summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2017-06-19 05:34:21 +0000
committerDavid Blaikie <dblaikie@gmail.com>2017-06-19 05:34:21 +0000
commit4039181fbec25e2827d656aa2c8454b0f981dfe0 (patch)
treee8c407927bdabbf6e541340058144f235a4ec08c /docs
parent47c282c3dffc60b553aa8be6b075651b025311a4 (diff)
[Doc] Fix getelementptr description about arguments
Section "Arguments" of `getelementptr` [1] says the first argument is a type, the second argument is a pointer or a vector of pointers, and is the base address to start from. Update `getelementptr` FAQ [2] accordingly, based on discussion with David on the mailing list [3]. [1] http://llvm.org/docs/LangRef.html#getelementptr-instruction [2] http://llvm.org/docs/GetElementPtr.html [3] http://lists.llvm.org/pipermail/llvm-dev/2017-June/114294.html Patch by Wei-Ren Chen! Differential Revision: https://reviews.llvm.org/D34325 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305662 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/GetElementPtr.rst20
-rw-r--r--docs/LangRef.rst6
2 files changed, 13 insertions, 13 deletions
diff --git a/docs/GetElementPtr.rst b/docs/GetElementPtr.rst
index d13479dabca8..b593871695fa 100644
--- a/docs/GetElementPtr.rst
+++ b/docs/GetElementPtr.rst
@@ -27,7 +27,7 @@ questions.
What is the first index of the GEP instruction?
-----------------------------------------------
-Quick answer: The index stepping through the first operand.
+Quick answer: The index stepping through the second operand.
The confusion with the first index usually arises from thinking about the
GetElementPtr instruction as if it was a C index operator. They aren't the
@@ -59,7 +59,7 @@ Sometimes this question gets rephrased as:
won't be dereferenced?*
The answer is simply because memory does not have to be accessed to perform the
-computation. The first operand to the GEP instruction must be a value of a
+computation. The second operand to the GEP instruction must be a value of a
pointer type. The value of the pointer is provided directly to the GEP
instruction as an operand without any need for accessing memory. It must,
therefore be indexed and requires an index operand. Consider this example:
@@ -80,8 +80,8 @@ therefore be indexed and requires an index operand. Consider this example:
In this "C" example, the front end compiler (Clang) will generate three GEP
instructions for the three indices through "P" in the assignment statement. The
-function argument ``P`` will be the first operand of each of these GEP
-instructions. The second operand indexes through that pointer. The third
+function argument ``P`` will be the second operand of each of these GEP
+instructions. The third operand indexes through that pointer. The fourth
operand will be the field offset into the ``struct munger_struct`` type, for
either the ``f1`` or ``f2`` field. So, in LLVM assembly the ``munge`` function
looks like:
@@ -100,8 +100,8 @@ looks like:
ret void
}
-In each case the first operand is the pointer through which the GEP instruction
-starts. The same is true whether the first operand is an argument, allocated
+In each case the second operand is the pointer through which the GEP instruction
+starts. The same is true whether the second operand is an argument, allocated
memory, or a global variable.
To make this clear, let's consider a more obtuse example:
@@ -159,11 +159,11 @@ confusion:
i32 }*``. That is, ``%MyStruct`` is a pointer to a structure containing a
pointer to a ``float`` and an ``i32``.
-#. Point #1 is evidenced by noticing the type of the first operand of the GEP
+#. Point #1 is evidenced by noticing the type of the second operand of the GEP
instruction (``%MyStruct``) which is ``{ float*, i32 }*``.
#. The first index, ``i64 0`` is required to step over the global variable
- ``%MyStruct``. Since the first argument to the GEP instruction must always
+ ``%MyStruct``. Since the second argument to the GEP instruction must always
be a value of pointer type, the first index steps through that pointer. A
value of 0 means 0 elements offset from that pointer.
@@ -267,7 +267,7 @@ in the IR. In the future, it will probably be outright disallowed.
What effect do address spaces have on GEPs?
-------------------------------------------
-None, except that the address space qualifier on the first operand pointer type
+None, except that the address space qualifier on the second operand pointer type
always matches the address space qualifier on the result type.
How is GEP different from ``ptrtoint``, arithmetic, and ``inttoptr``?
@@ -526,7 +526,7 @@ instruction:
#. The GEP instruction never accesses memory, it only provides pointer
computations.
-#. The first operand to the GEP instruction is always a pointer and it must be
+#. The second operand to the GEP instruction is always a pointer and it must be
indexed.
#. There are no superfluous indices for the GEP instruction.
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index 68aa500150ae..a3d1d9fb12e3 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -1989,7 +1989,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 value operand of the ``getelementptr``.
+ on the second 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
@@ -3166,7 +3166,7 @@ The following is the syntax for constant expressions:
``getelementptr (TY, CSTPTR, IDX0, IDX1, ...)``, ``getelementptr inbounds (TY, CSTPTR, IDX0, IDX1, ...)``
Perform the :ref:`getelementptr operation <i_getelementptr>` on
constants. As with the :ref:`getelementptr <i_getelementptr>`
- instruction, the index list may have zero or more indexes, which are
+ instruction, the index list may have one or more indexes, which are
required to make sense for the type of "pointer to TY".
``select (COND, VAL1, VAL2)``
Perform the :ref:`select operation <i_select>` on constants.
@@ -7805,7 +7805,7 @@ 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
-first argument, the second index indexes a value of the type pointed to
+second argument, the second index indexes a value of the type pointed to
(not necessarily the value directly pointed to, since the first index
can be non-zero), etc. The first type indexed into must be a pointer
value, subsequent types can be arrays, vectors, and structs. Note that