-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cpp
More file actions
37 lines (33 loc) · 1.02 KB
/
Program.cpp
File metadata and controls
37 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "Program.hpp"
#include "executable/bytecode/codegen/BytecodeGenerator.hpp"
#include "executable/llvm/LLVMGenerator.hpp"
#include "executable/mlir/Dialect/Python/MLIRGenerator.hpp"
#include "mlir/compile.hpp"
#include "utilities.hpp"
Program::Program(std::string &&filename, std::vector<std::string> &&argv)
: m_filename(std::move(filename)), m_argv(std::move(argv))
{}
namespace compiler {
std::shared_ptr<Program> compile(std::shared_ptr<ast::Module> node,
std::vector<std::string> argv,
Backend backend,
OptimizationLevel lvl)
{
switch (backend) {
case Backend::BYTECODE_GENERATOR:
return codegen::BytecodeGenerator::compile(node, std::move(argv), lvl);
case Backend::LLVM: {
#if defined(ENABLE_LLVM_BACKEND) && defined(LLVM_FOUND)
return codegen::LLVMGenerator::compile(node, std::move(argv), lvl);
#else
std::cerr << "LLVM backend unavailable\n";
return nullptr;
#endif
}
case Backend::MLIR: {
return compiler::mlir::compile(node, std::move(argv), lvl);
}
}
ASSERT_NOT_REACHED();
}
}// namespace compiler