summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2017-10-24 11:59:20 +0000
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2017-10-24 11:59:20 +0000
commit7b97ca1b57a2b7f2eb1e82f76328dfe240c2bf22 (patch)
tree041c9d6268663519a9da9cb490991f7e4e20aa93 /docs
parent2e2ff0a1e633bb4434e966b8ca9f3eda5c935743 (diff)
[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
Diffstat (limited to 'docs')
-rw-r--r--docs/LangRef.rst34
1 files changed, 16 insertions, 18 deletions
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index b88c7727f05..99a2ffa40d6 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -3162,14 +3162,11 @@ that does not have side effects (e.g. load and call are not supported).
The following is the syntax for constant expressions:
``trunc (CST to TYPE)``
- Truncate a constant to another type. The bit size of CST must be
- larger than the bit size of TYPE. Both types must be integers.
+ Perform the :ref:`trunc operation <i_trunc>` on constants.
``zext (CST to TYPE)``
- Zero extend a constant to another type. The bit size of CST must be
- smaller than the bit size of TYPE. Both types must be integers.
+ Perform the :ref:`zext operation <i_zext>` on constants.
``sext (CST to TYPE)``
- Sign extend a constant to another type. The bit size of CST must be
- smaller than the bit size of TYPE. Both types must be integers.
+ Perform the :ref:`sext operation <i_sext>` on constants.
``fptrunc (CST to TYPE)``
Truncate a floating point constant to another floating point type.
The size of CST must be larger than the size of TYPE. Both types
@@ -3203,19 +3200,14 @@ The following is the syntax for constant expressions:
be scalars, or vectors of the same number of elements. If the value
won't fit in the floating point type, the results are undefined.
``ptrtoint (CST to TYPE)``
- Convert a pointer typed constant to the corresponding integer
- constant. ``TYPE`` must be an integer type. ``CST`` must be of
- pointer type. The ``CST`` value is zero extended, truncated, or
- unchanged to make it fit in ``TYPE``.
+ Perform the :ref:`ptrtoint operation <i_ptrtoint>` on constants.
``inttoptr (CST to TYPE)``
- Convert an integer constant to a pointer constant. TYPE must be a
- pointer type. CST must be of integer type. The CST value is zero
- extended, truncated, or unchanged to make it fit in a pointer size.
+ Perform the :ref:`inttoptr operation <i_inttoptr>` on constants.
This one is *really* dangerous!
``bitcast (CST to TYPE)``
- Convert a constant, CST, to another TYPE. The constraints of the
- operands are the same as those for the :ref:`bitcast
- instruction <i_bitcast>`.
+ Convert a constant, CST, to another TYPE.
+ The constraints of the operands are the same as those for the
+ :ref:`bitcast instruction <i_bitcast>`.
``addrspacecast (CST to TYPE)``
Convert a constant pointer or constant vector of pointer, CST, to another
TYPE in a different address space. The constraints of the operands are the
@@ -3228,9 +3220,9 @@ The following is the syntax for constant expressions:
``select (COND, VAL1, VAL2)``
Perform the :ref:`select operation <i_select>` on constants.
``icmp COND (VAL1, VAL2)``
- Performs the :ref:`icmp operation <i_icmp>` on constants.
+ Perform the :ref:`icmp operation <i_icmp>` on constants.
``fcmp COND (VAL1, VAL2)``
- Performs the :ref:`fcmp operation <i_fcmp>` on constants.
+ Perform the :ref:`fcmp operation <i_fcmp>` on constants.
``extractelement (VAL, IDX)``
Perform the :ref:`extractelement operation <i_extractelement>` on
constants.
@@ -8076,6 +8068,8 @@ The instructions in this category are the conversion instructions
(casting) which all take a single operand and a type. They perform
various bit conversions on the operand.
+.. _i_trunc:
+
'``trunc .. to``' Instruction
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8118,6 +8112,8 @@ Example:
%Z = trunc i32 122 to i1 ; yields i1:false
%W = trunc <2 x i16> <i16 8, i16 7> to <2 x i8> ; yields <i8 8, i8 7>
+.. _i_zext:
+
'``zext .. to``' Instruction
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8158,6 +8154,8 @@ Example:
%Y = zext i1 true to i32 ; yields i32:1
%Z = zext <2 x i16> <i16 8, i16 7> to <2 x i32> ; yields <i32 8, i32 7>
+.. _i_sext:
+
'``sext .. to``' Instruction
^^^^^^^^^^^^^^^^^^^^^^^^^^^^