GCC Middle and Back End API Reference
gimplify_reg_info.h
Go to the documentation of this file.
1/* gimplify_reg_info is used during gimplification while walking over
2 operands and their corresponding constraints of asm statements in order to
3 detect errors.
4
5 m_alt_output is a mapping describing which registers are potentially used in
6 which alternative over all outputs. Similarly for m_alt_input but over all
7 inputs.
8
9 m_early_clobbered_alt is a mapping describing which register is early
10 clobbered in which alternative over all outputs.
11
12 m_early_clobbered_output is the counter part to the prior one, i.e., it
13 is a mapping describing which register is early clobbered in which operand
14 over all alternatives.
15
16 m_reg_asm_output is the set of registers (including register pairs) used for
17 register asm output operands.
18
19 m_reg_asm_input similar as m_reg_asm_output but for inputs. */
20
21#include "regs.h"
22
24{
32 const unsigned m_num_alternatives;
33 const unsigned m_num_outputs;
34 /* Member m_clobbered describes all the registers marked as clobbered in an
35 asm statement, i.e., this is the clobbers list of an extended asm
36
37 asm asm-qualifiers ( AssemblerTemplate
38 : OutputOperands
39 [ : InputOperands
40 [ : Clobbers ] ])
41
42 and is not to be confused with the early clobbers sets. */
44
45 /* Return the first overlapping register of REGS and REGNO:MODE or -1. */
46 int test (const HARD_REG_SET &regs, int regno) const
47 {
48 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
49
50 if (TEST_HARD_REG_BIT (regs, regno))
51 return regno;
52
53 int end_regno = end_hard_regno (mode, regno);
54 while (++regno < end_regno)
55 if (TEST_HARD_REG_BIT (regs, regno))
56 return regno;
57
58 return -1;
59 }
60
61public:
63
65 unsigned num_outputs)
67 , m_num_outputs{num_outputs}
68 {
72
73 /* If there are no alternatives, then there are no outputs/inputs and there
74 is nothing to do on our end. Thus, we are dealing most likely with a
75 basic asm. */
76 if (num_alternatives == 0)
77 return;
78
79 unsigned buf_size = num_alternatives * 3 + num_outputs;
80 m_buf = new HARD_REG_SET[buf_size];
81 for (unsigned i = 0; i < buf_size; ++i)
83 m_alt_output = &m_buf[0];
86 if (num_outputs > 0)
88 else
90 }
91
93 {
94 if (m_num_alternatives > 0)
95 delete[] m_buf;
96 }
97
98 void set_output (unsigned alt, int regno)
99 {
101 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
102 add_to_hard_reg_set (&m_alt_output[alt], mode, regno);
103 }
104
105 void set_input (unsigned alt, int regno)
106 {
108 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
109 add_to_hard_reg_set (&m_alt_input[alt], mode, regno);
110 }
111
112 int test_alt_output (unsigned alt, int regno) const
113 {
115 return test (m_alt_output[alt], regno);
116 }
117
118 int test_alt_input (unsigned alt, int regno) const
119 {
121 return test (m_alt_input[alt], regno);
122 }
123
124 void set_reg_asm_output (int regno)
125 {
126 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
128 }
129
130 int test_reg_asm_output (int regno) const
131 {
132 return test (m_reg_asm_output, regno);
133 }
134
135 void set_reg_asm_input (int regno)
136 {
137 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
138 add_to_hard_reg_set (&m_reg_asm_input, mode, regno);
139 }
140
141 int test_reg_asm_input (int regno) const
142 {
143 return test (m_reg_asm_input, regno);
144 }
145
146 void set_early_clobbered (unsigned alt, unsigned output, int regno)
147 {
150 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
151 add_to_hard_reg_set (&m_early_clobbered_alt[alt], mode, regno);
152 add_to_hard_reg_set (&m_early_clobbered_output[output], mode, regno);
153 }
154
155 bool test_early_clobbered_alt (unsigned alt, int regno) const
156 {
158 return TEST_HARD_REG_BIT (m_early_clobbered_alt[alt], regno);
159 }
160
162 int regno) const
163 {
165 for (unsigned op = 0; op < m_num_outputs; ++op)
166 if (op != operand
168 return true;
169 return false;
170 }
171
172 void set_clobbered (int regno)
173 {
175 }
176
177 bool is_clobbered (int regno) const
178 {
179 machine_mode mode = TYPE_MODE (TREE_TYPE (operand));
180 return overlaps_hard_reg_set_p (m_clobbered, mode, regno);
181 }
182};
int test_reg_asm_output(int regno) const
Definition gimplify_reg_info.h:130
HARD_REG_SET * m_early_clobbered_output
Definition gimplify_reg_info.h:29
tree operand
Definition gimplify_reg_info.h:62
HARD_REG_SET * m_buf
Definition gimplify_reg_info.h:25
const unsigned m_num_alternatives
Definition gimplify_reg_info.h:32
void set_reg_asm_output(int regno)
Definition gimplify_reg_info.h:124
int test(const HARD_REG_SET &regs, int regno) const
Definition gimplify_reg_info.h:46
gimplify_reg_info(unsigned num_alternatives, unsigned num_outputs)
Definition gimplify_reg_info.h:64
bool is_clobbered(int regno) const
Definition gimplify_reg_info.h:177
int test_reg_asm_input(int regno) const
Definition gimplify_reg_info.h:141
int test_alt_output(unsigned alt, int regno) const
Definition gimplify_reg_info.h:112
HARD_REG_SET m_reg_asm_output
Definition gimplify_reg_info.h:30
~gimplify_reg_info()
Definition gimplify_reg_info.h:92
const unsigned m_num_outputs
Definition gimplify_reg_info.h:33
void set_output(unsigned alt, int regno)
Definition gimplify_reg_info.h:98
HARD_REG_SET * m_alt_input
Definition gimplify_reg_info.h:27
HARD_REG_SET * m_alt_output
Definition gimplify_reg_info.h:26
HARD_REG_SET * m_early_clobbered_alt
Definition gimplify_reg_info.h:28
bool is_early_clobbered_in_any_output_unequal(unsigned operand, int regno) const
Definition gimplify_reg_info.h:161
int test_alt_input(unsigned alt, int regno) const
Definition gimplify_reg_info.h:118
void set_input(unsigned alt, int regno)
Definition gimplify_reg_info.h:105
HARD_REG_SET m_reg_asm_input
Definition gimplify_reg_info.h:31
bool test_early_clobbered_alt(unsigned alt, int regno) const
Definition gimplify_reg_info.h:155
HARD_REG_SET m_clobbered
Definition gimplify_reg_info.h:43
void set_clobbered(int regno)
Definition gimplify_reg_info.h:172
void set_early_clobbered(unsigned alt, unsigned output, int regno)
Definition gimplify_reg_info.h:146
void set_reg_asm_input(int regno)
Definition gimplify_reg_info.h:135
union tree_node * tree
Definition coretypes.h:97
static int num_alternatives(const_tree link)
Definition gimplify.cc:7846
#define TEST_HARD_REG_BIT(SET, BIT)
Definition hard-reg-set.h:170
HARD_REG_ELT_TYPE HARD_REG_SET
Definition hard-reg-set.h:47
#define CLEAR_HARD_REG_SET(TO)
Definition hard-reg-set.h:173
#define SET_HARD_REG_BIT(SET, BIT)
Definition hard-reg-set.h:166
i
Definition poly-int.h:776
bool overlaps_hard_reg_set_p(const_hard_reg_set regs, machine_mode mode, unsigned int regno)
Definition regs.h:332
void add_to_hard_reg_set(HARD_REG_SET *regs, machine_mode mode, unsigned int regno)
Definition regs.h:279
unsigned int end_hard_regno(machine_mode mode, unsigned int regno)
Definition regs.h:270
#define gcc_checking_assert(EXPR)
Definition system.h:821
#define TYPE_MODE(NODE)
Definition tree.h:2356
#define TREE_TYPE(NODE)
Definition tree.h:513