Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
c0ad71ed
Commit
c0ad71ed
authored
19 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
add a note about variable length array
llvm-svn: 22278
parent
9610c6f2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/docs/LangRef.html
+16
-0
16 additions, 0 deletions
llvm/docs/LangRef.html
with
16 additions
and
0 deletions
llvm/docs/LangRef.html
+
16
−
0
View file @
c0ad71ed
...
@@ -717,6 +717,14 @@ be any type with a size.</p>
...
@@ -717,6 +717,14 @@ be any type with a size.</p>
</td>
</td>
</tr>
</tr>
</table>
</table>
<p>
Note that 'variable sized arrays' can be implemented in LLVM With a zero
length array. Normally accesses past the end of an array are undefined in
LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
As a special case, however, zero length arrays are recognized to be variable
length. This allows implementation of 'pascal style arrays' with the LLVM
type "{ int, [0 x float]}", for example.
</p>
</div>
</div>
<!-- _______________________________________________________________________ -->
<!-- _______________________________________________________________________ -->
...
@@ -1989,7 +1997,15 @@ the LLVM code for the given testcase is equivalent to:</p>
...
@@ -1989,7 +1997,15 @@ the LLVM code for the given testcase is equivalent to:</p>
ret int* %t5
ret int* %t5
}
}
</pre>
</pre>
<p>
Note that it is undefined to access an array out of bounds: array and
pointer indexes must always be within the defined bounds of the array type.
The one exception for this rules is zero length arrays. These arrays are
defined to be accessible as variable length arrays, which requires access
beyond the zero'th element.
</p>
<h5>
Example:
</h5>
<h5>
Example:
</h5>
<pre>
<pre>
<i>
; yields [12 x ubyte]*:aptr
</i>
<i>
; yields [12 x ubyte]*:aptr
</i>
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment