@@ -162,7 +162,7 @@ symbol table entries. Here is an example of the "hello world" module:
162
162
; Definition of main function
163
163
define i32 @main() { ; i32()*
164
164
; Convert [13 x i8]* to i8 *...
165
- %cast210 = getelementptr [13 x i8]* @.str, i64 0, i64 0
165
+ %cast210 = getelementptr [13 x i8], [13 x i8] * @.str, i64 0, i64 0
166
166
167
167
; Call puts function to write out the string to stdout.
168
168
call i32 @puts(i8* %cast210)
@@ -1057,8 +1057,8 @@ The prefix data can be referenced as,
1057
1057
1058
1058
.. code-block :: llvm
1059
1059
1060
- %0 = bitcast * void () @f to * i32
1061
- %a = getelementptr inbounds * i32 %0, i32 -1
1060
+ %0 = bitcast void* () @f to i32*
1061
+ %a = getelementptr inbounds i32, i32* %0, i32 -1
1062
1062
%b = load i32* %a
1063
1063
1064
1064
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
1584
1584
following rules:
1585
1585
1586
1586
- A pointer value formed from a ``getelementptr `` operation is *based *
1587
- on the first operand of the ``getelementptr ``.
1587
+ on the first value operand of the ``getelementptr ``.
1588
1588
- The result value of a ``bitcast `` is *based * on the operand of the
1589
1589
``bitcast ``.
1590
1590
- A pointer value formed by an ``inttoptr `` is *based * on all pointer
@@ -2567,7 +2567,7 @@ Here are some examples:
2567
2567
entry:
2568
2568
%poison = sub nuw i32 0, 1 ; Results in a poison value.
2569
2569
%still_poison = and i32 %poison, 0 ; 0, but also poison.
2570
- %poison_yet_again = getelementptr i32* @h, i32 %still_poison
2570
+ %poison_yet_again = getelementptr i32, i32 * @h, i32 %still_poison
2571
2571
store i32 0, i32* %poison_yet_again ; memory at @h[0] is poisoned
2572
2572
2573
2573
store i32 %poison, i32* @g ; Poison value stored to memory.
@@ -5930,9 +5930,9 @@ Syntax:
5930
5930
5931
5931
::
5932
5932
5933
- <result> = getelementptr <pty >* <ptrval>{, <ty> <idx>}*
5934
- <result> = getelementptr inbounds <pty >* <ptrval>{, <ty> <idx>}*
5935
- <result> = getelementptr <ptr vector> ptrval, <vector index type> idx
5933
+ <result> = getelementptr <ty>, <ty >* <ptrval>{, <ty> <idx>}*
5934
+ <result> = getelementptr inbounds <ty>, <ty >* <ptrval>{, <ty> <idx>}*
5935
+ <result> = getelementptr <ty>, < ptr vector> < ptrval> , <vector index type> < idx>
5936
5936
5937
5937
Overview:
5938
5938
"""""""""
@@ -5944,8 +5944,9 @@ address calculation only and does not access memory.
5944
5944
Arguments:
5945
5945
""""""""""
5946
5946
5947
- The first argument is always a pointer or a vector of pointers, and
5948
- forms the basis of the calculation. The remaining arguments are indices
5947
+ The first argument is always a type used as the basis for the calculations.
5948
+ The second argument is always a pointer or a vector of pointers, and is the
5949
+ base address to start from. The remaining arguments are indices
5949
5950
that indicate which of the elements of the aggregate object are indexed.
5950
5951
The interpretation of each index is dependent on the type being indexed
5951
5952
into. The first index always indexes the pointer value given as the
@@ -5993,7 +5994,7 @@ The LLVM code generated by Clang is:
5993
5994
5994
5995
define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
5995
5996
entry:
5996
- %arrayidx = getelementptr inbounds %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
5997
+ %arrayidx = getelementptr inbounds %struct.ST, %struct.ST * %s, i64 1, i32 2, i32 1, i64 5, i64 13
5997
5998
ret i32* %arrayidx
5998
5999
}
5999
6000
@@ -6018,11 +6019,11 @@ for the given testcase is equivalent to:
6018
6019
.. code-block :: llvm
6019
6020
6020
6021
define i32* @foo(%struct.ST* %s) {
6021
- %t1 = getelementptr %struct.ST* %s, i32 1 ; yields %struct.ST*:%t1
6022
- %t2 = getelementptr %struct.ST* %t1, i32 0, i32 2 ; yields %struct.RT*:%t2
6023
- %t3 = getelementptr %struct.RT* %t2, i32 0, i32 1 ; yields [10 x [20 x i32]]*:%t3
6024
- %t4 = getelementptr [10 x [20 x i32]]* %t3, i32 0, i32 5 ; yields [20 x i32]*:%t4
6025
- %t5 = getelementptr [20 x i32]* %t4, i32 0, i32 13 ; yields i32*:%t5
6022
+ %t1 = getelementptr %struct.ST, %struct.ST * %s, i32 1 ; yields %struct.ST*:%t1
6023
+ %t2 = getelementptr %struct.ST, %struct.ST * %t1, i32 0, i32 2 ; yields %struct.RT*:%t2
6024
+ %t3 = getelementptr %struct.RT, %struct.RT * %t2, i32 0, i32 1 ; yields [10 x [20 x i32]]*:%t3
6025
+ %t4 = getelementptr [10 x [20 x i32]], [10 x [20 x i32]] * %t3, i32 0, i32 5 ; yields [20 x i32]*:%t4
6026
+ %t5 = getelementptr [20 x i32], [20 x i32] * %t4, i32 0, i32 13 ; yields i32*:%t5
6026
6027
ret i32* %t5
6027
6028
}
6028
6029
@@ -6056,20 +6057,20 @@ Example:
6056
6057
.. code-block :: llvm
6057
6058
6058
6059
; yields [12 x i8]*:aptr
6059
- %aptr = getelementptr {i32, [12 x i8]}* %saptr, i64 0, i32 1
6060
+ %aptr = getelementptr {i32, [12 x i8]}, {i32, [12 x i8]} * %saptr, i64 0, i32 1
6060
6061
; yields i8*:vptr
6061
- %vptr = getelementptr {i32, <2 x i8>}* %svptr, i64 0, i32 1, i32 1
6062
+ %vptr = getelementptr {i32, <2 x i8>}, {i32, <2 x i8>} * %svptr, i64 0, i32 1, i32 1
6062
6063
; yields i8*:eptr
6063
- %eptr = getelementptr [12 x i8]* %aptr, i64 0, i32 1
6064
+ %eptr = getelementptr [12 x i8], [12 x i8] * %aptr, i64 0, i32 1
6064
6065
; yields i32*:iptr
6065
- %iptr = getelementptr [10 x i32]* @arr, i16 0, i16 0
6066
+ %iptr = getelementptr [10 x i32], [10 x i32] * @arr, i16 0, i16 0
6066
6067
6067
6068
In cases where the pointer argument is a vector of pointers, each index
6068
6069
must be a vector with the same number of elements. For example:
6069
6070
6070
6071
.. code-block :: llvm
6071
6072
6072
- %A = getelementptr <4 x i8*> %ptrs, <4 x i64> %offsets,
6073
+ %A = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets,
6073
6074
6074
6075
Conversion Operations
6075
6076
---------------------
@@ -9546,7 +9547,7 @@ It can be created as follows:
9546
9547
.. code-block :: llvm
9547
9548
9548
9549
%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
9549
- %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
9550
+ %tramp1 = getelementptr [10 x i8], [10 x i8] * %tramp, i32 0, i32 0
9550
9551
call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8*, i32, i32)* @f to i8*), i8* %nval)
9551
9552
%p = call i8* @llvm.adjust.trampoline(i8* %tramp1)
9552
9553
%fp = bitcast i8* %p to i32 (i32, i32)*
0 commit comments