mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Update the "hello world" example to resemble what we currently output.
Also do some minor reformatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152707 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3d1d895c86
commit
4cc2be672f
@ -490,43 +490,43 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<p>LLVM programs are composed of "Module"s, each of which is a translation unit
|
<p>LLVM programs are composed of <tt>Module</tt>s, each of which is a
|
||||||
of the input programs. Each module consists of functions, global variables,
|
translation unit of the input programs. Each module consists of functions,
|
||||||
and symbol table entries. Modules may be combined together with the LLVM
|
global variables, and symbol table entries. Modules may be combined together
|
||||||
linker, which merges function (and global variable) definitions, resolves
|
with the LLVM linker, which merges function (and global variable)
|
||||||
forward declarations, and merges symbol table entries. Here is an example of
|
definitions, resolves forward declarations, and merges symbol table
|
||||||
the "hello world" module:</p>
|
entries. Here is an example of the "hello world" module:</p>
|
||||||
|
|
||||||
<pre class="doc_code">
|
<pre class="doc_code">
|
||||||
<i>; Declare the string constant as a global constant.</i>
|
<i>; Declare the string constant as a global constant.</i>
|
||||||
<a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00" <i>; [13 x i8]*</i>
|
<a href="#identifiers">@.str</a> = <a href="#linkage_private">private</a> <a href="#globalvars">unnamed_addr</a> <a href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00"
|
||||||
|
|
||||||
<i>; External declaration of the puts function</i>
|
<i>; External declaration of the puts function</i>
|
||||||
<a href="#functionstructure">declare</a> i32 @puts(i8*) <i>; i32 (i8*)* </i>
|
<a href="#functionstructure">declare</a> i32 @puts(i8* <a href="#nocapture">nocapture</a>) <a href="#fnattrs">nounwind</a>
|
||||||
|
|
||||||
<i>; Definition of main function</i>
|
<i>; Definition of main function</i>
|
||||||
define i32 @main() { <i>; i32()* </i>
|
define i32 @main() { <i>; i32()* </i>
|
||||||
<i>; Convert [13 x i8]* to i8 *...</i>
|
<i>; Convert [13 x i8]* to i8 *...</i>
|
||||||
%cast210 = <a href="#i_getelementptr">getelementptr</a> [13 x i8]* @.LC0, i64 0, i64 0 <i>; i8*</i>
|
%cast210 = <a href="#i_getelementptr">getelementptr</a> [13 x i8]* @.str, i64 0, i64 0
|
||||||
|
|
||||||
<i>; Call puts function to write out the string to stdout.</i>
|
<i>; Call puts function to write out the string to stdout.</i>
|
||||||
<a href="#i_call">call</a> i32 @puts(i8* %cast210) <i>; i32</i>
|
<a href="#i_call">call</a> i32 @puts(i8* %cast210)
|
||||||
<a href="#i_ret">ret</a> i32 0
|
<a href="#i_ret">ret</a> i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
<i>; Named metadata</i>
|
<i>; Named metadata</i>
|
||||||
!1 = metadata !{i32 41}
|
!1 = metadata !{i32 42}
|
||||||
!foo = !{!1, null}
|
!foo = !{!1, null}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>This example is made up of a <a href="#globalvars">global variable</a> named
|
<p>This example is made up of a <a href="#globalvars">global variable</a> named
|
||||||
"<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function,
|
"<tt>.str</tt>", an external declaration of the "<tt>puts</tt>" function,
|
||||||
a <a href="#functionstructure">function definition</a> for
|
a <a href="#functionstructure">function definition</a> for
|
||||||
"<tt>main</tt>" and <a href="#namedmetadatastructure">named metadata</a>
|
"<tt>main</tt>" and <a href="#namedmetadatastructure">named metadata</a>
|
||||||
"<tt>foo"</tt>.</p>
|
"<tt>foo</tt>".</p>
|
||||||
|
|
||||||
<p>In general, a module is made up of a list of global values, where both
|
<p>In general, a module is made up of a list of global values (where both
|
||||||
functions and global variables are global values. Global values are
|
functions and global variables are global values). Global values are
|
||||||
represented by a pointer to a memory location (in this case, a pointer to an
|
represented by a pointer to a memory location (in this case, a pointer to an
|
||||||
array of char, and a pointer to a function), and have one of the
|
array of char, and a pointer to a function), and have one of the
|
||||||
following <a href="#linkage">linkage types</a>.</p>
|
following <a href="#linkage">linkage types</a>.</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user