Mercurial > hg > CbC > CbC_gcc
comparison gcc/brig/brigfrontend/brig-mem-inst-handler.cc @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* brig-mem-inst-handler.cc -- brig memory inst handler | 1 /* brig-mem-inst-handler.cc -- brig memory inst handler |
2 Copyright (C) 2016-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2016-2018 Free Software Foundation, Inc. |
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com> | 3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com> |
4 for General Processor Tech. | 4 for General Processor Tech. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
39 if (!is_load && !is_store) | 39 if (!is_load && !is_store) |
40 gcc_unreachable (); | 40 gcc_unreachable (); |
41 | 41 |
42 tree instr_type = gccbrig_tree_type_for_hsa_type (brig_inst->type); | 42 tree instr_type = gccbrig_tree_type_for_hsa_type (brig_inst->type); |
43 | 43 |
44 if (VECTOR_TYPE_P (TREE_TYPE (data))) | 44 /* In case of {ld,st}_v{2,4}. Note: since 'register' variables may |
45 be any type, even a vector type, we distinguish the registers | |
46 from operand lists by checking for constructor nodes (which | |
47 operand lists are represented as). */ | |
48 if (VECTOR_TYPE_P (TREE_TYPE (data)) && TREE_CODE (data) == CONSTRUCTOR) | |
45 instr_type = TREE_TYPE (data); | 49 instr_type = TREE_TYPE (data); |
46 | 50 |
47 tree ptype = build_pointer_type (instr_type); | 51 tree ptype = build_pointer_type (instr_type); |
48 | 52 |
49 /* The HSAIL mem instructions are unaligned by default. | 53 /* The HSAIL mem instructions are unaligned by default. |
57 | 61 |
58 if (is_load) | 62 if (is_load) |
59 { | 63 { |
60 /* Add a temporary variable so there won't be multiple | 64 /* Add a temporary variable so there won't be multiple |
61 reads in case of vector unpack. */ | 65 reads in case of vector unpack. */ |
62 mem_ref = add_temp_var ("mem_read", mem_ref); | 66 mem_ref = m_parent.m_cf->add_temp_var ("mem_read", mem_ref); |
63 return build_output_assignment (*brig_inst, data, mem_ref); | 67 return build_output_assignment (*brig_inst, data, mem_ref); |
64 } | 68 } |
65 else | 69 else |
66 { | 70 { |
67 tree stmt = build2 (MODIFY_EXPR, TREE_TYPE (mem_ref), mem_ref, data); | 71 tree stmt = build2 (MODIFY_EXPR, TREE_TYPE (mem_ref), mem_ref, data); |
89 tree align_opr = build_int_cstu (size_type_node, alignment); | 93 tree align_opr = build_int_cstu (size_type_node, alignment); |
90 tree_stl_vec inputs; | 94 tree_stl_vec inputs; |
91 inputs.push_back (operands[1]); | 95 inputs.push_back (operands[1]); |
92 inputs.push_back (align_opr); | 96 inputs.push_back (align_opr); |
93 tree builtin_call | 97 tree builtin_call |
94 = expand_or_call_builtin (BRIG_OPCODE_ALLOCA, BRIG_TYPE_U32, | 98 = m_parent.m_cf->expand_or_call_builtin (BRIG_OPCODE_ALLOCA, |
95 uint32_type_node, inputs); | 99 BRIG_TYPE_U32, |
100 uint32_type_node, inputs); | |
96 build_output_assignment (*brig_inst, operands[0], builtin_call); | 101 build_output_assignment (*brig_inst, operands[0], builtin_call); |
97 m_parent.m_cf->m_has_allocas = true; | 102 m_parent.m_cf->m_has_allocas = true; |
98 return base->byteCount; | 103 return base->byteCount; |
99 } | 104 } |
100 | 105 |
149 tree ptr_offset = build_int_cst (size_type_node, address_offset); | 154 tree ptr_offset = build_int_cst (size_type_node, address_offset); |
150 tree address = build2 (POINTER_PLUS_EXPR, TREE_TYPE (address_base), | 155 tree address = build2 (POINTER_PLUS_EXPR, TREE_TYPE (address_base), |
151 address_base, ptr_offset); | 156 address_base, ptr_offset); |
152 | 157 |
153 if (is_store && TREE_TYPE (data) != instr_type) | 158 if (is_store && TREE_TYPE (data) != instr_type) |
154 { | 159 data = build_resize_convert_view (instr_type, data); |
155 if (int_size_in_bytes (TREE_TYPE (data)) | |
156 == int_size_in_bytes (instr_type) | |
157 && !INTEGRAL_TYPE_P (instr_type)) | |
158 data = build1 (VIEW_CONVERT_EXPR, instr_type, data); | |
159 else | |
160 data = convert (instr_type, data); | |
161 } | |
162 | 160 |
163 build_mem_access (brig_inst, address, data); | 161 build_mem_access (brig_inst, address, data); |
164 | 162 |
165 address_offset += int_size_in_bytes (instr_type); | 163 address_offset += int_size_in_bytes (instr_type); |
166 ++operand_ptr; | 164 ++operand_ptr; |