summaryrefslogtreecommitdiffstats
path: root/llvm/docs/LangRef.rst
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/docs/LangRef.rst')
-rw-r--r--llvm/docs/LangRef.rst45
1 files changed, 23 insertions, 22 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index cc815e1a4e9..bbdd9b2e8c3 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -162,7 +162,7 @@ symbol table entries. Here is an example of the "hello world" module:
; Definition of main function
define i32 @main() { ; i32()*
; Convert [13 x i8]* to i8 *...
- %cast210 = getelementptr [13 x i8]* @.str, i64 0, i64 0
+ %cast210 = getelementptr [13 x i8], [13 x i8]* @.str, i64 0, i64 0
; Call puts function to write out the string to stdout.
call i32 @puts(i8* %cast210)
@@ -1057,8 +1057,8 @@ The prefix data can be referenced as,
.. code-block:: llvm
- %0 = bitcast *void () @f to *i32
- %a = getelementptr inbounds *i32 %0, i32 -1
+ %0 = bitcast void* () @f to i32*
+ %a = getelementptr inbounds i32, i32* %0, i32 -1
%b = load i32* %a
Prefix data is laid out as if it were an initializer for a global variable
@@ -1584,7 +1584,7 @@ A pointer value is *based* on another pointer value according to the
following rules:
- A pointer value formed from a ``getelementptr`` operation is *based*
- on the first operand of the ``getelementptr``.
+ on the first value operand of the ``getelementptr``.
- The result value of a ``bitcast`` is *based* on the operand of the
``bitcast``.
- A pointer value formed by an ``inttoptr`` is *based* on all pointer
@@ -2567,7 +2567,7 @@ Here are some examples:
entry:
%poison = sub nuw i32 0, 1 ; Results in a poison value.
%still_poison = and i32 %poison, 0 ; 0, but also poison.
- %poison_yet_again = getelementptr i32* @h, i32 %still_poison
+ %poison_yet_again = getelementptr i32, i32* @h, i32 %still_poison
store i32 0, i32* %poison_yet_again ; memory at @h[0] is poisoned
store i32 %poison, i32* @g ; Poison value stored to memory.
@@ -5930,9 +5930,9 @@ Syntax:
::
- <result> = getelementptr <pty>* <ptrval>{, <ty> <idx>}*
- <result> = getelementptr inbounds <pty>* <ptrval>{, <ty> <idx>}*
- <result> = getelementptr <ptr vector> ptrval, <vector index type> idx
+ <result> = getelementptr <ty>, <ty>* <ptrval>{, <ty> <idx>}*
+ <result> = getelementptr inbounds <ty>, <ty>* <ptrval>{, <ty> <idx>}*
+ <result> = getelementptr <ty>, <ptr vector> <ptrval>, <vector index type> <idx>
Overview:
"""""""""
@@ -5944,8 +5944,9 @@ address calculation only and does not access memory.
Arguments:
""""""""""
-The first argument is always a pointer or a vector of pointers, and
-forms the basis of the calculation. The remaining arguments are indices
+The first argument is always a type used as the basis for the calculations.
+The second argument is always a pointer or a vector of pointers, and is the
+base address to start from. The remaining arguments are indices
that indicate which of the elements of the aggregate object are indexed.
The interpretation of each index is dependent on the type being indexed
into. The first index always indexes the pointer value given as the
@@ -5993,7 +5994,7 @@ The LLVM code generated by Clang is:
define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
entry:
- %arrayidx = getelementptr inbounds %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
+ %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
ret i32* %arrayidx
}
@@ -6018,11 +6019,11 @@ for the given testcase is equivalent to:
.. code-block:: llvm
define i32* @foo(%struct.ST* %s) {
- %t1 = getelementptr %struct.ST* %s, i32 1 ; yields %struct.ST*:%t1
- %t2 = getelementptr %struct.ST* %t1, i32 0, i32 2 ; yields %struct.RT*:%t2
- %t3 = getelementptr %struct.RT* %t2, i32 0, i32 1 ; yields [10 x [20 x i32]]*:%t3
- %t4 = getelementptr [10 x [20 x i32]]* %t3, i32 0, i32 5 ; yields [20 x i32]*:%t4
- %t5 = getelementptr [20 x i32]* %t4, i32 0, i32 13 ; yields i32*:%t5
+ %t1 = getelementptr %struct.ST, %struct.ST* %s, i32 1 ; yields %struct.ST*:%t1
+ %t2 = getelementptr %struct.ST, %struct.ST* %t1, i32 0, i32 2 ; yields %struct.RT*:%t2
+ %t3 = getelementptr %struct.RT, %struct.RT* %t2, i32 0, i32 1 ; yields [10 x [20 x i32]]*:%t3
+ %t4 = getelementptr [10 x [20 x i32]], [10 x [20 x i32]]* %t3, i32 0, i32 5 ; yields [20 x i32]*:%t4
+ %t5 = getelementptr [20 x i32], [20 x i32]* %t4, i32 0, i32 13 ; yields i32*:%t5
ret i32* %t5
}
@@ -6056,20 +6057,20 @@ Example:
.. code-block:: llvm
; yields [12 x i8]*:aptr
- %aptr = getelementptr {i32, [12 x i8]}* %saptr, i64 0, i32 1
+ %aptr = getelementptr {i32, [12 x i8]}, {i32, [12 x i8]}* %saptr, i64 0, i32 1
; yields i8*:vptr
- %vptr = getelementptr {i32, <2 x i8>}* %svptr, i64 0, i32 1, i32 1
+ %vptr = getelementptr {i32, <2 x i8>}, {i32, <2 x i8>}* %svptr, i64 0, i32 1, i32 1
; yields i8*:eptr
- %eptr = getelementptr [12 x i8]* %aptr, i64 0, i32 1
+ %eptr = getelementptr [12 x i8], [12 x i8]* %aptr, i64 0, i32 1
; yields i32*:iptr
- %iptr = getelementptr [10 x i32]* @arr, i16 0, i16 0
+ %iptr = getelementptr [10 x i32], [10 x i32]* @arr, i16 0, i16 0
In cases where the pointer argument is a vector of pointers, each index
must be a vector with the same number of elements. For example:
.. code-block:: llvm
- %A = getelementptr <4 x i8*> %ptrs, <4 x i64> %offsets,
+ %A = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets,
Conversion Operations
---------------------
@@ -9546,7 +9547,7 @@ It can be created as follows:
.. code-block:: llvm
%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
- %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
+ %tramp1 = getelementptr [10 x i8], [10 x i8]* %tramp, i32 0, i32 0
call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8*, i32, i32)* @f to i8*), i8* %nval)
%p = call i8* @llvm.adjust.trampoline(i8* %tramp1)
%fp = bitcast i8* %p to i32 (i32, i32)*
OpenPOWER on IntegriCloud