mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-10 04:35:03 -05:00
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#ifndef ZAMALANG_SUPPORT_COMPILER_ENGINE_H
|
|
#define ZAMALANG_SUPPORT_COMPILER_ENGINE_H
|
|
|
|
#include "zamalang/Dialect/HLFHE/IR/HLFHEDialect.h"
|
|
#include "zamalang/Dialect/HLFHE/IR/HLFHETypes.h"
|
|
#include "zamalang/Dialect/LowLFHE/IR/LowLFHEDialect.h"
|
|
#include "zamalang/Dialect/LowLFHE/IR/LowLFHETypes.h"
|
|
#include "zamalang/Dialect/MidLFHE/IR/MidLFHEDialect.h"
|
|
#include "zamalang/Dialect/MidLFHE/IR/MidLFHETypes.h"
|
|
#include "zamalang/Support/CompilerTools.h"
|
|
#include <mlir/Dialect/Linalg/IR/LinalgOps.h>
|
|
#include <mlir/Dialect/MemRef/IR/MemRef.h>
|
|
#include <mlir/Dialect/StandardOps/IR/Ops.h>
|
|
#include <string>
|
|
|
|
namespace mlir {
|
|
namespace zamalang {
|
|
|
|
/// CompilerEngine is an tools that provides tools to implements the compilation
|
|
/// flow and manage the compilation flow state.
|
|
class CompilerEngine {
|
|
public:
|
|
CompilerEngine() {
|
|
context = new mlir::MLIRContext();
|
|
loadDialects();
|
|
}
|
|
~CompilerEngine() {
|
|
if (context != nullptr)
|
|
delete context;
|
|
}
|
|
|
|
// Compile an mlir programs from it's textual representation.
|
|
llvm::Error compile(std::string mlirStr);
|
|
|
|
// Build the jit lambda argument.
|
|
llvm::Expected<std::unique_ptr<JITLambda::Argument>> buildArgument();
|
|
|
|
// Call the compiled function with and argument object.
|
|
llvm::Error invoke(JITLambda::Argument &arg);
|
|
|
|
// Call the compiled function with a list of integer arguments.
|
|
llvm::Expected<uint64_t> run(std::vector<uint64_t> args);
|
|
|
|
// Get a printable representation of the compiled module
|
|
std::string getCompiledModule();
|
|
|
|
private:
|
|
// Load the necessary dialects into the engine's context
|
|
void loadDialects();
|
|
|
|
mlir::OwningModuleRef module_ref;
|
|
mlir::MLIRContext *context;
|
|
std::unique_ptr<mlir::zamalang::KeySet> keySet;
|
|
};
|
|
} // namespace zamalang
|
|
} // namespace mlir
|
|
|
|
#endif |