annotate gcc/brig/brigfrontend/brig-control-handler.cc @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* brig-control-handler.cc -- brig control directive handling
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
kono
parents:
diff changeset
4 for General Processor Tech.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
11 version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
16 for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #include "brig-code-entry-handler.h"
kono
parents:
diff changeset
23 #include "diagnostic.h"
kono
parents:
diff changeset
24 #include "print-tree.h"
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 size_t
kono
parents:
diff changeset
27 brig_directive_control_handler::operator () (const BrigBase *base)
kono
parents:
diff changeset
28 {
kono
parents:
diff changeset
29 const BrigDirectiveControl *inst = (const BrigDirectiveControl *) base;
kono
parents:
diff changeset
30 const BrigData *operand_entries
kono
parents:
diff changeset
31 = m_parent.get_brig_data_entry (inst->operands);
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 /* Parse the constant integer operands. */
kono
parents:
diff changeset
34 std::vector<tree> operands;
kono
parents:
diff changeset
35 for (size_t i = 0; i < operand_entries->byteCount / 4; ++i)
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 uint32_t operand_offset
kono
parents:
diff changeset
38 = ((const uint32_t *) &operand_entries->bytes)[i];
kono
parents:
diff changeset
39 const BrigBase *operand_data
kono
parents:
diff changeset
40 = m_parent.get_brig_operand_entry (operand_offset);
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 tree operand_type
kono
parents:
diff changeset
43 = (inst->control == BRIG_CONTROL_REQUIREDGRIDSIZE
kono
parents:
diff changeset
44 || inst->control == BRIG_CONTROL_MAXFLATGRIDSIZE) ?
kono
parents:
diff changeset
45 uint64_type_node : uint32_type_node;
kono
parents:
diff changeset
46 operands.push_back
kono
parents:
diff changeset
47 (build_tree_operand (*(const BrigInstBase*)inst, *operand_data,
kono
parents:
diff changeset
48 operand_type));
kono
parents:
diff changeset
49 }
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 switch (inst->control)
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 case BRIG_CONTROL_MAXDYNAMICGROUPSIZE:
kono
parents:
diff changeset
54 {
kono
parents:
diff changeset
55 m_parent.m_cf->m_descriptor.max_dynamic_group_size
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
56 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
57 break;
kono
parents:
diff changeset
58 }
kono
parents:
diff changeset
59 case BRIG_CONTROL_MAXFLATGRIDSIZE:
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 m_parent.m_cf->m_descriptor.max_flat_grid_size
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
63 break;
kono
parents:
diff changeset
64 }
kono
parents:
diff changeset
65 case BRIG_CONTROL_MAXFLATWORKGROUPSIZE:
kono
parents:
diff changeset
66 {
kono
parents:
diff changeset
67 m_parent.m_cf->m_descriptor.max_flat_workgroup_size
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
69 break;
kono
parents:
diff changeset
70 }
kono
parents:
diff changeset
71 case BRIG_CONTROL_REQUIREDDIM:
kono
parents:
diff changeset
72 {
kono
parents:
diff changeset
73 m_parent.m_cf->m_descriptor.required_dim
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
75 break;
kono
parents:
diff changeset
76 }
kono
parents:
diff changeset
77 case BRIG_CONTROL_REQUIREDGRIDSIZE:
kono
parents:
diff changeset
78 {
kono
parents:
diff changeset
79 m_parent.m_cf->m_descriptor.required_grid_size[0]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
81 m_parent.m_cf->m_descriptor.required_grid_size[1]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 = brig_function::int_constant_value (operands.at (1));
111
kono
parents:
diff changeset
83 m_parent.m_cf->m_descriptor.required_grid_size[2]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84 = brig_function::int_constant_value (operands.at (2));
111
kono
parents:
diff changeset
85 break;
kono
parents:
diff changeset
86 }
kono
parents:
diff changeset
87 case BRIG_CONTROL_REQUIREDWORKGROUPSIZE:
kono
parents:
diff changeset
88 {
kono
parents:
diff changeset
89 m_parent.m_cf->m_descriptor.required_workgroup_size[0]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
90 = brig_function::int_constant_value (operands.at (0));
111
kono
parents:
diff changeset
91 m_parent.m_cf->m_descriptor.required_workgroup_size[1]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 = brig_function::int_constant_value (operands.at (1));
111
kono
parents:
diff changeset
93 m_parent.m_cf->m_descriptor.required_workgroup_size[2]
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
94 = brig_function::int_constant_value (operands.at (2));
111
kono
parents:
diff changeset
95 break;
kono
parents:
diff changeset
96 }
kono
parents:
diff changeset
97 case BRIG_CONTROL_REQUIRENOPARTIALWORKGROUPS:
kono
parents:
diff changeset
98 /* Performance hint only, ignored for now. */
kono
parents:
diff changeset
99 break;
kono
parents:
diff changeset
100 case BRIG_CONTROL_ENABLEBREAKEXCEPTIONS:
kono
parents:
diff changeset
101 case BRIG_CONTROL_ENABLEDETECTEXCEPTIONS:
kono
parents:
diff changeset
102 /* Unimplemented. */
kono
parents:
diff changeset
103 break;
kono
parents:
diff changeset
104 default:
kono
parents:
diff changeset
105 sorry ("Unsupported control directive %x.\n", inst->control);
kono
parents:
diff changeset
106 }
kono
parents:
diff changeset
107 return base->byteCount;
kono
parents:
diff changeset
108 }