]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/brig/brigfrontend/brig-queue-inst-handler.cc
Update copyright years.
[thirdparty/gcc.git] / gcc / brig / brigfrontend / brig-queue-inst-handler.cc
CommitLineData
5fd1486c
PJ
1/* brig-queue-inst-handler.cc -- brig user mode queue related instruction
2 handling
8d9254fc 3 Copyright (C) 2016-2020 Free Software Foundation, Inc.
5fd1486c
PJ
4 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
5 for General Processor Tech.
6
7This file is part of GCC.
8
9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 3, or (at your option) any later
12version.
13
14GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
18
19You should have received a copy of the GNU General Public License
20along with GCC; see the file COPYING3. If not see
21<http://www.gnu.org/licenses/>. */
22
23#include <sstream>
24
25#include "brig-code-entry-handler.h"
26#include "brig-util.h"
27#include "convert.h"
28#include "tree-pretty-print.h"
29#include "errors.h"
30#include "diagnostic-core.h"
31#include "brig-builtins.h"
32
33brig_queue_inst_handler::brig_queue_inst_handler (brig_to_generic &parent)
34 : brig_code_entry_handler (parent)
35{
36}
37
38size_t
39brig_queue_inst_handler::operator () (const BrigBase *base)
40{
41 const BrigInstBase &inst_base = *(const BrigInstBase *) base;
42
43 tree_stl_vec operands = build_operands (inst_base);
44
45 if (inst_base.opcode == BRIG_OPCODE_LDQUEUEWRITEINDEX
46 || inst_base.opcode == BRIG_OPCODE_LDQUEUEREADINDEX)
47 {
48 tree builtin
49 = inst_base.opcode == BRIG_OPCODE_LDQUEUEWRITEINDEX
50 ? builtin_decl_explicit (BUILT_IN_HSAIL_LDQUEUEWRITEINDEX)
51 : builtin_decl_explicit (BUILT_IN_HSAIL_LDQUEUEREADINDEX);
52
53 tree expr
54 = call_builtin (builtin, 1, uint64_type_node,
55 uint64_type_node, operands[1]);
56 build_output_assignment (inst_base, operands[0], expr);
57 }
58 else if (inst_base.opcode == BRIG_OPCODE_STQUEUEWRITEINDEX
59 || inst_base.opcode == BRIG_OPCODE_STQUEUEREADINDEX)
60 {
61 tree builtin
62 = inst_base.opcode == BRIG_OPCODE_STQUEUEWRITEINDEX
63 ? builtin_decl_explicit (BUILT_IN_HSAIL_STQUEUEWRITEINDEX)
64 : builtin_decl_explicit (BUILT_IN_HSAIL_STQUEUEREADINDEX);
65
66 call_builtin (builtin, 2, void_type_node,
67 uint64_type_node, operands[0], uint64_type_node,
68 operands[1]);
69 }
70 else if (inst_base.opcode == BRIG_OPCODE_ADDQUEUEWRITEINDEX)
71 {
72 tree builtin = builtin_decl_explicit (BUILT_IN_HSAIL_ADDQUEUEWRITEINDEX);
73
74 tree expr = call_builtin (builtin, 2,
75 uint64_type_node, uint64_type_node, operands[1],
76 uint64_type_node, operands[2]);
77 build_output_assignment (inst_base, operands[0], expr);
78 }
79 else if (inst_base.opcode == BRIG_OPCODE_CASQUEUEWRITEINDEX)
80 {
81 tree builtin = builtin_decl_explicit (BUILT_IN_HSAIL_CASQUEUEWRITEINDEX);
82
83 tree expr
84 = call_builtin (builtin, 3, uint64_type_node,
85 uint64_type_node, operands[1], uint64_type_node,
86 operands[2], uint64_type_node, operands[3]);
87 build_output_assignment (inst_base, operands[0], expr);
88 }
89 else
90 gcc_unreachable ();
91
92 return base->byteCount;
93}