aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/hsa-gen.c28
-rw-r--r--gcc/hsa.c8
-rw-r--r--gcc/hsa.h12
4 files changed, 41 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index de2189a..bf03f18 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
2016-02-26 Martin Jambor <mjambor@suse.cz>
+ * hsa.h (is_a_helper): New overload for hsa_op_immed for
+ hsa_op_with_type operands.
+ (hsa_unsigned_type_for_type): Declare.
+ * hsa.c (hsa_unsigned_type_for_type): New function.
+ * hsa-gen.c (gen_hsa_binary_operation): Use hsa_unsigned_type_for_type.
+ (gen_hsa_insns_for_operation_assignment): Satisfy constrains of
+ the finalizer. Do not emit extra move.
+
+2016-02-26 Martin Jambor <mjambor@suse.cz>
+
* hsa-gen.c (gen_hsa_ternary_atomic_for_builtin): Fail in presence of
atomic operations in private segment.
diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index 7a7ec41..be402dd 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -3022,7 +3022,7 @@ gen_hsa_binary_operation (int opcode, hsa_op_reg *dest,
&& is_a <hsa_op_immed *> (op2))
{
hsa_op_immed *i = dyn_cast <hsa_op_immed *> (op2);
- i->set_type (hsa_uint_for_bitsize (hsa_type_bit_size (i->m_type)));
+ i->set_type (hsa_unsigned_type_for_type (i->m_type));
}
hsa_insn_basic *insn = new hsa_insn_basic (3, opcode, dest->m_type, dest,
@@ -3233,27 +3233,21 @@ gen_hsa_insns_for_operation_assignment (gimple *assign, hsa_bb *hbb)
ctrl = r;
}
- hsa_op_with_type *rhs2_reg = hsa_reg_or_immed_for_gimple_op (rhs2, hbb);
- hsa_op_with_type *rhs3_reg = hsa_reg_or_immed_for_gimple_op (rhs3, hbb);
-
- BrigType16_t btype = hsa_bittype_for_type (dest->m_type);
- hsa_op_reg *tmp = new hsa_op_reg (btype);
+ hsa_op_with_type *op2 = hsa_reg_or_immed_for_gimple_op (rhs2, hbb);
+ hsa_op_with_type *op3 = hsa_reg_or_immed_for_gimple_op (rhs3, hbb);
- rhs2_reg->m_type = btype;
- rhs3_reg->m_type = btype;
+ BrigType16_t utype = hsa_unsigned_type_for_type (dest->m_type);
+ if (is_a <hsa_op_immed *> (op2))
+ op2->m_type = utype;
+ if (is_a <hsa_op_immed *> (op3))
+ op3->m_type = utype;
hsa_insn_basic *insn
- = new hsa_insn_basic (4, BRIG_OPCODE_CMOV, tmp->m_type, tmp, ctrl,
- rhs2_reg, rhs3_reg);
+ = new hsa_insn_basic (4, BRIG_OPCODE_CMOV,
+ hsa_bittype_for_type (dest->m_type),
+ dest, ctrl, op2, op3);
hbb->append_insn (insn);
-
- /* As operands of a CMOV insn must be Bx types, we have to emit
- a conversion insn. */
- hsa_insn_basic *mov = new hsa_insn_basic (2, BRIG_OPCODE_MOV,
- dest->m_type, dest, tmp);
- hbb->append_insn (mov);
-
return;
}
case COMPLEX_EXPR:
diff --git a/gcc/hsa.c b/gcc/hsa.c
index f0b3205..9537e29 100644
--- a/gcc/hsa.c
+++ b/gcc/hsa.c
@@ -472,6 +472,14 @@ hsa_bittype_for_type (BrigType16_t t)
return hsa_bittype_for_bitsize (hsa_type_bit_size (t));
}
+/* Return HSA unsigned integer type with the same size as the type T. */
+
+BrigType16_t
+hsa_unsigned_type_for_type (BrigType16_t t)
+{
+ return hsa_uint_for_bitsize (hsa_type_bit_size (t));
+}
+
/* Return true if and only if TYPE is a floating point number type. */
bool
diff --git a/gcc/hsa.h b/gcc/hsa.h
index f0436f3..275a954 100644
--- a/gcc/hsa.h
+++ b/gcc/hsa.h
@@ -199,6 +199,17 @@ is_a_helper <hsa_op_immed *>::test (hsa_op_base *p)
return p->m_kind == BRIG_KIND_OPERAND_CONSTANT_BYTES;
}
+/* Likewise, but for a more specified base. */
+
+template <>
+template <>
+inline bool
+is_a_helper <hsa_op_immed *>::test (hsa_op_with_type *p)
+{
+ return p->m_kind == BRIG_KIND_OPERAND_CONSTANT_BYTES;
+}
+
+
/* HSA register operand. */
class hsa_op_reg : public hsa_op_with_type
@@ -1326,6 +1337,7 @@ BrigType16_t hsa_bittype_for_bitsize (unsigned bitsize);
BrigType16_t hsa_uint_for_bitsize (unsigned bitsize);
BrigType16_t hsa_float_for_bitsize (unsigned bitsize);
BrigType16_t hsa_bittype_for_type (BrigType16_t t);
+BrigType16_t hsa_unsigned_type_for_type (BrigType16_t t);
bool hsa_type_float_p (BrigType16_t type);
bool hsa_type_integer_p (BrigType16_t type);
bool hsa_btype_p (BrigType16_t type);