1 #include "llvm/DerivedTypes.h"
2 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3 #include "llvm/ExecutionEngine/JIT.h"
4 #include "llvm/LLVMContext.h"
5 #include "llvm/Module.h"
6 #include "llvm/PassManager.h"
7 #include "llvm/Analysis/Verifier.h"
8 #include "llvm/Analysis/Passes.h"
9 #include "llvm/Target/TargetData.h"
10 #include "llvm/Target/TargetSelect.h"
11 #include "llvm/Transforms/Scalar.h"
12 #include "llvm/Support/IRBuilder.h"
19 //===----------------------------------------------------------------------===//
21 //===----------------------------------------------------------------------===//
23 // The lexer returns tokens [0-255] if it is an unknown character, otherwise one
24 // of these for known things.
29 tok_def
= -2, tok_extern
= -3,
32 tok_identifier
= -4, tok_number
= -5,
35 tok_if
= -6, tok_then
= -7, tok_else
= -8,
36 tok_for
= -9, tok_in
= -10
39 static std::string IdentifierStr
; // Filled in if tok_identifier
40 static double NumVal
; // Filled in if tok_number
42 /// gettok - Return the next token from standard input.
44 static int LastChar
= ' ';
46 // Skip any whitespace.
47 while (isspace(LastChar
))
50 if (isalpha(LastChar
)) { // identifier: [a-zA-Z][a-zA-Z0-9]*
51 IdentifierStr
= LastChar
;
52 while (isalnum((LastChar
= getchar())))
53 IdentifierStr
+= LastChar
;
55 if (IdentifierStr
== "def") return tok_def
;
56 if (IdentifierStr
== "extern") return tok_extern
;
57 if (IdentifierStr
== "if") return tok_if
;
58 if (IdentifierStr
== "then") return tok_then
;
59 if (IdentifierStr
== "else") return tok_else
;
60 if (IdentifierStr
== "for") return tok_for
;
61 if (IdentifierStr
== "in") return tok_in
;
62 return tok_identifier
;
65 if (isdigit(LastChar
) || LastChar
== '.') { // Number: [0-9.]+
70 } while (isdigit(LastChar
) || LastChar
== '.');
72 NumVal
= strtod(NumStr
.c_str(), 0);
76 if (LastChar
== '#') {
77 // Comment until end of line.
78 do LastChar
= getchar();
79 while (LastChar
!= EOF
&& LastChar
!= '\n' && LastChar
!= '\r');
85 // Check for end of file. Don't eat the EOF.
89 // Otherwise, just return the character as its ascii value.
90 int ThisChar
= LastChar
;
95 //===----------------------------------------------------------------------===//
96 // Abstract Syntax Tree (aka Parse Tree)
97 //===----------------------------------------------------------------------===//
99 /// ExprAST - Base class for all expression nodes.
102 virtual ~ExprAST() {}
103 virtual Value
*Codegen() = 0;
106 /// NumberExprAST - Expression class for numeric literals like "1.0".
107 class NumberExprAST
: public ExprAST
{
110 NumberExprAST(double val
) : Val(val
) {}
111 virtual Value
*Codegen();
114 /// VariableExprAST - Expression class for referencing a variable, like "a".
115 class VariableExprAST
: public ExprAST
{
118 VariableExprAST(const std::string
&name
) : Name(name
) {}
119 virtual Value
*Codegen();
122 /// BinaryExprAST - Expression class for a binary operator.
123 class BinaryExprAST
: public ExprAST
{
127 BinaryExprAST(char op
, ExprAST
*lhs
, ExprAST
*rhs
)
128 : Op(op
), LHS(lhs
), RHS(rhs
) {}
129 virtual Value
*Codegen();
132 /// CallExprAST - Expression class for function calls.
133 class CallExprAST
: public ExprAST
{
135 std::vector
<ExprAST
*> Args
;
137 CallExprAST(const std::string
&callee
, std::vector
<ExprAST
*> &args
)
138 : Callee(callee
), Args(args
) {}
139 virtual Value
*Codegen();
142 /// IfExprAST - Expression class for if/then/else.
143 class IfExprAST
: public ExprAST
{
144 ExprAST
*Cond
, *Then
, *Else
;
146 IfExprAST(ExprAST
*cond
, ExprAST
*then
, ExprAST
*_else
)
147 : Cond(cond
), Then(then
), Else(_else
) {}
148 virtual Value
*Codegen();
151 /// ForExprAST - Expression class for for/in.
152 class ForExprAST
: public ExprAST
{
154 ExprAST
*Start
, *End
, *Step
, *Body
;
156 ForExprAST(const std::string
&varname
, ExprAST
*start
, ExprAST
*end
,
157 ExprAST
*step
, ExprAST
*body
)
158 : VarName(varname
), Start(start
), End(end
), Step(step
), Body(body
) {}
159 virtual Value
*Codegen();
162 /// PrototypeAST - This class represents the "prototype" for a function,
163 /// which captures its name, and its argument names (thus implicitly the number
164 /// of arguments the function takes).
167 std::vector
<std::string
> Args
;
169 PrototypeAST(const std::string
&name
, const std::vector
<std::string
> &args
)
170 : Name(name
), Args(args
) {}
175 /// FunctionAST - This class represents a function definition itself.
180 FunctionAST(PrototypeAST
*proto
, ExprAST
*body
)
181 : Proto(proto
), Body(body
) {}
186 //===----------------------------------------------------------------------===//
188 //===----------------------------------------------------------------------===//
190 /// CurTok/getNextToken - Provide a simple token buffer. CurTok is the current
191 /// token the parser is looking at. getNextToken reads another token from the
192 /// lexer and updates CurTok with its results.
194 static int getNextToken() {
195 return CurTok
= gettok();
198 /// BinopPrecedence - This holds the precedence for each binary operator that is
200 static std::map
<char, int> BinopPrecedence
;
202 /// GetTokPrecedence - Get the precedence of the pending binary operator token.
203 static int GetTokPrecedence() {
204 if (!isascii(CurTok
))
207 // Make sure it's a declared binop.
208 int TokPrec
= BinopPrecedence
[CurTok
];
209 if (TokPrec
<= 0) return -1;
213 /// Error* - These are little helper functions for error handling.
214 ExprAST
*Error(const char *Str
) { fprintf(stderr
, "Error: %s\n", Str
);return 0;}
215 PrototypeAST
*ErrorP(const char *Str
) { Error(Str
); return 0; }
216 FunctionAST
*ErrorF(const char *Str
) { Error(Str
); return 0; }
218 static ExprAST
*ParseExpression();
222 /// ::= identifier '(' expression* ')'
223 static ExprAST
*ParseIdentifierExpr() {
224 std::string IdName
= IdentifierStr
;
226 getNextToken(); // eat identifier.
228 if (CurTok
!= '(') // Simple variable ref.
229 return new VariableExprAST(IdName
);
232 getNextToken(); // eat (
233 std::vector
<ExprAST
*> Args
;
236 ExprAST
*Arg
= ParseExpression();
240 if (CurTok
== ')') break;
243 return Error("Expected ')' or ',' in argument list");
251 return new CallExprAST(IdName
, Args
);
254 /// numberexpr ::= number
255 static ExprAST
*ParseNumberExpr() {
256 ExprAST
*Result
= new NumberExprAST(NumVal
);
257 getNextToken(); // consume the number
261 /// parenexpr ::= '(' expression ')'
262 static ExprAST
*ParseParenExpr() {
263 getNextToken(); // eat (.
264 ExprAST
*V
= ParseExpression();
268 return Error("expected ')'");
269 getNextToken(); // eat ).
273 /// ifexpr ::= 'if' expression 'then' expression 'else' expression
274 static ExprAST
*ParseIfExpr() {
275 getNextToken(); // eat the if.
278 ExprAST
*Cond
= ParseExpression();
281 if (CurTok
!= tok_then
)
282 return Error("expected then");
283 getNextToken(); // eat the then
285 ExprAST
*Then
= ParseExpression();
286 if (Then
== 0) return 0;
288 if (CurTok
!= tok_else
)
289 return Error("expected else");
293 ExprAST
*Else
= ParseExpression();
296 return new IfExprAST(Cond
, Then
, Else
);
299 /// forexpr ::= 'for' identifier '=' expr ',' expr (',' expr)? 'in' expression
300 static ExprAST
*ParseForExpr() {
301 getNextToken(); // eat the for.
303 if (CurTok
!= tok_identifier
)
304 return Error("expected identifier after for");
306 std::string IdName
= IdentifierStr
;
307 getNextToken(); // eat identifier.
310 return Error("expected '=' after for");
311 getNextToken(); // eat '='.
314 ExprAST
*Start
= ParseExpression();
315 if (Start
== 0) return 0;
317 return Error("expected ',' after for start value");
320 ExprAST
*End
= ParseExpression();
321 if (End
== 0) return 0;
323 // The step value is optional.
327 Step
= ParseExpression();
328 if (Step
== 0) return 0;
331 if (CurTok
!= tok_in
)
332 return Error("expected 'in' after for");
333 getNextToken(); // eat 'in'.
335 ExprAST
*Body
= ParseExpression();
336 if (Body
== 0) return 0;
338 return new ForExprAST(IdName
, Start
, End
, Step
, Body
);
342 /// ::= identifierexpr
347 static ExprAST
*ParsePrimary() {
349 default: return Error("unknown token when expecting an expression");
350 case tok_identifier
: return ParseIdentifierExpr();
351 case tok_number
: return ParseNumberExpr();
352 case '(': return ParseParenExpr();
353 case tok_if
: return ParseIfExpr();
354 case tok_for
: return ParseForExpr();
359 /// ::= ('+' primary)*
360 static ExprAST
*ParseBinOpRHS(int ExprPrec
, ExprAST
*LHS
) {
361 // If this is a binop, find its precedence.
363 int TokPrec
= GetTokPrecedence();
365 // If this is a binop that binds at least as tightly as the current binop,
366 // consume it, otherwise we are done.
367 if (TokPrec
< ExprPrec
)
370 // Okay, we know this is a binop.
372 getNextToken(); // eat binop
374 // Parse the primary expression after the binary operator.
375 ExprAST
*RHS
= ParsePrimary();
378 // If BinOp binds less tightly with RHS than the operator after RHS, let
379 // the pending operator take RHS as its LHS.
380 int NextPrec
= GetTokPrecedence();
381 if (TokPrec
< NextPrec
) {
382 RHS
= ParseBinOpRHS(TokPrec
+1, RHS
);
383 if (RHS
== 0) return 0;
387 LHS
= new BinaryExprAST(BinOp
, LHS
, RHS
);
392 /// ::= primary binoprhs
394 static ExprAST
*ParseExpression() {
395 ExprAST
*LHS
= ParsePrimary();
398 return ParseBinOpRHS(0, LHS
);
402 /// ::= id '(' id* ')'
403 static PrototypeAST
*ParsePrototype() {
404 if (CurTok
!= tok_identifier
)
405 return ErrorP("Expected function name in prototype");
407 std::string FnName
= IdentifierStr
;
411 return ErrorP("Expected '(' in prototype");
413 std::vector
<std::string
> ArgNames
;
414 while (getNextToken() == tok_identifier
)
415 ArgNames
.push_back(IdentifierStr
);
417 return ErrorP("Expected ')' in prototype");
420 getNextToken(); // eat ')'.
422 return new PrototypeAST(FnName
, ArgNames
);
425 /// definition ::= 'def' prototype expression
426 static FunctionAST
*ParseDefinition() {
427 getNextToken(); // eat def.
428 PrototypeAST
*Proto
= ParsePrototype();
429 if (Proto
== 0) return 0;
431 if (ExprAST
*E
= ParseExpression())
432 return new FunctionAST(Proto
, E
);
436 /// toplevelexpr ::= expression
437 static FunctionAST
*ParseTopLevelExpr() {
438 if (ExprAST
*E
= ParseExpression()) {
439 // Make an anonymous proto.
440 PrototypeAST
*Proto
= new PrototypeAST("", std::vector
<std::string
>());
441 return new FunctionAST(Proto
, E
);
446 /// external ::= 'extern' prototype
447 static PrototypeAST
*ParseExtern() {
448 getNextToken(); // eat extern.
449 return ParsePrototype();
452 //===----------------------------------------------------------------------===//
454 //===----------------------------------------------------------------------===//
456 static Module
*TheModule
;
457 static IRBuilder
<> Builder(getGlobalContext());
458 static std::map
<std::string
, Value
*> NamedValues
;
459 static FunctionPassManager
*TheFPM
;
461 Value
*ErrorV(const char *Str
) { Error(Str
); return 0; }
463 Value
*NumberExprAST::Codegen() {
464 return ConstantFP::get(getGlobalContext(), APFloat(Val
));
467 Value
*VariableExprAST::Codegen() {
468 // Look this variable up in the function.
469 Value
*V
= NamedValues
[Name
];
470 return V
? V
: ErrorV("Unknown variable name");
473 Value
*BinaryExprAST::Codegen() {
474 Value
*L
= LHS
->Codegen();
475 Value
*R
= RHS
->Codegen();
476 if (L
== 0 || R
== 0) return 0;
479 case '+': return Builder
.CreateFAdd(L
, R
, "addtmp");
480 case '-': return Builder
.CreateFSub(L
, R
, "subtmp");
481 case '*': return Builder
.CreateFMul(L
, R
, "multmp");
483 L
= Builder
.CreateFCmpULT(L
, R
, "cmptmp");
484 // Convert bool 0/1 to double 0.0 or 1.0
485 return Builder
.CreateUIToFP(L
, Type::getDoubleTy(getGlobalContext()),
487 default: return ErrorV("invalid binary operator");
491 Value
*CallExprAST::Codegen() {
492 // Look up the name in the global module table.
493 Function
*CalleeF
= TheModule
->getFunction(Callee
);
495 return ErrorV("Unknown function referenced");
497 // If argument mismatch error.
498 if (CalleeF
->arg_size() != Args
.size())
499 return ErrorV("Incorrect # arguments passed");
501 std::vector
<Value
*> ArgsV
;
502 for (unsigned i
= 0, e
= Args
.size(); i
!= e
; ++i
) {
503 ArgsV
.push_back(Args
[i
]->Codegen());
504 if (ArgsV
.back() == 0) return 0;
507 return Builder
.CreateCall(CalleeF
, ArgsV
.begin(), ArgsV
.end(), "calltmp");
510 Value
*IfExprAST::Codegen() {
511 Value
*CondV
= Cond
->Codegen();
512 if (CondV
== 0) return 0;
514 // Convert condition to a bool by comparing equal to 0.0.
515 CondV
= Builder
.CreateFCmpONE(CondV
,
516 ConstantFP::get(getGlobalContext(), APFloat(0.0)),
519 Function
*TheFunction
= Builder
.GetInsertBlock()->getParent();
521 // Create blocks for the then and else cases. Insert the 'then' block at the
522 // end of the function.
523 BasicBlock
*ThenBB
= BasicBlock::Create(getGlobalContext(), "then", TheFunction
);
524 BasicBlock
*ElseBB
= BasicBlock::Create(getGlobalContext(), "else");
525 BasicBlock
*MergeBB
= BasicBlock::Create(getGlobalContext(), "ifcont");
527 Builder
.CreateCondBr(CondV
, ThenBB
, ElseBB
);
530 Builder
.SetInsertPoint(ThenBB
);
532 Value
*ThenV
= Then
->Codegen();
533 if (ThenV
== 0) return 0;
535 Builder
.CreateBr(MergeBB
);
536 // Codegen of 'Then' can change the current block, update ThenBB for the PHI.
537 ThenBB
= Builder
.GetInsertBlock();
540 TheFunction
->getBasicBlockList().push_back(ElseBB
);
541 Builder
.SetInsertPoint(ElseBB
);
543 Value
*ElseV
= Else
->Codegen();
544 if (ElseV
== 0) return 0;
546 Builder
.CreateBr(MergeBB
);
547 // Codegen of 'Else' can change the current block, update ElseBB for the PHI.
548 ElseBB
= Builder
.GetInsertBlock();
551 TheFunction
->getBasicBlockList().push_back(MergeBB
);
552 Builder
.SetInsertPoint(MergeBB
);
553 PHINode
*PN
= Builder
.CreatePHI(Type::getDoubleTy(getGlobalContext()), 2,
556 PN
->addIncoming(ThenV
, ThenBB
);
557 PN
->addIncoming(ElseV
, ElseBB
);
561 Value
*ForExprAST::Codegen() {
567 // variable = phi [start, loopheader], [nextvariable, loopend]
573 // nextvariable = variable + step
575 // br endcond, loop, endloop
578 // Emit the start code first, without 'variable' in scope.
579 Value
*StartVal
= Start
->Codegen();
580 if (StartVal
== 0) return 0;
582 // Make the new basic block for the loop header, inserting after current
584 Function
*TheFunction
= Builder
.GetInsertBlock()->getParent();
585 BasicBlock
*PreheaderBB
= Builder
.GetInsertBlock();
586 BasicBlock
*LoopBB
= BasicBlock::Create(getGlobalContext(), "loop", TheFunction
);
588 // Insert an explicit fall through from the current block to the LoopBB.
589 Builder
.CreateBr(LoopBB
);
591 // Start insertion in LoopBB.
592 Builder
.SetInsertPoint(LoopBB
);
594 // Start the PHI node with an entry for Start.
595 PHINode
*Variable
= Builder
.CreatePHI(Type::getDoubleTy(getGlobalContext()), 2, VarName
.c_str());
596 Variable
->addIncoming(StartVal
, PreheaderBB
);
598 // Within the loop, the variable is defined equal to the PHI node. If it
599 // shadows an existing variable, we have to restore it, so save it now.
600 Value
*OldVal
= NamedValues
[VarName
];
601 NamedValues
[VarName
] = Variable
;
603 // Emit the body of the loop. This, like any other expr, can change the
604 // current BB. Note that we ignore the value computed by the body, but don't
606 if (Body
->Codegen() == 0)
609 // Emit the step value.
612 StepVal
= Step
->Codegen();
613 if (StepVal
== 0) return 0;
615 // If not specified, use 1.0.
616 StepVal
= ConstantFP::get(getGlobalContext(), APFloat(1.0));
619 Value
*NextVar
= Builder
.CreateFAdd(Variable
, StepVal
, "nextvar");
621 // Compute the end condition.
622 Value
*EndCond
= End
->Codegen();
623 if (EndCond
== 0) return EndCond
;
625 // Convert condition to a bool by comparing equal to 0.0.
626 EndCond
= Builder
.CreateFCmpONE(EndCond
,
627 ConstantFP::get(getGlobalContext(), APFloat(0.0)),
630 // Create the "after loop" block and insert it.
631 BasicBlock
*LoopEndBB
= Builder
.GetInsertBlock();
632 BasicBlock
*AfterBB
= BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction
);
634 // Insert the conditional branch into the end of LoopEndBB.
635 Builder
.CreateCondBr(EndCond
, LoopBB
, AfterBB
);
637 // Any new code will be inserted in AfterBB.
638 Builder
.SetInsertPoint(AfterBB
);
640 // Add a new entry to the PHI node for the backedge.
641 Variable
->addIncoming(NextVar
, LoopEndBB
);
643 // Restore the unshadowed variable.
645 NamedValues
[VarName
] = OldVal
;
647 NamedValues
.erase(VarName
);
650 // for expr always returns 0.0.
651 return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
654 Function
*PrototypeAST::Codegen() {
655 // Make the function type: double(double,double) etc.
656 std::vector
<const Type
*> Doubles(Args
.size(),
657 Type::getDoubleTy(getGlobalContext()));
658 FunctionType
*FT
= FunctionType::get(Type::getDoubleTy(getGlobalContext()),
661 Function
*F
= Function::Create(FT
, Function::ExternalLinkage
, Name
, TheModule
);
663 // If F conflicted, there was already something named 'Name'. If it has a
664 // body, don't allow redefinition or reextern.
665 if (F
->getName() != Name
) {
666 // Delete the one we just made and get the existing one.
667 F
->eraseFromParent();
668 F
= TheModule
->getFunction(Name
);
670 // If F already has a body, reject this.
672 ErrorF("redefinition of function");
676 // If F took a different number of args, reject.
677 if (F
->arg_size() != Args
.size()) {
678 ErrorF("redefinition of function with different # args");
683 // Set names for all arguments.
685 for (Function::arg_iterator AI
= F
->arg_begin(); Idx
!= Args
.size();
687 AI
->setName(Args
[Idx
]);
689 // Add arguments to variable symbol table.
690 NamedValues
[Args
[Idx
]] = AI
;
696 Function
*FunctionAST::Codegen() {
699 Function
*TheFunction
= Proto
->Codegen();
700 if (TheFunction
== 0)
703 // Create a new basic block to start insertion into.
704 BasicBlock
*BB
= BasicBlock::Create(getGlobalContext(), "entry", TheFunction
);
705 Builder
.SetInsertPoint(BB
);
707 if (Value
*RetVal
= Body
->Codegen()) {
708 // Finish off the function.
709 Builder
.CreateRet(RetVal
);
711 // Validate the generated code, checking for consistency.
712 verifyFunction(*TheFunction
);
714 // Optimize the function.
715 TheFPM
->run(*TheFunction
);
720 // Error reading body, remove function.
721 TheFunction
->eraseFromParent();
725 //===----------------------------------------------------------------------===//
726 // Top-Level parsing and JIT Driver
727 //===----------------------------------------------------------------------===//
729 static ExecutionEngine
*TheExecutionEngine
;
731 static void HandleDefinition() {
732 if (FunctionAST
*F
= ParseDefinition()) {
733 if (Function
*LF
= F
->Codegen()) {
734 fprintf(stderr
, "Read function definition:");
738 // Skip token for error recovery.
743 static void HandleExtern() {
744 if (PrototypeAST
*P
= ParseExtern()) {
745 if (Function
*F
= P
->Codegen()) {
746 fprintf(stderr
, "Read extern: ");
750 // Skip token for error recovery.
755 static void HandleTopLevelExpression() {
756 // Evaluate a top-level expression into an anonymous function.
757 if (FunctionAST
*F
= ParseTopLevelExpr()) {
758 if (Function
*LF
= F
->Codegen()) {
759 // JIT the function, returning a function pointer.
760 void *FPtr
= TheExecutionEngine
->getPointerToFunction(LF
);
762 // Cast it to the right type (takes no arguments, returns a double) so we
763 // can call it as a native function.
764 double (*FP
)() = (double (*)())(intptr_t)FPtr
;
765 fprintf(stderr
, "Evaluated to %f\n", FP());
768 // Skip token for error recovery.
773 /// top ::= definition | external | expression | ';'
774 static void MainLoop() {
776 fprintf(stderr
, "ready> ");
778 case tok_eof
: return;
779 case ';': getNextToken(); break; // ignore top-level semicolons.
780 case tok_def
: HandleDefinition(); break;
781 case tok_extern
: HandleExtern(); break;
782 default: HandleTopLevelExpression(); break;
787 //===----------------------------------------------------------------------===//
788 // "Library" functions that can be "extern'd" from user code.
789 //===----------------------------------------------------------------------===//
791 /// putchard - putchar that takes a double and returns 0.
793 double putchard(double X
) {
798 //===----------------------------------------------------------------------===//
800 //===----------------------------------------------------------------------===//
803 InitializeNativeTarget();
804 LLVMContext
&Context
= getGlobalContext();
806 // Install standard binary operators.
807 // 1 is lowest precedence.
808 BinopPrecedence
['<'] = 10;
809 BinopPrecedence
['+'] = 20;
810 BinopPrecedence
['-'] = 20;
811 BinopPrecedence
['*'] = 40; // highest.
813 // Prime the first token.
814 fprintf(stderr
, "ready> ");
817 // Make the module, which holds all the code.
818 TheModule
= new Module("my cool jit", Context
);
820 // Create the JIT. This takes ownership of the module.
822 TheExecutionEngine
= EngineBuilder(TheModule
).setErrorStr(&ErrStr
).create();
823 if (!TheExecutionEngine
) {
824 fprintf(stderr
, "Could not create ExecutionEngine: %s\n", ErrStr
.c_str());
828 FunctionPassManager
OurFPM(TheModule
);
830 // Set up the optimizer pipeline. Start with registering info about how the
831 // target lays out data structures.
832 OurFPM
.add(new TargetData(*TheExecutionEngine
->getTargetData()));
833 // Provide basic AliasAnalysis support for GVN.
834 OurFPM
.add(createBasicAliasAnalysisPass());
835 // Do simple "peephole" optimizations and bit-twiddling optzns.
836 OurFPM
.add(createInstructionCombiningPass());
837 // Reassociate expressions.
838 OurFPM
.add(createReassociatePass());
839 // Eliminate Common SubExpressions.
840 OurFPM
.add(createGVNPass());
841 // Simplify the control flow graph (deleting unreachable blocks, etc).
842 OurFPM
.add(createCFGSimplificationPass());
844 OurFPM
.doInitialization();
846 // Set the global so the code gen can use this.
849 // Run the main "interpreter loop" now.
854 // Print out all of the generated code.