Clean up the rst for the debug info tutorial

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223682 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher
2014-12-08 18:48:08 +00:00
parent 7fd7effa37
commit abe81e4794

View File

@@ -75,8 +75,8 @@ statement be our "main":
.. code-block:: udiff .. code-block:: udiff
- PrototypeAST *Proto = new PrototypeAST("", std::vector<std::string>()); - PrototypeAST *Proto = new PrototypeAST("", std::vector<std::string>());
+ PrototypeAST *Proto = new PrototypeAST("main", std::vector<std::string>()); + PrototypeAST *Proto = new PrototypeAST("main", std::vector<std::string>());
just with the simple change of giving it a name. just with the simple change of giving it a name.
@@ -84,19 +84,19 @@ Then we're going to remove the command line code wherever it exists:
.. code-block:: udiff .. code-block:: udiff
@@ -1129,7 +1129,6 @@ static void HandleTopLevelExpression() { @@ -1129,7 +1129,6 @@ static void HandleTopLevelExpression() {
/// top ::= definition | external | expression | ';' /// top ::= definition | external | expression | ';'
static void MainLoop() { static void MainLoop() {
while (1) { while (1) {
- fprintf(stderr, "ready> "); - fprintf(stderr, "ready> ");
switch (CurTok) { switch (CurTok) {
case tok_eof: case tok_eof:
return; return;
@@ -1184,7 +1183,6 @@ int main() { @@ -1184,7 +1183,6 @@ int main() {
BinopPrecedence['*'] = 40; // highest. BinopPrecedence['*'] = 40; // highest.
// Prime the first token. // Prime the first token.
- fprintf(stderr, "ready> "); - fprintf(stderr, "ready> ");
getNextToken(); getNextToken();
Lastly we're going to disable all of the optimization passes and the JIT so Lastly we're going to disable all of the optimization passes and the JIT so
@@ -105,40 +105,40 @@ code is that the llvm IR goes to standard error:
.. code-block:: udiff .. code-block:: udiff
@@ -1108,17 +1108,8 @@ static void HandleExtern() { @@ -1108,17 +1108,8 @@ static void HandleExtern() {
static void HandleTopLevelExpression() { static void HandleTopLevelExpression() {
// Evaluate a top-level expression into an anonymous function. // Evaluate a top-level expression into an anonymous function.
if (FunctionAST *F = ParseTopLevelExpr()) { if (FunctionAST *F = ParseTopLevelExpr()) {
- if (Function *LF = F->Codegen()) { - if (Function *LF = F->Codegen()) {
- // We're just doing this to make sure it executes. - // We're just doing this to make sure it executes.
- TheExecutionEngine->finalizeObject(); - TheExecutionEngine->finalizeObject();
- // JIT the function, returning a function pointer. - // JIT the function, returning a function pointer.
- void *FPtr = TheExecutionEngine->getPointerToFunction(LF); - void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
- -
- // Cast it to the right type (takes no arguments, returns a double) so we - // Cast it to the right type (takes no arguments, returns a double) so we
- // can call it as a native function. - // can call it as a native function.
- double (*FP)() = (double (*)())(intptr_t)FPtr; - double (*FP)() = (double (*)())(intptr_t)FPtr;
- // Ignore the return value for this. - // Ignore the return value for this.
- (void)FP; - (void)FP;
+ if (!F->Codegen()) { + if (!F->Codegen()) {
+ fprintf(stderr, "Error generating code for top level expr"); + fprintf(stderr, "Error generating code for top level expr");
} }
} else { } else {
// Skip token for error recovery. // Skip token for error recovery.
@@ -1439,11 +1459,11 @@ int main() { @@ -1439,11 +1459,11 @@ int main() {
// target lays out data structures. // target lays out data structures.
TheModule->setDataLayout(TheExecutionEngine->getDataLayout()); TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
OurFPM.add(new DataLayoutPass()); OurFPM.add(new DataLayoutPass());
+#if 0 +#if 0
OurFPM.add(createBasicAliasAnalysisPass()); OurFPM.add(createBasicAliasAnalysisPass());
// Promote allocas to registers. // Promote allocas to registers.
OurFPM.add(createPromoteMemoryToRegisterPass()); OurFPM.add(createPromoteMemoryToRegisterPass());
@@ -1218,7 +1210,7 @@ int main() { @@ -1218,7 +1210,7 @@ int main() {
OurFPM.add(createGVNPass()); OurFPM.add(createGVNPass());
// Simplify the control flow graph (deleting unreachable blocks, etc). // Simplify the control flow graph (deleting unreachable blocks, etc).
OurFPM.add(createCFGSimplificationPass()); OurFPM.add(createCFGSimplificationPass());
- -
+ #endif + #endif
OurFPM.doInitialization(); OurFPM.doInitialization();
// Set the global so the code gen can use this. // Set the global so the code gen can use this.
@@ -149,7 +149,7 @@ command line:
.. code-block:: bash .. code-block:: bash
Kaleidoscope-Ch8 < fib.ks | & clang -x ir - Kaleidoscope-Ch8 < fib.ks | & clang -x ir -
which gives an a.out/a.exe in the current working directory. which gives an a.out/a.exe in the current working directory.