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.
6 .. index:: RTL classes, classes of RTX codes, RTX codes, classes of, GET_RTX_CLASS
10 RTL Classes and Formats
11 ***********************
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:
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
26 .. envvar:: RTX_CONST_OBJ
28 An RTX code that represents a constant object. ``HIGH`` is also
29 included in this class.
31 .. envvar:: RTX_COMPARE
33 An RTX code for a non-symmetric comparison, such as ``GEU`` or
36 .. envvar:: RTX_COMM_COMPARE
38 An RTX code for a symmetric (commutative) comparison, such as ``EQ``
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.
47 .. envvar:: RTX_COMM_ARITH
49 An RTX code for a commutative binary operation, such as ``PLUS`` or
50 ``AND``. ``NE`` and ``EQ`` are comparisons, so they have class
53 .. envvar:: RTX_BIN_ARITH
55 An RTX code for a non-commutative binary operation, such as ``MINUS``,
56 ``DIV``, or ``ASHIFTRT``.
58 .. envvar:: RTX_BITFIELD_OPS
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`.
65 .. envvar:: RTX_TERNARY
67 An RTX code for other three input operations. Currently only
68 ``IF_THEN_ELSE``, ``VEC_MERGE``, ``SIGN_EXTRACT``,
69 ``ZERO_EXTRACT``, and ``FMA``.
73 An RTX code for an entire instruction: ``INSN``, ``JUMP_INSN``, and
74 ``CALL_INSN``. See :ref:`insns`.
78 An RTX code for something that matches in insns, such as
79 ``MATCH_DUP``. These only occur in machine descriptions.
81 .. envvar:: RTX_AUTOINC
83 An RTX code for an auto-increment addressing mode, such as
84 ``POST_INC``. :samp:`XEXP ({x}, 0)` gives the auto-modified
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.
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`.
103 .. index:: RTL format characters
105 These are the most commonly used format characters:
108 An expression (actually a pointer to an expression).
120 A vector of expressions.
122 A few other format characters are used occasionally:
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.
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
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.
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.
146 :samp:`B` indicates a pointer to basic block structure.
149 A polynomial integer. At present this is used only for ``SUBREG_BYTE``.
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.
156 There are macros to get the number of operands and the format
157 of an expression code:
159 .. index:: GET_RTX_LENGTH
161 :samp:`GET_RTX_LENGTH ({code})`
162 Number of operands of an RTX of code :samp:`{code}`.
164 .. index:: GET_RTX_FORMAT
166 :samp:`GET_RTX_FORMAT ({code})`
167 The format of an RTX of code :samp:`{code}`, as a C string.
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``.
172 .. envvar:: RTX_UNARY
174 All codes of this class have format ``e``.
176 .. envvar:: RTX_BIN_ARITH
178 All codes of these classes have format ``ee``.
180 .. envvar:: RTX_BITFIELD_OPS
182 All codes of these classes have format ``eee``.
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``.
190 .. envvar:: RTX_CONST_OBJ
192 You can make no assumptions about the format of these codes.