Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/examples/Kaleidoscope/Chapter5/toy.cpp
Show First 20 Lines • Show All 880 Lines • ▼ Show 20 Lines | if (FnAST->codegen()) { | ||||
InitializeModuleAndPassManager(); | InitializeModuleAndPassManager(); | ||||
// Search the JIT for the __anon_expr symbol. | // Search the JIT for the __anon_expr symbol. | ||||
auto ExprSymbol = TheJIT->findSymbol("__anon_expr"); | auto ExprSymbol = TheJIT->findSymbol("__anon_expr"); | ||||
assert(ExprSymbol && "Function not found"); | assert(ExprSymbol && "Function not found"); | ||||
// Get the symbol's address and cast it to the right type (takes no | // Get the symbol's address and cast it to the right type (takes no | ||||
// arguments, returns a double) so we can call it as a native function. | // arguments, returns a double) so we can call it as a native function. | ||||
double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); | double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); | ||||
fprintf(stderr, "Evaluated to %f\n", FP()); | fprintf(stderr, "Evaluated to %f\n", FP()); | ||||
// Delete the anonymous expression module from the JIT. | // Delete the anonymous expression module from the JIT. | ||||
TheJIT->removeModule(H); | TheJIT->removeModule(H); | ||||
} | } | ||||
} else { | } else { | ||||
// Skip token for error recovery. | // Skip token for error recovery. | ||||
getNextToken(); | getNextToken(); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |