This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[hsa-branch 2/5] Make emit_insn_operands handle zero operands
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 2 Jun 2016 18:32:39 +0200
- Subject: [hsa-branch 2/5] Make emit_insn_operands handle zero operands
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1465479214 dot git dot mjambor at suse dot 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