llvm.org GIT mirror llvm / 7b97ca1
[LangRef] Update description of Constant Expressions Summary: When describing trunc/zext/sext/ptrtoint/inttoptr in the chapter about Constant Expressions we now simply refer to the Instruction Reference. As far as I know there are no difference when it comes to the semantics and the argument constraints. The only difference is that the syntax is slighly different for the constant expressions, regarding the use of parenthesis in constant expressions. Referring to the Instruction Reference is the same solution as already used for several other operations, such as bitcast. The main goal was to add information that vector types are allowed also in trunc/zext/sext/ptrtoint/inttoptr constant expressions. That was not explicitly mentioned earlier, and resulted in some questions in the review of https://reviews.llvm.org/D38546 Reviewers: efriedma, majnemer Reviewed By: efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39165 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316429 91177308-0d34-0410-b5e6-96231b3b80d8 Bjorn Pettersson 1 year, 9 months ago
1 changed file(s) with 16 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
31613161 The following is the syntax for constant expressions:
31623162
31633163 ``trunc (CST to TYPE)``
3164 Truncate a constant to another type. The bit size of CST must be
3165 larger than the bit size of TYPE. Both types must be integers.
3164 Perform the :ref:`trunc operation ` on constants.
31663165 ``zext (CST to TYPE)``
3167 Zero extend a constant to another type. The bit size of CST must be
3168 smaller than the bit size of TYPE. Both types must be integers.
3166 Perform the :ref:`zext operation ` on constants.
31693167 ``sext (CST to TYPE)``
3170 Sign extend a constant to another type. The bit size of CST must be
3171 smaller than the bit size of TYPE. Both types must be integers.
3168 Perform the :ref:`sext operation ` on constants.
31723169 ``fptrunc (CST to TYPE)``
31733170 Truncate a floating point constant to another floating point type.
31743171 The size of CST must be larger than the size of TYPE. Both types
32023199 be scalars, or vectors of the same number of elements. If the value
32033200 won't fit in the floating point type, the results are undefined.
32043201 ``ptrtoint (CST to TYPE)``
3205 Convert a pointer typed constant to the corresponding integer
3206 constant. ``TYPE`` must be an integer type. ``CST`` must be of
3207 pointer type. The ``CST`` value is zero extended, truncated, or
3208 unchanged to make it fit in ``TYPE``.
3202 Perform the :ref:`ptrtoint operation ` on constants.
32093203 ``inttoptr (CST to TYPE)``
3210 Convert an integer constant to a pointer constant. TYPE must be a
3211 pointer type. CST must be of integer type. The CST value is zero
3212 extended, truncated, or unchanged to make it fit in a pointer size.
3204 Perform the :ref:`inttoptr operation ` on constants.
32133205 This one is *really* dangerous!
32143206 ``bitcast (CST to TYPE)``
3215 Convert a constant, CST, to another TYPE. The constraints of the
3216 operands are the same as those for the :ref:`bitcast
3217 instruction `.
3207 Convert a constant, CST, to another TYPE.
3208 The constraints of the operands are the same as those for the
3209 :ref:`bitcast instruction `.
32183210 ``addrspacecast (CST to TYPE)``
32193211 Convert a constant pointer or constant vector of pointer, CST, to another
32203212 TYPE in a different address space. The constraints of the operands are the
32273219 ``select (COND, VAL1, VAL2)``
32283220 Perform the :ref:`select operation ` on constants.
32293221 ``icmp COND (VAL1, VAL2)``
3230 Performs the :ref:`icmp operation ` on constants.
3222 Perform the :ref:`icmp operation ` on constants.
32313223 ``fcmp COND (VAL1, VAL2)``
3232 Performs the :ref:`fcmp operation ` on constants.
3224 Perform the :ref:`fcmp operation ` on constants.
32333225 ``extractelement (VAL, IDX)``
32343226 Perform the :ref:`extractelement operation ` on
32353227 constants.
80758067 (casting) which all take a single operand and a type. They perform
80768068 various bit conversions on the operand.
80778069
8070 .. _i_trunc:
8071
80788072 '``trunc .. to``' Instruction
80798073 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80808074
81178111 %Z = trunc i32 122 to i1 ; yields i1:false
81188112 %W = trunc <2 x i16> to <2 x i8> ; yields
81198113
8114 .. _i_zext:
8115
81208116 '``zext .. to``' Instruction
81218117 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
81228118
81568152 %X = zext i32 257 to i64 ; yields i64:257
81578153 %Y = zext i1 true to i32 ; yields i32:1
81588154 %Z = zext <2 x i16> to <2 x i32> ; yields
8155
8156 .. _i_sext:
81598157
81608158 '``sext .. to``' Instruction
81618159 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^