mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-23 16:30:00 +00:00
Fix the JIT code for the Kaleidoscope tutorial.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223670 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
811474b929
commit
72878a54ff
@ -1,5 +1,7 @@
|
|||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||||
|
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||||
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
@ -512,6 +514,7 @@ 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()) {
|
||||||
|
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);
|
||||||
|
|
||||||
@ -557,6 +560,8 @@ double putchard(double X) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
InitializeNativeTarget();
|
InitializeNativeTarget();
|
||||||
|
InitializeNativeTargetAsmPrinter();
|
||||||
|
InitializeNativeTargetAsmParser();
|
||||||
LLVMContext &Context = getGlobalContext();
|
LLVMContext &Context = getGlobalContext();
|
||||||
|
|
||||||
// Install standard binary operators.
|
// Install standard binary operators.
|
||||||
@ -576,8 +581,10 @@ int main() {
|
|||||||
|
|
||||||
// Create the JIT. This takes ownership of the module.
|
// Create the JIT. This takes ownership of the module.
|
||||||
std::string ErrStr;
|
std::string ErrStr;
|
||||||
TheExecutionEngine =
|
TheExecutionEngine = EngineBuilder(std::move(Owner))
|
||||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
.setErrorStr(&ErrStr)
|
||||||
|
.setMCJITMemoryManager(new SectionMemoryManager())
|
||||||
|
.create();
|
||||||
if (!TheExecutionEngine) {
|
if (!TheExecutionEngine) {
|
||||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||||
|
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||||
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
@ -757,6 +759,7 @@ 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()) {
|
||||||
|
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);
|
||||||
|
|
||||||
@ -802,6 +805,8 @@ double putchard(double X) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
InitializeNativeTarget();
|
InitializeNativeTarget();
|
||||||
|
InitializeNativeTargetAsmPrinter();
|
||||||
|
InitializeNativeTargetAsmParser();
|
||||||
LLVMContext &Context = getGlobalContext();
|
LLVMContext &Context = getGlobalContext();
|
||||||
|
|
||||||
// Install standard binary operators.
|
// Install standard binary operators.
|
||||||
@ -821,8 +826,10 @@ int main() {
|
|||||||
|
|
||||||
// Create the JIT. This takes ownership of the module.
|
// Create the JIT. This takes ownership of the module.
|
||||||
std::string ErrStr;
|
std::string ErrStr;
|
||||||
TheExecutionEngine =
|
TheExecutionEngine = EngineBuilder(std::move(Owner))
|
||||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
.setErrorStr(&ErrStr)
|
||||||
|
.setMCJITMemoryManager(new SectionMemoryManager())
|
||||||
|
.create();
|
||||||
if (!TheExecutionEngine) {
|
if (!TheExecutionEngine) {
|
||||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||||
|
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||||
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
@ -868,6 +870,7 @@ 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()) {
|
||||||
|
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);
|
||||||
|
|
||||||
@ -920,6 +923,8 @@ double printd(double X) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
InitializeNativeTarget();
|
InitializeNativeTarget();
|
||||||
|
InitializeNativeTargetAsmPrinter();
|
||||||
|
InitializeNativeTargetAsmParser();
|
||||||
LLVMContext &Context = getGlobalContext();
|
LLVMContext &Context = getGlobalContext();
|
||||||
|
|
||||||
// Install standard binary operators.
|
// Install standard binary operators.
|
||||||
@ -939,8 +944,10 @@ int main() {
|
|||||||
|
|
||||||
// Create the JIT. This takes ownership of the module.
|
// Create the JIT. This takes ownership of the module.
|
||||||
std::string ErrStr;
|
std::string ErrStr;
|
||||||
TheExecutionEngine =
|
TheExecutionEngine = EngineBuilder(std::move(Owner))
|
||||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
.setErrorStr(&ErrStr)
|
||||||
|
.setMCJITMemoryManager(new SectionMemoryManager())
|
||||||
|
.create();
|
||||||
if (!TheExecutionEngine) {
|
if (!TheExecutionEngine) {
|
||||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||||
|
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||||
|
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
#include "llvm/IR/IRBuilder.h"
|
||||||
@ -1031,6 +1033,7 @@ 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()) {
|
||||||
|
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);
|
||||||
|
|
||||||
@ -1083,6 +1086,8 @@ double printd(double X) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
InitializeNativeTarget();
|
InitializeNativeTarget();
|
||||||
|
InitializeNativeTargetAsmPrinter();
|
||||||
|
InitializeNativeTargetAsmParser();
|
||||||
LLVMContext &Context = getGlobalContext();
|
LLVMContext &Context = getGlobalContext();
|
||||||
|
|
||||||
// Install standard binary operators.
|
// Install standard binary operators.
|
||||||
@ -1103,8 +1108,10 @@ int main() {
|
|||||||
|
|
||||||
// Create the JIT. This takes ownership of the module.
|
// Create the JIT. This takes ownership of the module.
|
||||||
std::string ErrStr;
|
std::string ErrStr;
|
||||||
TheExecutionEngine =
|
TheExecutionEngine = EngineBuilder(std::move(Owner))
|
||||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
.setErrorStr(&ErrStr)
|
||||||
|
.setMCJITMemoryManager(new SectionMemoryManager())
|
||||||
|
.create();
|
||||||
if (!TheExecutionEngine) {
|
if (!TheExecutionEngine) {
|
||||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user