Files
concrete/compiler/include/zamalang-c/Support/CompilerEngine.h
Andi Drebes 1187cfbd62 refactor(compiler): Refactor CompilerEngine and related classes
This commit contains several incremental improvements towards a clear
interface for lambdas:

  - Unification of static and JIT compilation by using the static
    compilation path of `CompilerEngine` within a new subclass
    `JitCompilerEngine`.

  - Clear ownership for compilation artefacts through
    `CompilationContext`, making it impossible to destroy objects used
    directly or indirectly before destruction of their users.

  - Clear interface for lambdas generated by the compiler through
    `JitCompilerEngine::Lambda` with a templated call operator,
    encapsulating otherwise manual orchestration of `CompilerEngine`,
    `JITLambda`, and `CompilerEngine::Argument`.

  - Improved error handling through `llvm::Expected<T>` and proper
    error checking following the conventions for `llvm::Expected<T>`
    and `llvm::Error`.

Co-authored-by: youben11 <ayoub.benaissa@zama.ai>
2021-10-29 13:44:34 +02:00

38 lines
941 B
C++

#ifndef ZAMALANG_C_SUPPORT_COMPILER_ENGINE_H
#define ZAMALANG_C_SUPPORT_COMPILER_ENGINE_H
#include "mlir-c/IR.h"
#include "mlir-c/Registration.h"
#include "zamalang/Support/CompilerEngine.h"
#include "zamalang/Support/ExecutionArgument.h"
#include "zamalang/Support/Jit.h"
#include "zamalang/Support/JitCompilerEngine.h"
#ifdef __cplusplus
extern "C" {
#endif
struct lambda {
mlir::zamalang::JitCompilerEngine::Lambda *ptr;
};
typedef struct lambda lambda;
struct executionArguments {
mlir::zamalang::ExecutionArgument *data;
size_t size;
};
typedef struct executionArguments exectuionArguments;
MLIR_CAPI_EXPORTED mlir::zamalang::JitCompilerEngine::Lambda
buildLambda(const char *module, const char *funcName);
MLIR_CAPI_EXPORTED uint64_t invokeLambda(lambda l, executionArguments args);
MLIR_CAPI_EXPORTED std::string roundTrip(const char *module);
#ifdef __cplusplus
}
#endif
#endif // ZAMALANG_C_SUPPORT_COMPILER_ENGINE_H