]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/brig/brigfrontend/brig-util.h
Update copyright years.
[thirdparty/gcc.git] / gcc / brig / brigfrontend / brig-util.h
CommitLineData
5fd1486c 1/* brig-util.h -- gccbrig utility functions
8d9254fc 2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
5fd1486c
PJ
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4 for General Processor Tech.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#ifndef GCC_BRIG_UTIL_H
23#define GCC_BRIG_UTIL_H
24
d4b7f2ee 25#include <map>
dc03239c 26#include <vector>
d4b7f2ee
PJ
27
28#include "config.h"
29#include "system.h"
30#include "ansidecl.h"
31#include "coretypes.h"
32#include "opts.h"
33#include "tree.h"
34
dc03239c
HL
35/* There are 128 c regs and 2048 s/d/q regs each in the HSAIL. */
36#define BRIG_2_TREE_HSAIL_C_REG_COUNT (128)
37#define BRIG_2_TREE_HSAIL_S_REG_COUNT (2048)
38#define BRIG_2_TREE_HSAIL_D_REG_COUNT (2048)
39#define BRIG_2_TREE_HSAIL_Q_REG_COUNT (2048)
40#define BRIG_2_TREE_HSAIL_TOTAL_REG_COUNT \
41 (BRIG_2_TREE_HSAIL_C_REG_COUNT + BRIG_2_TREE_HSAIL_S_REG_COUNT \
42 + BRIG_2_TREE_HSAIL_D_REG_COUNT + BRIG_2_TREE_HSAIL_Q_REG_COUNT)
43
d4b7f2ee
PJ
44/* Helper class for keeping book of group variable offsets. */
45
46class group_variable_offset_index
47{
48public:
49 group_variable_offset_index () : m_next_group_offset (0) {}
50
51 typedef std::map<std::string, size_t> varname_offset_table;
52
53 bool has_variable (const std::string &name) const;
54 void add (const std::string &name, size_t size, size_t alignment);
55 size_t segment_offset (const std::string &name) const;
56 size_t size () const { return m_next_group_offset; }
57
58private:
59 size_t m_next_group_offset;
60 varname_offset_table m_group_offsets;
61};
5fd1486c
PJ
62
63bool gccbrig_hsa_opcode_op_output_p (BrigOpcode16_t opcode, int opnum);
64
65unsigned gccbrig_hsa_type_bit_size (BrigType16_t t);
66
67uint64_t gccbrig_to_uint64_t (const BrigUInt64 &brig_type);
68
69int gccbrig_reg_size (const BrigOperandRegister *brig_reg);
70
71std::string gccbrig_reg_name (const BrigOperandRegister *reg);
72
73std::string gccbrig_type_name (BrigType16_t type);
74
75std::string gccbrig_segment_name (BrigSegment8_t segment);
76
77bool gccbrig_is_float_type (BrigType16_t type);
78
79bool gccbrig_is_bit_operation (BrigOpcode16_t opcode);
80
81BrigType16_t gccbrig_tree_type_to_hsa_type (tree tree_type);
82tree gccbrig_tree_type_for_hsa_type (BrigType16_t brig_type);
83
84bool gccbrig_might_be_host_defined_var_p (const BrigDirectiveVariable *brigVar);
85
86/* From hsa.h. */
87bool hsa_type_packed_p (BrigType16_t type);
88
dc03239c
HL
89struct reg_use_info
90{
91 /* This vector keeps count of the times an HSAIL register is used as
92 a tree type in generic expressions. The count is used to select
93 type for 'register' variables to reduce emission of
94 VIEW_CONVERT_EXPR nodes. The data is kept in vector (insertion
95 order) for determinism, in a case there is a tie with the
96 counts. */
97 std::vector<std::pair<tree, size_t> > m_type_refs;
98 /* Tree to index. Lookup for the above vector. */
99 std::map<tree, size_t> m_type_refs_lookup;
100};
101
102/* key = hsa register entry generated by gccbrig_hsa_reg_id (). */
103typedef std::map<size_t, reg_use_info> regs_use_index;
104
105size_t gccbrig_hsa_reg_id (const BrigOperandRegister &reg);
106std::string gccbrig_hsa_reg_name_from_id (size_t reg_hash);
107
108void gccbrig_print_reg_use_info (FILE *dump, const regs_use_index &info);
109
e112bba2
RS
110/* Return the number of elements in a VECTOR_TYPE. BRIG does not support
111 variable-length vectors. */
112inline unsigned HOST_WIDE_INT
113gccbrig_type_vector_subparts (const_tree type)
114{
928686b1 115 return TYPE_VECTOR_SUBPARTS (type).to_constant ();
e112bba2
RS
116}
117
5fd1486c 118#endif