[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: llvmcommits
Differential Revision: https://reviews.llvm.org/D39165
gitsvnid: https://llvm.org/svn/llvmproject/llvm/trunk@316429 911773080d340410b5e696231b3b80d8
Bjorn Pettersson
1 year, 9 months ago
3161  3161  The following is the syntax for constant expressions: 
3162  3162  
3163  3163  ``trunc (CST to TYPE)`` 
3164  Truncate a constant to another type. The bit size of CST must be  
3165 


3164 
Perform the :ref:`trunc operation 

3166  3165  ``zext (CST to TYPE)`` 
3167  Zero extend a constant to another type. The bit size of CST must be  
3168 


3166 
Perform the :ref:`zext operation 

3169  3167  ``sext (CST to TYPE)`` 
3170  Sign extend a constant to another type. The bit size of CST must be  
3171 


3168 
Perform the :ref:`sext operation 

3172  3169  ``fptrunc (CST to TYPE)`` 
3173  3170  Truncate a floating point constant to another floating point type. 
3174  3171  The size of CST must be larger than the size of TYPE. Both types 
3202  3199  be scalars, or vectors of the same number of elements. If the value 
3203  3200  won't fit in the floating point type, the results are undefined. 
3204  3201  ``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 


3202 
Perform the :ref:`ptrtoint operation 

3209  3203  ``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 


3204 
Perform the :ref:`inttoptr operation 

3213  3205  This one is *really* dangerous! 
3214  3206  ``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 


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 

3218  3210  ``addrspacecast (CST to TYPE)`` 
3219  3211  Convert a constant pointer or constant vector of pointer, CST, to another 
3220  3212  TYPE in a different address space. The constraints of the operands are the 
3227  3219  ``select (COND, VAL1, VAL2)`` 
3228  3220 
Perform the :ref:`select operation 
3229  3221  ``icmp COND (VAL1, VAL2)`` 
3230 
Perform 

3222 
Perform the :ref:`icmp operation 

3231  3223  ``fcmp COND (VAL1, VAL2)`` 
3232 
Perform 

3224 
Perform the :ref:`fcmp operation 

3233  3225  ``extractelement (VAL, IDX)`` 
3234  3226 
Perform the :ref:`extractelement operation 
3235  3227  constants. 
8075  8067  (casting) which all take a single operand and a type. They perform 
8076  8068  various bit conversions on the operand. 
8077  8069  
8070  .. _i_trunc:  
8071  
8078  8072  '``trunc .. to``' Instruction 
8079  8073  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
8080  8074  
8117  8111  %Z = trunc i32 122 to i1 ; yields i1:false 
8118  8112 
%W = trunc <2 x i16> 
8119  8113  
8114  .. _i_zext:  
8115  
8120  8116  '``zext .. to``' Instruction 
8121  8117  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
8122  8118  
8156  8152  %X = zext i32 257 to i64 ; yields i64:257 
8157  8153  %Y = zext i1 true to i32 ; yields i32:1 
8158  8154 
%Z = zext <2 x i16> 
8155  
8156  .. _i_sext:  
8159  8157  
8160  8158  '``sext .. to``' Instruction 
8161  8159  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 