From 176e8298b5914adcf9fd950e2727e4ceb46afa95 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 19 May 2008 00:19:02 +0000 Subject: [PATCH] Convert non-ASCII apostrophes into ASCII apostrophes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51234 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/tutorial/JITTutorial1.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/tutorial/JITTutorial1.html b/docs/tutorial/JITTutorial1.html index 87b7ed6da8d..3f0e7c18649 100644 --- a/docs/tutorial/JITTutorial1.html +++ b/docs/tutorial/JITTutorial1.html @@ -48,7 +48,7 @@ entry: -

If you're unsure what the above code says, skim through the LLVM Language Reference Manual and convince yourself that the above LLVM IR is actually equivalent to the original function. Once you’re satisfied with that, let’s move on to actually generating it programmatically!

+

If you're unsure what the above code says, skim through the LLVM Language Reference Manual and convince yourself that the above LLVM IR is actually equivalent to the original function. Once you’re satisfied with that, let's move on to actually generating it programmatically!

Of course, before we can start, we need to #include the appropriate LLVM header files:

@@ -64,7 +64,7 @@ entry: -

Now, let’s get started on our real program. Here’s what our basic main() will look like:

+

Now, let's get started on our real program. Here's what our basic main() will look like:

@@ -89,7 +89,7 @@ int main(int argc, char**argv) {
 
 

The first segment is pretty simple: it creates an LLVM “module.” In LLVM, a module represents a single unit of code that is to be processed together. A module contains things like global variables, function declarations, and implementations. Here we’ve declared a makeLLVMModule() function to do the real work of creating the module. Don’t worry, we’ll be looking at that one next!

-

The second segment runs the LLVM module verifier on our newly created module. While this probably isn’t really necessary for a simple module like this one, it’s always a good idea, especially if you’re generating LLVM IR based on some input. The verifier will print an error message if your LLVM module is malformed in any way.

+

The second segment runs the LLVM module verifier on our newly created module. While this probably isn’t really necessary for a simple module like this one, it's always a good idea, especially if you’re generating LLVM IR based on some input. The verifier will print an error message if your LLVM module is malformed in any way.

Finally, we instantiate an LLVM PassManager and run the PrintModulePass on our module. LLVM uses an explicit pass @@ -99,7 +99,7 @@ it is responsible for scheduling them, invoking them, and ensuring the proper disposal after we’re done with them. For this example, we’re just using a trivial pass that prints out our module in textual form.

-

Now onto the interesting part: creating and populating a module. Here’s the +

Now onto the interesting part: creating and populating a module. Here's the first chunk of our makeLLVMModule():

@@ -146,7 +146,7 @@ function will interoperate properly with C code, which is a good thing.

-

While we’re setting up our function, let’s also give names to the parameters. This also isn’t strictly necessary (LLVM will generate names for them if you don’t specify them), but it’ll make looking at our output somewhat more pleasant. To name the parameters, we iterate over the arguments of our function and call setName() on them. We’ll also keep the pointer to x, y, and z around, since we’ll need them when we get around to creating instructions.

+

While we’re setting up our function, let's also give names to the parameters. This also isn’t strictly necessary (LLVM will generate names for them if you don’t specify them), but it’ll make looking at our output somewhat more pleasant. To name the parameters, we iterate over the arguments of our function and call setName() on them. We’ll also keep the pointer to x, y, and z around, since we’ll need them when we get around to creating instructions.

Great! We have a function now. But what good is a function if it has no body? Before we start working on a body for our new function, we need to recall some details of the LLVM IR. The IR, being an abstract assembly language, represents control flow using jumps (we call them branches), both conditional and unconditional. The straight-line sequences of code between branches are called basic blocks, or just blocks. To create a body for our function, we fill it with blocks:

@@ -173,9 +173,9 @@ function will interoperate properly with C code, which is a good thing.

-

The final step in creating our function is to create the instructions that make it up. Our mul_add function is composed of just three instructions: a multiply, an add, and a return. IRBuilder gives us a simple interface for constructing these instructions and appending them to the “entry” block. Each of the calls to IRBuilder returns a Value* that represents the value yielded by the instruction. You’ll also notice that, above, x, y, and z are also Value*’s, so it’s clear that instructions operate on Value*’s.

+

The final step in creating our function is to create the instructions that make it up. Our mul_add function is composed of just three instructions: a multiply, an add, and a return. IRBuilder gives us a simple interface for constructing these instructions and appending them to the “entry” block. Each of the calls to IRBuilder returns a Value* that represents the value yielded by the instruction. You’ll also notice that, above, x, y, and z are also Value*'s, so it's clear that instructions operate on Value*'s.

-

And that’s it! Now you can compile and run your code, and get a wonderful textual print out of the LLVM IR we saw at the beginning. To compile, use the following command line as a guide:

+

And that's it! Now you can compile and run your code, and get a wonderful textual print out of the LLVM IR we saw at the beginning. To compile, use the following command line as a guide: