public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [hsa-branch 2/5] Make emit_insn_operands handle zero operands
Date: Thu, 09 Jun 2016 14:01:00 -0000	[thread overview]
Message-ID: <6d712c697c72d0d6359fd9e57f1b8e012565686e.1465479214.git.mjambor@suse.cz> (raw)
In-Reply-To: <cover.1465479214.git.mjambor@suse.cz>

Hi,

the patch below allows emit_insn_operands to instructions with no
operands gracefully.  Apparently so far we have not produced any.

I'll commit this to the hsa branch in a few moments and then to trunk
at some point in summer.

Martin

2016-06-02  Martin Jambor  <mjambor@suse.cz>

	* hsa-brig.c (emit_insn_operands): Cope with zero operands in an
	instruction.
---
 gcc/hsa-brig.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c
index 9c74b9a..471533c 100644
--- a/gcc/hsa-brig.c
+++ b/gcc/hsa-brig.c
@@ -1236,20 +1236,20 @@ emit_insn_operands (hsa_insn_basic *insn)
     operand_offsets;
 
   unsigned l = insn->operand_count ();
-  operand_offsets.safe_grow (l);
-
-  for (unsigned i = 0; i < l; i++)
-    operand_offsets[i] = lendian32 (enqueue_op (insn->get_op (i)));
 
   /* We have N operands so use 4 * N for the byte_count.  */
   uint32_t byte_count = lendian32 (4 * l);
-
   unsigned offset = brig_data.add (&byte_count, sizeof (byte_count));
-  brig_data.add (operand_offsets.address (),
-		 l * sizeof (BrigOperandOffset32_t));
+  if (l > 0)
+    {
+      operand_offsets.safe_grow (l);
+      for (unsigned i = 0; i < l; i++)
+	operand_offsets[i] = lendian32 (enqueue_op (insn->get_op (i)));
 
+      brig_data.add (operand_offsets.address (),
+		     l * sizeof (BrigOperandOffset32_t));
+    }
   brig_data.round_size_up (4);
-
   return offset;
 }
 
-- 
2.8.2

  parent reply	other threads:[~2016-06-09 14:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 14:01 [hsa-branch 0/5] Gridification support for tiling algorithms Martin Jambor
2016-06-09 14:01 ` [hsa-branch 1/5] Allow putting local variables into group and global segments Martin Jambor
2016-06-09 14:01 ` [hsa-branch 5/5] OMP lowering/expansion changes to gridify tiled loops Martin Jambor
2016-06-09 14:01 ` Martin Jambor [this message]
2016-06-09 14:01 ` [hsa-branch 3/5] Reorganize HSA branches representation Martin Jambor
2016-06-09 14:01 ` [hsa-branch 4/5] New HSA builtins needed for tiling Martin Jambor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d712c697c72d0d6359fd9e57f1b8e012565686e.1465479214.git.mjambor@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).