[context] Replace the targetTriple string with a Triple object

This commit is contained in:
Sameer Rahmani 2022-02-22 18:50:42 +00:00
parent 578afc30a4
commit 840a7c565c
3 changed files with 8 additions and 17 deletions

View File

@ -123,8 +123,10 @@ it would be nice for the JIT to add instrumentation to the compiled
functions and detect hot functions similar to how javascript jits do it
and recompile those functions with more optimization passes
* TODOs
** TODO Provide the CLI arguments to pass the =createTargetMachine=.
We need a way to tweak the target machine object. It's better to provide cli tools
to do so.
** TODO Walk the module and register the symbols with the engine (lazy and nonlazy) :JIT:
** TODO Change the compilation layer to accept MLIR modules instead of LLVM IR :JIT:
This way we can fine tune MLIR's passes based on the JIT settings as well

View File

@ -99,11 +99,8 @@ public:
using CurrentNSFn = std::function<T()>;
mlir::MLIRContext mlirContext;
mlir::PassManager pm;
std::unique_ptr<DiagnosticEngine> diagEngine;
std::unique_ptr<serene::jit::Halley> jit;
/// The source manager is responsible for loading namespaces and practically
@ -113,10 +110,7 @@ public:
/// The set of options to change the compilers behaivoirs
Options opts;
std::string targetTriple;
// TODO: Replace target Triple with this one
llvm::Triple triple;
const llvm::Triple triple;
/// Insert the given `ns` into the context. The Context object is
/// the owner of all the namespaces. The `ns` will overwrite any
@ -162,7 +156,8 @@ public:
SereneContext(Options &options)
: pm(&mlirContext), diagEngine(makeDiagnosticEngine(*this)),
opts(options), targetPhase(CompilationPhase::NoOptimization) {
opts(options), triple(llvm::sys::getDefaultTargetTriple()),
targetPhase(CompilationPhase::NoOptimization) {
mlirContext.getOrLoadDialect<serene::slir::SereneDialect>();
mlirContext.getOrLoadDialect<mlir::StandardOpsDialect>();
@ -175,9 +170,6 @@ public:
// TODO: Get the crash report path dynamically from the cli
// pm.enableCrashReproducerGeneration("/home/lxsameer/mlir.mlir");
// TODO: Set the target triple with respect to the CLI args
targetTriple = llvm::sys::getDefaultTargetTriple();
};
/// Set the target compilation phase of the compiler. The compilation
@ -243,8 +235,6 @@ public:
return ctx;
};
llvm::Triple getTargetTriple() const { return llvm::Triple(targetTriple); };
// JIT JITDylib related functions ---
// TODO: For Dylib related functions, make sure that the namespace in questoin

View File

@ -365,9 +365,8 @@ MaybeJIT Halley::make(SereneContext &serene_ctx,
// exported symbol visibility.
// cf llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
// LLJIT::createObjectLinkingLayer
llvm::Triple targetTriple(llvm::Twine(serene_ctx.targetTriple));
if (targetTriple.isOSBinFormatCOFF()) {
if (serene_ctx.triple.isOSBinFormatCOFF()) {
objectLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);
objectLayer->setAutoClaimResponsibilityForObjectSymbols(true);
}
@ -481,7 +480,7 @@ Namespace &Halley::getActiveNS() { return *activeNS; };
llvm::Expected<std::unique_ptr<Halley>> makeHalleyJIT(SereneContext &ctx) {
llvm::orc::JITTargetMachineBuilder jtmb(ctx.getTargetTriple());
llvm::orc::JITTargetMachineBuilder jtmb(ctx.triple);
auto maybeJIT = Halley::make(ctx, std::move(jtmb));
if (!maybeJIT) {
return maybeJIT.takeError();