Mercurial > hg > CbC > CbC_gcc
comparison gcc/brig/brigfrontend/brig-branch-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-branch-inst-handler.cc -- brig branch instruction handling | 1 /* brig-branch-inst-handler.cc -- brig branch instruction handling |
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 |
117 /* Pass the hidden kernel arguments along to the called functions as | 117 /* Pass the hidden kernel arguments along to the called functions as |
118 they might call builtins that need them or access group/private | 118 they might call builtins that need them or access group/private |
119 memory. */ | 119 memory. */ |
120 | 120 |
121 tree group_local_offset | 121 tree group_local_offset |
122 = add_temp_var ("group_local_offset", | 122 = m_parent.m_cf->add_temp_var ("group_local_offset", |
123 build_int_cst | 123 build_int_cst |
124 (uint32_type_node, | 124 (uint32_type_node, |
125 m_parent.m_cf->m_local_group_variables.size())); | 125 m_parent.m_cf-> |
126 m_local_group_variables.size())); | |
126 | 127 |
127 /* TODO: ensure the callee's frame is aligned! */ | 128 /* TODO: ensure the callee's frame is aligned! */ |
128 | 129 |
129 vec_safe_reserve (in_args, 4); | 130 vec_safe_reserve (in_args, 4); |
130 vec_safe_push (in_args, m_parent.m_cf->m_context_arg); | 131 vec_safe_push (in_args, m_parent.m_cf->m_context_arg); |
148 { | 149 { |
149 m_parent.m_cf->append_statement (call); | 150 m_parent.m_cf->append_statement (call); |
150 } | 151 } |
151 | 152 |
152 m_parent.m_cf->m_called_functions.push_back (func_ref); | 153 m_parent.m_cf->m_called_functions.push_back (func_ref); |
154 if (DECL_EXTERNAL (func_ref)) | |
155 m_parent.add_decl_call (call); | |
156 m_parent.m_cf->start_new_bb (); | |
153 | 157 |
154 return base->byteCount; | 158 return base->byteCount; |
155 } | 159 } |
156 | 160 |
157 tree instr_type = gccbrig_tree_type_for_hsa_type (brig_inst->type); | 161 tree instr_type = gccbrig_tree_type_for_hsa_type (brig_inst->type); |
165 else if (brig_inst->opcode == BRIG_OPCODE_SBR) | 169 else if (brig_inst->opcode == BRIG_OPCODE_SBR) |
166 { | 170 { |
167 tree select = operands[0]; | 171 tree select = operands[0]; |
168 tree cases = operands[1]; | 172 tree cases = operands[1]; |
169 | 173 |
170 tree switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (select), select, | 174 tree switch_expr = build2 (SWITCH_EXPR, TREE_TYPE (select), select, |
171 NULL_TREE, NULL_TREE); | 175 NULL_TREE); |
172 | 176 |
173 tree default_case | 177 tree default_case |
174 = build_case_label (NULL_TREE, NULL_TREE, | 178 = build_case_label (NULL_TREE, NULL_TREE, |
175 create_artificial_label (UNKNOWN_LOCATION)); | 179 create_artificial_label (UNKNOWN_LOCATION)); |
176 append_to_statement_list (default_case, &SWITCH_BODY (switch_expr)); | 180 append_to_statement_list (default_case, &SWITCH_BODY (switch_expr)); |
212 tree_stl_vec call_operands; | 216 tree_stl_vec call_operands; |
213 /* FIXME. We should add attributes (are there suitable ones in gcc?) that | 217 /* FIXME. We should add attributes (are there suitable ones in gcc?) that |
214 ensure the barrier won't be duplicated or moved out of loops etc. | 218 ensure the barrier won't be duplicated or moved out of loops etc. |
215 Like the 'noduplicate' of LLVM. Same goes for fbarriers. */ | 219 Like the 'noduplicate' of LLVM. Same goes for fbarriers. */ |
216 m_parent.m_cf->append_statement | 220 m_parent.m_cf->append_statement |
217 (expand_or_call_builtin (brig_inst->opcode, BRIG_TYPE_NONE, NULL_TREE, | 221 (m_parent.m_cf->expand_or_call_builtin (brig_inst->opcode, |
218 call_operands)); | 222 BRIG_TYPE_NONE, NULL_TREE, |
223 call_operands)); | |
219 } | 224 } |
220 else if (brig_inst->opcode >= BRIG_OPCODE_ARRIVEFBAR | 225 else if (brig_inst->opcode >= BRIG_OPCODE_ARRIVEFBAR |
221 && brig_inst->opcode <= BRIG_OPCODE_WAITFBAR) | 226 && brig_inst->opcode <= BRIG_OPCODE_WAITFBAR) |
222 { | 227 { |
223 m_parent.m_cf->m_has_barriers = true; | 228 m_parent.m_cf->m_has_barriers = true; |
224 m_parent.m_cf->append_statement | 229 m_parent.m_cf->append_statement |
225 (expand_or_call_builtin (brig_inst->opcode, BRIG_TYPE_NONE, | 230 (m_parent.m_cf->expand_or_call_builtin (brig_inst->opcode, |
226 uint32_type_node, operands)); | 231 BRIG_TYPE_NONE, |
232 uint32_type_node, operands)); | |
227 } | 233 } |
228 else | 234 else |
229 gcc_unreachable (); | 235 gcc_unreachable (); |
236 m_parent.m_cf->start_new_bb (); | |
230 return base->byteCount; | 237 return base->byteCount; |
231 } | 238 } |