annotate gcc/brig/brigfrontend/brig-lane-inst-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-lane-inst-handler.cc -- brig lane instruction 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 "errors.h"
kono
parents:
diff changeset
24 #include "diagnostic-core.h"
kono
parents:
diff changeset
25 #include "brig-util.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 brig_lane_inst_handler::brig_lane_inst_handler (brig_to_generic &parent)
kono
parents:
diff changeset
28 : brig_code_entry_handler (parent)
kono
parents:
diff changeset
29 {
kono
parents:
diff changeset
30 }
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 size_t
kono
parents:
diff changeset
33 brig_lane_inst_handler::operator () (const BrigBase *base)
kono
parents:
diff changeset
34 {
kono
parents:
diff changeset
35 const BrigInstLane &inst = *(const BrigInstLane *) base;
kono
parents:
diff changeset
36 tree_stl_vec operands = build_operands (inst.base);
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 tree expr = NULL_TREE;
kono
parents:
diff changeset
39 if (inst.base.opcode == BRIG_OPCODE_ACTIVELANECOUNT)
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 /* Because we are fixed to single WI per wave, it's enough to
kono
parents:
diff changeset
42 just check the src value of the single work item itself. */
kono
parents:
diff changeset
43 expr = build2 (NE_EXPR, uint32_type_node,
kono
parents:
diff changeset
44 build_zero_cst (uint32_type_node), operands[1]);
kono
parents:
diff changeset
45 }
kono
parents:
diff changeset
46 else if (inst.base.opcode == BRIG_OPCODE_ACTIVELANEID)
kono
parents:
diff changeset
47 {
kono
parents:
diff changeset
48 expr = build_zero_cst (uint32_type_node);
kono
parents:
diff changeset
49 }
kono
parents:
diff changeset
50 else if (inst.base.opcode == BRIG_OPCODE_ACTIVELANEMASK)
kono
parents:
diff changeset
51 {
kono
parents:
diff changeset
52 tree u64_type = gccbrig_tree_type_for_hsa_type (BRIG_TYPE_U64);
kono
parents:
diff changeset
53 tree zero_cst = build_zero_cst (u64_type);
kono
parents:
diff changeset
54 expr = build2 (NE_EXPR, u64_type, zero_cst, operands[1]);
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 tree_stl_vec elements;
kono
parents:
diff changeset
57 elements.push_back (expr);
kono
parents:
diff changeset
58 elements.push_back (zero_cst);
kono
parents:
diff changeset
59 elements.push_back (zero_cst);
kono
parents:
diff changeset
60 elements.push_back (zero_cst);
kono
parents:
diff changeset
61
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 expr = m_parent.m_cf->pack (elements);
111
kono
parents:
diff changeset
63 }
kono
parents:
diff changeset
64 else if (inst.base.opcode == BRIG_OPCODE_ACTIVELANEPERMUTE)
kono
parents:
diff changeset
65 {
kono
parents:
diff changeset
66 tree src = operands[1];
kono
parents:
diff changeset
67 tree identity = operands[3];
kono
parents:
diff changeset
68 tree use_identity = operands[4];
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* When WAVESIZE is 1, we either select the src of the work-item
kono
parents:
diff changeset
71 itself or 'identity' in case use_identity is 1. */
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 tree cmp = build2 (EQ_EXPR, uint32_type_node,
kono
parents:
diff changeset
74 build_int_cstu (TREE_TYPE (use_identity), 1),
kono
parents:
diff changeset
75 use_identity);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 expr = build3 (COND_EXPR, TREE_TYPE (src), cmp, identity, src);
kono
parents:
diff changeset
78 }
kono
parents:
diff changeset
79 else
kono
parents:
diff changeset
80 gcc_unreachable ();
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 build_output_assignment (inst.base, operands[0], expr);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 return base->byteCount;
kono
parents:
diff changeset
85 }