Fix the serenec to use the new ns api
This commit is contained in:
parent
3ace6ec260
commit
8af6452457
|
@ -131,7 +131,7 @@ int dumpAsObject(Namespace &ns) {
|
|||
// TODO: Fix this call to raise the wrapped error instead
|
||||
auto module = std::move(
|
||||
maybeModule.getValueOrFail("Faild to generato LLVM IR for namespace"));
|
||||
auto &ctx = ns.getContext();
|
||||
auto &ctx = ns.getContext();
|
||||
|
||||
// TODO: We need to set the triple data layout and everything to that sort in
|
||||
// one place. We want them for the JIT as well and also we're kinda
|
||||
|
@ -309,9 +309,14 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
if (isSet.succeeded()) {
|
||||
ctx->insertNS(ns);
|
||||
if (emitAction < CompileToObject) {
|
||||
switch (emitAction) {
|
||||
case Action::DumpSLIR:
|
||||
case Action::DumpMLIR:
|
||||
case Action::DumpLIR: {
|
||||
ns->dump();
|
||||
} else if (emitAction == Action::DumpIR) {
|
||||
break;
|
||||
};
|
||||
case Action::DumpIR: {
|
||||
auto maybeModule = ns->compileToLLVM();
|
||||
|
||||
if (!maybeModule) {
|
||||
|
@ -320,13 +325,19 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
maybeModule.getValue()->dump();
|
||||
} else if (emitAction == Action::JIT) {
|
||||
break;
|
||||
};
|
||||
|
||||
} else {
|
||||
case Action::Compile:
|
||||
case Action::CompileToObject: {
|
||||
return dumpAsObject(*ns);
|
||||
};
|
||||
default: {
|
||||
llvm::errs() << "Action is not supported yet!\n";
|
||||
};
|
||||
}
|
||||
} else {
|
||||
llvm::outs() << "Can't set the tree of the namespace!\n";
|
||||
llvm::errs() << "Can't set the tree of the namespace!\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
4
dev.org
4
dev.org
|
@ -104,7 +104,7 @@ on ADF
|
|||
- https://en.wikipedia.org/wiki/Collision_attack
|
||||
|
||||
* TODOs
|
||||
** Bootstrap
|
||||
** Bootstrap*
|
||||
*** TODO Add the support for =ns-paths= :serenecli:context:
|
||||
We need to add the support for an array of paths to lookup namespaces. The =ns-paths= should
|
||||
be an array that each entry represents a path which serene has to look into in order to find
|
||||
|
@ -114,9 +114,11 @@ in python.
|
|||
- [ ] Add the support to the *Context*.
|
||||
- [ ] Add the support to *Namespace*.
|
||||
- [ ] Add the cli argument to the =bin/serene.cpp=
|
||||
|
||||
*** TODO Error handling
|
||||
Create proper error handling for the internal infra
|
||||
*** TODO Replace =llvm::outs()= with debug statements
|
||||
* ** TODO Move the generatable logic out of its files and remove them
|
||||
*** TODO Language Spec :DOCS:
|
||||
*** TODO A proper List implementation
|
||||
*** TODO Vector implementation
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <memory>
|
||||
#include <mlir/IR/Builders.h>
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/OwningOpRef.h>
|
||||
#include <mlir/IR/Value.h>
|
||||
#include <mlir/Support/LogicalResult.h>
|
||||
#include <string>
|
||||
|
@ -57,7 +58,7 @@ using Ast = std::vector<Node>;
|
|||
using MaybeModule = Result<std::unique_ptr<llvm::Module>, bool>;
|
||||
|
||||
// TODO: replace the temporary `bool` by errors::Error
|
||||
using MaybeModuleOp = Result<mlir::ModuleOp, bool>;
|
||||
using MaybeModuleOp = Result<mlir::OwningOpRef<mlir::ModuleOp>, bool>;
|
||||
|
||||
/// Serene's namespaces are the unit of compilation. Any code that needs to be
|
||||
/// compiled has to be in a namespace. The official way to create a new
|
||||
|
|
|
@ -115,20 +115,20 @@ void Namespace::dump() {
|
|||
return;
|
||||
}
|
||||
|
||||
maybeModuleOp.getValue().dump();
|
||||
maybeModuleOp.getValue()->dump();
|
||||
};
|
||||
|
||||
MaybeModule Namespace::compileToLLVM() {
|
||||
auto m = generate();
|
||||
auto maybeModule = generate();
|
||||
|
||||
if (!m) {
|
||||
if (!maybeModule) {
|
||||
NAMESPACE_LOG("IR generation failed for '" << name << "'");
|
||||
return MaybeModule::error(true);
|
||||
}
|
||||
|
||||
if (ctx.getTargetPhase() >= CompilationPhase::IR) {
|
||||
return MaybeModule::success(
|
||||
::serene::slir::compileToLLVMIR(ctx, m.getValue()));
|
||||
mlir::ModuleOp module = maybeModule.getValue().get();
|
||||
return MaybeModule::success(::serene::slir::compileToLLVMIR(ctx, module));
|
||||
}
|
||||
|
||||
return MaybeModule::error(true);
|
||||
|
|
Loading…
Reference in New Issue