llvm.org GIT mirror llvm / abe81e4
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 Eric Christopher 4 years ago
1 changed file(s) with 52 addition(s) and 52 deletion(s). Raw diff Collapse all Expand all
7474
7575 .. code-block:: udiff
7676
77 - PrototypeAST *Proto = new PrototypeAST("", std::vector());
78 + PrototypeAST *Proto = new PrototypeAST("main", std::vector());
77 - PrototypeAST *Proto = new PrototypeAST("", std::vector());
78 + PrototypeAST *Proto = new PrototypeAST("main", std::vector());
7979
8080 just with the simple change of giving it a name.
8181
8383
8484 .. code-block:: udiff
8585
86 @@ -1129,7 +1129,6 @@ static void HandleTopLevelExpression() {
87 /// top ::= definition | external | expression | ';'
88 static void MainLoop() {
89 while (1) {
90 - fprintf(stderr, "ready> ");
91 switch (CurTok) {
92 case tok_eof:
93 return;
94 @@ -1184,7 +1183,6 @@ int main() {
95 BinopPrecedence['*'] = 40; // highest.
86 @@ -1129,7 +1129,6 @@ static void HandleTopLevelExpression() {
87 /// top ::= definition | external | expression | ';'
88 static void MainLoop() {
89 while (1) {
90 - fprintf(stderr, "ready> ");
91 switch (CurTok) {
92 case tok_eof:
93 return;
94 @@ -1184,7 +1183,6 @@ int main() {
95 BinopPrecedence['*'] = 40; // highest.
9696
97 // Prime the first token.
98 - fprintf(stderr, "ready> ");
99 getNextToken();
97 // Prime the first token.
98 - fprintf(stderr, "ready> ");
99 getNextToken();
100100
101101 Lastly we're going to disable all of the optimization passes and the JIT so
102102 that the only thing that happens after we're done parsing and generating
104104
105105 .. code-block:: udiff
106106
107 @@ -1108,17 +1108,8 @@ static void HandleExtern() {
108 static void HandleTopLevelExpression() {
109 // Evaluate a top-level expression into an anonymous function.
110 if (FunctionAST *F = ParseTopLevelExpr()) {
111 - if (Function *LF = F->Codegen()) {
112 - // We're just doing this to make sure it executes.
113 - TheExecutionEngine->finalizeObject();
114 - // JIT the function, returning a function pointer.
115 - void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
116 -
117 - // Cast it to the right type (takes no arguments, returns a double) so we
118 - // can call it as a native function.
119 - double (*FP)() = (double (*)())(intptr_t)FPtr;
120 - // Ignore the return value for this.
121 - (void)FP;
122 + if (!F->Codegen()) {
123 + fprintf(stderr, "Error generating code for top level expr");
124 }
125 } else {
126 // Skip token for error recovery.
127 @@ -1439,11 +1459,11 @@ int main() {
128 // target lays out data structures.
129 TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
130 OurFPM.add(new DataLayoutPass());
131 +#if 0
132 OurFPM.add(createBasicAliasAnalysisPass());
133 // Promote allocas to registers.
134 OurFPM.add(createPromoteMemoryToRegisterPass());
135 @@ -1218,7 +1210,7 @@ int main() {
136 OurFPM.add(createGVNPass());
137 // Simplify the control flow graph (deleting unreachable blocks, etc).
138 OurFPM.add(createCFGSimplificationPass());
139 -
140 + #endif
141 OurFPM.doInitialization();
107 @@ -1108,17 +1108,8 @@ static void HandleExtern() {
108 static void HandleTopLevelExpression() {
109 // Evaluate a top-level expression into an anonymous function.
110 if (FunctionAST *F = ParseTopLevelExpr()) {
111 - if (Function *LF = F->Codegen()) {
112 - // We're just doing this to make sure it executes.
113 - TheExecutionEngine->finalizeObject();
114 - // JIT the function, returning a function pointer.
115 - void *FPtr = TheExecutionEngine->getPointerToFunction(LF);
116 -
117 - // Cast it to the right type (takes no arguments, returns a double) so we
118 - // can call it as a native function.
119 - double (*FP)() = (double (*)())(intptr_t)FPtr;
120 - // Ignore the return value for this.
121 - (void)FP;
122 + if (!F->Codegen()) {
123 + fprintf(stderr, "Error generating code for top level expr");
124 }
125 } else {
126 // Skip token for error recovery.
127 @@ -1439,11 +1459,11 @@ int main() {
128 // target lays out data structures.
129 TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
130 OurFPM.add(new DataLayoutPass());
131 +#if 0
132 OurFPM.add(createBasicAliasAnalysisPass());
133 // Promote allocas to registers.
134 OurFPM.add(createPromoteMemoryToRegisterPass());
135 @@ -1218,7 +1210,7 @@ int main() {
136 OurFPM.add(createGVNPass());
137 // Simplify the control flow graph (deleting unreachable blocks, etc).
138 OurFPM.add(createCFGSimplificationPass());
139 -
140 + #endif
141 OurFPM.doInitialization();
142142
143 // Set the global so the code gen can use this.
143 // Set the global so the code gen can use this.
144144
145145 This relatively small set of changes get us to the point that we can compile
146146 our piece of Kaleidoscope language down to an executable program via this
148148
149149 .. code-block:: bash
150150
151 Kaleidoscope-Ch8 < fib.ks | & clang -x ir -
151 Kaleidoscope-Ch8 < fib.ks | & clang -x ir -
152152
153153 which gives an a.out/a.exe in the current working directory.
154154