summaryrefslogtreecommitdiffstats
path: root/llvm/examples/Kaleidoscope
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-02-09 02:30:40 +0000
committerLang Hames <lhames@gmail.com>2018-02-09 02:30:40 +0000
commit0976cee8e9d6dbf890cb25299baac973307e2d9a (patch)
treec5fccb3bd0a483d8a5cafb402e43729da0c6b4ad /llvm/examples/Kaleidoscope
parent6562b3d954b57b04daf0b1bf72c402d9aabd633e (diff)
downloadbcm5719-llvm-0976cee8e9d6dbf890cb25299baac973307e2d9a.tar.gz
bcm5719-llvm-0976cee8e9d6dbf890cb25299baac973307e2d9a.zip
[ORC] Remove Layer handles from the layer concept.
Handles were returned by addModule and used as keys for removeModule, findSymbolIn, and emitAndFinalize. Their job is now subsumed by VModuleKeys, which simplify resource management by providing a consistent handle across all layers. llvm-svn: 324700
Diffstat (limited to 'llvm/examples/Kaleidoscope')
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h11
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h12
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h10
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h12
-rw-r--r--llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h12
-rw-r--r--llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h21
6 files changed, 39 insertions, 39 deletions
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
index 91709433d93..a5553f488bb 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
@@ -47,7 +47,6 @@ private:
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
public:
- using ModuleHandle = decltype(CompileLayer)::ModuleHandleT;
KaleidoscopeJIT()
: ES(SSP),
@@ -74,9 +73,11 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandle addModule(std::unique_ptr<Module> M) {
+ VModuleKey addModule(std::unique_ptr<Module> M) {
// Add the module to the JIT with a new VModuleKey.
- return cantFail(CompileLayer.addModule(ES.allocateVModule(), std::move(M)));
+ auto K = ES.allocateVModule();
+ cantFail(CompileLayer.addModule(K, std::move(M)));
+ return K;
}
JITSymbol findSymbol(const std::string Name) {
@@ -90,8 +91,8 @@ public:
return cantFail(findSymbol(Name).getAddress());
}
- void removeModule(ModuleHandle H) {
- cantFail(CompileLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ cantFail(CompileLayer.removeModule(K));
}
};
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
index 4b7549391b9..c04244a4ad7 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
@@ -56,7 +56,6 @@ private:
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT()
: ES(SSP),
@@ -86,10 +85,11 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandle addModule(std::unique_ptr<Module> M) {
+ VModuleKey addModule(std::unique_ptr<Module> M) {
// Add the module to the JIT with a new VModuleKey.
- return cantFail(
- OptimizeLayer.addModule(ES.allocateVModule(), std::move(M)));
+ auto K = ES.allocateVModule();
+ cantFail(OptimizeLayer.addModule(K, std::move(M)));
+ return K;
}
JITSymbol findSymbol(const std::string Name) {
@@ -99,8 +99,8 @@ public:
return OptimizeLayer.findSymbol(MangledNameStream.str(), true);
}
- void removeModule(ModuleHandle H) {
- cantFail(OptimizeLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ cantFail(OptimizeLayer.removeModule(K));
}
private:
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
index 43de6d9ef56..767a1183b44 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
@@ -63,7 +63,6 @@ private:
CompileOnDemandLayer<decltype(OptimizeLayer)> CODLayer;
public:
- using ModuleHandle = decltype(CODLayer)::ModuleHandleT;
KaleidoscopeJIT()
: ES(SSP), TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
@@ -92,7 +91,7 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandle addModule(std::unique_ptr<Module> M) {
+ VModuleKey addModule(std::unique_ptr<Module> M) {
// Create a new VModuleKey.
VModuleKey K = ES.allocateVModule();
@@ -111,7 +110,8 @@ public:
[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); });
// Add the module to the JIT with the new key.
- return cantFail(CODLayer.addModule(K, std::move(M)));
+ cantFail(CODLayer.addModule(K, std::move(M)));
+ return K;
}
JITSymbol findSymbol(const std::string Name) {
@@ -121,8 +121,8 @@ public:
return CODLayer.findSymbol(MangledNameStream.str(), true);
}
- void removeModule(ModuleHandle H) {
- cantFail(CODLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ cantFail(CODLayer.removeModule(K));
}
private:
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
index a95efd4ba82..1fa169b8b13 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
@@ -89,7 +89,6 @@ private:
std::unique_ptr<IndirectStubsManager> IndirectStubsMgr;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT()
: ES(SSP),
@@ -127,10 +126,11 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandle addModule(std::unique_ptr<Module> M) {
+ VModuleKey addModule(std::unique_ptr<Module> M) {
// Add the module to the JIT with a new VModuleKey.
- return cantFail(
- OptimizeLayer.addModule(ES.allocateVModule(), std::move(M)));
+ auto K = ES.allocateVModule();
+ cantFail(OptimizeLayer.addModule(K, std::move(M)));
+ return K;
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -195,8 +195,8 @@ public:
return OptimizeLayer.findSymbol(mangle(Name), true);
}
- void removeModule(ModuleHandle H) {
- cantFail(OptimizeLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ cantFail(OptimizeLayer.removeModule(K));
}
private:
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
index 2e9f5c3b37f..806573f1667 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
@@ -95,7 +95,6 @@ private:
MyRemote &Remote;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT(MyRemote &Remote)
: ES(SSP),
@@ -139,10 +138,11 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandle addModule(std::unique_ptr<Module> M) {
+ VModuleKey addModule(std::unique_ptr<Module> M) {
// Add the module with a new VModuleKey.
- return cantFail(
- OptimizeLayer.addModule(ES.allocateVModule(), std::move(M)));
+ auto K = ES.allocateVModule();
+ cantFail(OptimizeLayer.addModule(K, std::move(M)));
+ return K;
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -211,8 +211,8 @@ public:
return OptimizeLayer.findSymbol(mangle(Name), true);
}
- void removeModule(ModuleHandle H) {
- cantFail(OptimizeLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ cantFail(OptimizeLayer.removeModule(K));
}
private:
diff --git a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
index a1cbe0267ba..c2f9d80f636 100644
--- a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
+++ b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h
@@ -42,7 +42,6 @@ class KaleidoscopeJIT {
public:
using ObjLayerT = RTDyldObjectLinkingLayer;
using CompileLayerT = IRCompileLayer<ObjLayerT, SimpleCompiler>;
- using ModuleHandleT = CompileLayerT::ModuleHandleT;
KaleidoscopeJIT()
: ES(SSP),
@@ -62,16 +61,16 @@ public:
TargetMachine &getTargetMachine() { return *TM; }
- ModuleHandleT addModule(std::unique_ptr<Module> M) {
- auto H =
- cantFail(CompileLayer.addModule(ES.allocateVModule(), std::move(M)));
- ModuleHandles.push_back(H);
- return H;
+ VModuleKey addModule(std::unique_ptr<Module> M) {
+ auto K = ES.allocateVModule();
+ cantFail(CompileLayer.addModule(K, std::move(M)));
+ ModuleKeys.push_back(K);
+ return K;
}
- void removeModule(ModuleHandleT H) {
- ModuleHandles.erase(find(ModuleHandles, H));
- cantFail(CompileLayer.removeModule(H));
+ void removeModule(VModuleKey K) {
+ ModuleKeys.erase(find(ModuleKeys, K));
+ cantFail(CompileLayer.removeModule(K));
}
JITSymbol findSymbol(const std::string Name) {
@@ -105,7 +104,7 @@ private:
// Search modules in reverse order: from last added to first added.
// This is the opposite of the usual search order for dlsym, but makes more
// sense in a REPL where we want to bind to the newest available definition.
- for (auto H : make_range(ModuleHandles.rbegin(), ModuleHandles.rend()))
+ for (auto H : make_range(ModuleKeys.rbegin(), ModuleKeys.rend()))
if (auto Sym = CompileLayer.findSymbolIn(H, Name, ExportedSymbolsOnly))
return Sym;
@@ -133,7 +132,7 @@ private:
const DataLayout DL;
ObjLayerT ObjectLayer;
CompileLayerT CompileLayer;
- std::vector<ModuleHandleT> ModuleHandles;
+ std::vector<VModuleKey> ModuleKeys;
};
} // end namespace orc
OpenPOWER on IntegriCloud