From 6f652a50723f0fe0f8b055a1f532058c1dce3c18 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 31 Mar 2016 19:28:29 +0200 Subject: re PR hsa/70399 (HSA: Wrong emission of st_align(4)_u8 HSAIL insn) Fix PR hsa/70399 PR hsa/70399 * hsa-brig.c (hsa_op_immed::emit_to_buffer): Emit either a tree value or an immediate integer value to a buffer that is eventually copied to a BRIG section. (emit_immediate_operand): Call the function here. * hsa-dump.c (dump_hsa_immed): Remove checking assert. * hsa-gen.c (hsa_op_immed::hsa_op_immed): Remove initialization of class' fields that are removed. (hsa_op_immed::~hsa_op_immed): Remove deinitialization. * hsa.h (class hsa_op_immed): Remove m_brig_repr and m_brig_repr_size fields. From-SVN: r234647 --- gcc/hsa-gen.c | 68 ++++++++++++++--------------------------------------------- 1 file changed, 16 insertions(+), 52 deletions(-) (limited to 'gcc/hsa-gen.c') diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index 4c86023..bc95c5c 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -1075,8 +1075,7 @@ hsa_op_with_type::get_in_type (BrigType16_t dtype, hsa_bb *hbb) hsa_op_immed::hsa_op_immed (tree tree_val, bool min32int) : hsa_op_with_type (BRIG_KIND_OPERAND_CONSTANT_BYTES, hsa_type_for_tree_type (TREE_TYPE (tree_val), NULL, - min32int)), - m_brig_repr (NULL) + min32int)) { if (hsa_seen_error ()) return; @@ -1086,30 +1085,20 @@ hsa_op_immed::hsa_op_immed (tree tree_val, bool min32int) || TREE_CODE (tree_val) == INTEGER_CST)) || TREE_CODE (tree_val) == CONSTRUCTOR); m_tree_value = tree_val; - m_brig_repr_size = hsa_get_imm_brig_type_len (m_type); - if (TREE_CODE (m_tree_value) == STRING_CST) - m_brig_repr_size = TREE_STRING_LENGTH (m_tree_value); - else if (TREE_CODE (m_tree_value) == CONSTRUCTOR) - { - m_brig_repr_size - = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (m_tree_value))); - - /* Verify that all elements of a constructor are constants. */ - for (unsigned i = 0; - i < vec_safe_length (CONSTRUCTOR_ELTS (m_tree_value)); i++) - { - tree v = CONSTRUCTOR_ELT (m_tree_value, i)->value; - if (!CONSTANT_CLASS_P (v)) - { - HSA_SORRY_AT (EXPR_LOCATION (tree_val), - "HSA ctor should have only constants"); - return; - } - } - } - - emit_to_buffer (m_tree_value); + /* Verify that all elements of a constructor are constants. */ + if (TREE_CODE (m_tree_value) == CONSTRUCTOR) + for (unsigned i = 0; + i < vec_safe_length (CONSTRUCTOR_ELTS (m_tree_value)); i++) + { + tree v = CONSTRUCTOR_ELT (m_tree_value, i)->value; + if (!CONSTANT_CLASS_P (v)) + { + HSA_SORRY_AT (EXPR_LOCATION (tree_val), + "HSA ctor should have only constants"); + return; + } + } } /* Constructor of class representing HSA immediate values. INTEGER_VALUE is the @@ -1117,38 +1106,14 @@ hsa_op_immed::hsa_op_immed (tree tree_val, bool min32int) hsa_op_immed::hsa_op_immed (HOST_WIDE_INT integer_value, BrigType16_t type) : hsa_op_with_type (BRIG_KIND_OPERAND_CONSTANT_BYTES, type), - m_tree_value (NULL), m_brig_repr (NULL) + m_tree_value (NULL) { gcc_assert (hsa_type_integer_p (type)); m_int_value = integer_value; - m_brig_repr_size = hsa_type_bit_size (type) / BITS_PER_UNIT; - - hsa_bytes bytes; - - switch (m_brig_repr_size) - { - case 1: - bytes.b8 = (uint8_t) m_int_value; - break; - case 2: - bytes.b16 = (uint16_t) m_int_value; - break; - case 4: - bytes.b32 = (uint32_t) m_int_value; - break; - case 8: - bytes.b64 = (uint64_t) m_int_value; - break; - default: - gcc_unreachable (); - } - - m_brig_repr = XNEWVEC (char, m_brig_repr_size); - memcpy (m_brig_repr, &bytes, m_brig_repr_size); } hsa_op_immed::hsa_op_immed () - : hsa_op_with_type (BRIG_KIND_NONE, BRIG_TYPE_NONE), m_brig_repr (NULL) + : hsa_op_with_type (BRIG_KIND_NONE, BRIG_TYPE_NONE) { } @@ -1164,7 +1129,6 @@ hsa_op_immed::operator new (size_t) hsa_op_immed::~hsa_op_immed () { - free (m_brig_repr); } /* Change type of the immediate value to T. */ -- cgit v1.1