Files
concrete/compiler/include/zamalang/Support/CompilerEngine.h
Andi Drebes 2acfa63eb7 feat(compiler): Determine FHE circuit constraints instead of using default values
This replaces the default FHE circuit constrains (maximum encrypted
integer width of 7 bits and a Minimal Arithmetic Noise Padding of 10
with the results of the `MaxMANP` pass, which determines these values
automatically from the input program.

Since the maximum encrypted integer width and the maximum value for
the Minimal Arithmetic Noise Padding can only be derived from HLFHE
operations, the circuit constraints are determined automatically by
`zamacompiler` only if the option `--entry-dialect=hlfhe` was
specified.

For lower-level dialects, `zamacompiler` has been provided with the
options `--assume-max-eint-precision=...` and `--assume-max-manp=...`
that allow a user to specify the values for the maximum required
precision and maximum values for the Minimal Arithmetic Noise Padding.
2021-09-28 11:35:58 +02:00

51 lines
1.3 KiB
C++

#ifndef ZAMALANG_SUPPORT_COMPILER_ENGINE_H
#define ZAMALANG_SUPPORT_COMPILER_ENGINE_H
#include "Jit.h"
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,
llvm::Optional<mlir::zamalang::V0FHEConstraint> overrideConstraints = {});
// 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