]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: RTL classes, classes of RTX codes, RTX codes, classes of, GET_RTX_CLASS | |
7 | ||
8 | .. _rtl-classes: | |
9 | ||
10 | RTL Classes and Formats | |
11 | *********************** | |
12 | ||
13 | The various expression codes are divided into several :dfn:`classes`, | |
14 | which are represented by single characters. You can determine the class | |
15 | of an RTX code with the macro ``GET_RTX_CLASS (code)``. | |
16 | Currently, :samp:`rtl.def` defines these classes: | |
17 | ||
18 | .. envvar:: RTX_OBJ | |
19 | ||
20 | An RTX code that represents an actual object, such as a register | |
21 | (``REG``) or a memory location (``MEM``, ``SYMBOL_REF``). | |
22 | ``LO_SUM`` is also included; instead, ``SUBREG`` and | |
23 | ``STRICT_LOW_PART`` are not in this class, but in class | |
24 | ``RTX_EXTRA``. | |
25 | ||
26 | .. envvar:: RTX_CONST_OBJ | |
27 | ||
28 | An RTX code that represents a constant object. ``HIGH`` is also | |
29 | included in this class. | |
30 | ||
31 | .. envvar:: RTX_COMPARE | |
32 | ||
33 | An RTX code for a non-symmetric comparison, such as ``GEU`` or | |
34 | ``LT``. | |
35 | ||
36 | .. envvar:: RTX_COMM_COMPARE | |
37 | ||
38 | An RTX code for a symmetric (commutative) comparison, such as ``EQ`` | |
39 | or ``ORDERED``. | |
40 | ||
41 | .. envvar:: RTX_UNARY | |
42 | ||
43 | An RTX code for a unary arithmetic operation, such as ``NEG``, | |
44 | ``NOT``, or ``ABS``. This category also includes value extension | |
45 | (sign or zero) and conversions between integer and floating point. | |
46 | ||
47 | .. envvar:: RTX_COMM_ARITH | |
48 | ||
49 | An RTX code for a commutative binary operation, such as ``PLUS`` or | |
50 | ``AND``. ``NE`` and ``EQ`` are comparisons, so they have class | |
51 | ``RTX_COMM_COMPARE``. | |
52 | ||
53 | .. envvar:: RTX_BIN_ARITH | |
54 | ||
55 | An RTX code for a non-commutative binary operation, such as ``MINUS``, | |
56 | ``DIV``, or ``ASHIFTRT``. | |
57 | ||
58 | .. envvar:: RTX_BITFIELD_OPS | |
59 | ||
60 | An RTX code for a bit-field operation. Currently only | |
61 | ``ZERO_EXTRACT`` and ``SIGN_EXTRACT``. These have three inputs | |
62 | and are lvalues (so they can be used for insertion as well). | |
63 | See :ref:`bit-fields`. | |
64 | ||
65 | .. envvar:: RTX_TERNARY | |
66 | ||
67 | An RTX code for other three input operations. Currently only | |
68 | ``IF_THEN_ELSE``, ``VEC_MERGE``, ``SIGN_EXTRACT``, | |
69 | ``ZERO_EXTRACT``, and ``FMA``. | |
70 | ||
71 | .. envvar:: RTX_INSN | |
72 | ||
73 | An RTX code for an entire instruction: ``INSN``, ``JUMP_INSN``, and | |
74 | ``CALL_INSN``. See :ref:`insns`. | |
75 | ||
76 | .. envvar:: RTX_MATCH | |
77 | ||
78 | An RTX code for something that matches in insns, such as | |
79 | ``MATCH_DUP``. These only occur in machine descriptions. | |
80 | ||
81 | .. envvar:: RTX_AUTOINC | |
82 | ||
83 | An RTX code for an auto-increment addressing mode, such as | |
84 | ``POST_INC``. :samp:`XEXP ({x}, 0)` gives the auto-modified | |
85 | register. | |
86 | ||
87 | .. envvar:: RTX_EXTRA | |
88 | ||
89 | All other RTX codes. This category includes the remaining codes used | |
90 | only in machine descriptions (``DEFINE_*``, etc.). It also includes | |
91 | all the codes describing side effects (``SET``, ``USE``, | |
92 | ``CLOBBER``, etc.) and the non-insns that may appear on an insn | |
93 | chain, such as ``NOTE``, ``BARRIER``, and ``CODE_LABEL``. | |
94 | ``SUBREG`` is also part of this class. | |
95 | ||
96 | .. index:: RTL format | |
97 | ||
98 | For each expression code, :samp:`rtl.def` specifies the number of | |
99 | contained objects and their kinds using a sequence of characters | |
100 | called the :dfn:`format` of the expression code. For example, | |
101 | the format of ``subreg`` is :samp:`ep`. | |
102 | ||
103 | .. index:: RTL format characters | |
104 | ||
105 | These are the most commonly used format characters: | |
106 | ||
107 | ``e`` | |
108 | An expression (actually a pointer to an expression). | |
109 | ||
110 | ``i`` | |
111 | An integer. | |
112 | ||
113 | ``w`` | |
114 | A wide integer. | |
115 | ||
116 | ``s`` | |
117 | A string. | |
118 | ||
119 | ``E`` | |
120 | A vector of expressions. | |
121 | ||
122 | A few other format characters are used occasionally: | |
123 | ||
124 | ``u`` | |
125 | :samp:`u` is equivalent to :samp:`e` except that it is printed differently | |
126 | in debugging dumps. It is used for pointers to insns. | |
127 | ||
128 | ``n`` | |
129 | :samp:`n` is equivalent to :samp:`i` except that it is printed differently | |
130 | in debugging dumps. It is used for the line number or code number of a | |
131 | ``note`` insn. | |
132 | ||
133 | ``S`` | |
134 | :samp:`S` indicates a string which is optional. In the RTL objects in | |
135 | core, :samp:`S` is equivalent to :samp:`s`, but when the object is read, | |
136 | from an :samp:`md` file, the string value of this operand may be omitted. | |
137 | An omitted string is taken to be the null string. | |
138 | ||
139 | ``V`` | |
140 | :samp:`V` indicates a vector which is optional. In the RTL objects in | |
141 | core, :samp:`V` is equivalent to :samp:`E`, but when the object is read | |
142 | from an :samp:`md` file, the vector value of this operand may be omitted. | |
143 | An omitted vector is effectively the same as a vector of no elements. | |
144 | ||
145 | ``B`` | |
146 | :samp:`B` indicates a pointer to basic block structure. | |
147 | ||
148 | ``p`` | |
149 | A polynomial integer. At present this is used only for ``SUBREG_BYTE``. | |
150 | ||
151 | ``0`` | |
152 | :samp:`0` means a slot whose contents do not fit any normal category. | |
153 | :samp:`0` slots are not printed at all in dumps, and are often used in | |
154 | special ways by small parts of the compiler. | |
155 | ||
156 | There are macros to get the number of operands and the format | |
157 | of an expression code: | |
158 | ||
159 | .. index:: GET_RTX_LENGTH | |
160 | ||
161 | :samp:`GET_RTX_LENGTH ({code})` | |
162 | Number of operands of an RTX of code :samp:`{code}`. | |
163 | ||
164 | .. index:: GET_RTX_FORMAT | |
165 | ||
166 | :samp:`GET_RTX_FORMAT ({code})` | |
167 | The format of an RTX of code :samp:`{code}`, as a C string. | |
168 | ||
169 | Some classes of RTX codes always have the same format. For example, it | |
170 | is safe to assume that all comparison operations have format ``ee``. | |
171 | ||
172 | .. envvar:: RTX_UNARY | |
173 | ||
174 | All codes of this class have format ``e``. | |
175 | ||
176 | .. envvar:: RTX_BIN_ARITH | |
177 | ||
178 | All codes of these classes have format ``ee``. | |
179 | ||
180 | .. envvar:: RTX_BITFIELD_OPS | |
181 | ||
182 | All codes of these classes have format ``eee``. | |
183 | ||
184 | .. envvar:: RTX_INSN | |
185 | ||
186 | All codes of this class have formats that begin with ``iuueiee``. | |
187 | See :ref:`insns`. Note that not all RTL objects linked onto an insn chain | |
188 | are of class ``RTX_INSN``. | |
189 | ||
190 | .. envvar:: RTX_CONST_OBJ | |
191 | ||
3ed1b4ce | 192 | You can make no assumptions about the format of these codes. |