@@ -10,8 +10,8 @@ Introduction
10
10
11
11
This document seeks to dispel the mystery and confusion surrounding LLVM's
12
12
`GetElementPtr <LangRef.html#getelementptr-instruction >`_ (GEP) instruction.
13
- Questions about the wily GEP instruction are probably the most frequently
14
- occurring questions once a developer gets down to coding with LLVM. Here we lay
13
+ Questions about the wily GEP instruction are probably the most frequent
14
+ questions once a developer gets down to coding with LLVM. Here we lay
15
15
out the sources of confusion and show that the GEP instruction is really quite
16
16
simple.
17
17
@@ -30,8 +30,8 @@ What is the first index of the GEP instruction?
30
30
Quick answer: The index stepping through the second operand.
31
31
32
32
The confusion with the first index usually arises from thinking about the
33
- GetElementPtr instruction as if it was a C index operator. They aren't the
34
- same. For example, when we write, in "C" :
33
+ GetElementPtr instruction as if it were a C index operator. They aren't the
34
+ same. For example, when we write, in C :
35
35
36
36
.. code-block :: c++
37
37
@@ -62,7 +62,7 @@ The answer is simply because memory does not have to be accessed to perform the
62
62
computation. The second operand to the GEP instruction must be a value of a
63
63
pointer type. The value of the pointer is provided directly to the GEP
64
64
instruction as an operand without any need for accessing memory. It must,
65
- therefore be indexed and requires an index operand. Consider this example:
65
+ therefore, be indexed and requires an index operand. Consider this example:
66
66
67
67
.. code-block :: c++
68
68
@@ -285,7 +285,7 @@ I'm writing a backend for a target which needs custom lowering for GEP. How do I
285
285
-----------------------------------------------------------------------------------------
286
286
287
287
You don't. The integer computation implied by a GEP is target-independent.
288
- Typically what you'll need to do is make your backend pattern-match expressions
288
+ Typically what you'll need to do is make your backend pattern-match expression
289
289
trees involving ADD, MUL, etc., which are what GEP is lowered into. This has the
290
290
advantage of letting your code work correctly in more cases.
291
291
@@ -377,7 +377,7 @@ the underlying object.
377
377
378
378
Furthermore, loads and stores don't have to use the same types as the type of
379
379
the underlying object. Types in this context serve only to specify memory size
380
- and alignment. Beyond that there are merely a hint to the optimizer indicating
380
+ and alignment. Beyond that they are merely a hint to the optimizer indicating
381
381
how the value will likely be used.
382
382
383
383
Can I cast an object's address to integer and add it to null?
@@ -506,7 +506,7 @@ sufficient to preserve the pointer aliasing guarantees that GEP provides.
506
506
Summary
507
507
=======
508
508
509
- In summary, here's some things to always remember about the GetElementPtr
509
+ In summary, here are some things to always remember about the GetElementPtr
510
510
instruction:
511
511
512
512
0 commit comments