mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 20:25:34 -05:00
chore(compiler): Empty MLIR structure
This commit is contained in:
1
compiler/.gitignore
vendored
Normal file
1
compiler/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build/
|
||||
29
compiler/CMakeLists.txt
Normal file
29
compiler/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
project(zamacompiler LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(MLIR REQUIRED CONFIG)
|
||||
message(STATUS "Using MLIR cmake file from: ${MLIR_DIR}")
|
||||
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
message(STATUS "Using LLVM cmake file from: ${LLVM_DIR}")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
|
||||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
||||
include(TableGen)
|
||||
include(AddLLVM)
|
||||
include(AddMLIR)
|
||||
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
include_directories(${MLIR_INCLUDE_DIRS})
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||
link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(src)
|
||||
19
compiler/README.md
Normal file
19
compiler/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Building the compiler
|
||||
|
||||
Generate the compiler build system, in the `build` directory
|
||||
|
||||
```sh
|
||||
cmake -B build . -DLLVM_DIR=$LLVM_PROJECT/build/lib/cmake/llvm -DMLIR_DIR=$LLVM_PROJECT/build/lib/cmake/mlir
|
||||
```
|
||||
|
||||
Build the compiler
|
||||
|
||||
```sh
|
||||
make -C build/ zamacompiler
|
||||
```
|
||||
|
||||
Run the compiler
|
||||
|
||||
```sh
|
||||
./build/src/zamacompiler
|
||||
```
|
||||
1
compiler/include/CMakeLists.txt
Normal file
1
compiler/include/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(zamalang)
|
||||
1
compiler/include/zamalang/CMakeLists.txt
Normal file
1
compiler/include/zamalang/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(Dialect)
|
||||
1
compiler/include/zamalang/Dialect/CMakeLists.txt
Normal file
1
compiler/include/zamalang/Dialect/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(HLFHE)
|
||||
1
compiler/include/zamalang/Dialect/HLFHE/CMakeLists.txt
Normal file
1
compiler/include/zamalang/Dialect/HLFHE/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(IR)
|
||||
@@ -0,0 +1,3 @@
|
||||
add_mlir_dialect(HLFHEOps HLFHE)
|
||||
add_mlir_doc(HLFHEDialect -gen-dialect-doc HLFHEDialect zamalang/)
|
||||
add_mlir_doc(HLFHEOps -gen-op-doc HLFHEOps zamalang/)
|
||||
13
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEDialect.h
Normal file
13
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEDialect.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ZAMALANG_DIALECT_HLFHE_HLFHE_DIALECT_H
|
||||
#define ZAMALANG_DIALECT_HLFHE_HLFHE_DIALECT_H
|
||||
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOpsDialect.h.inc"
|
||||
|
||||
#endif
|
||||
23
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEDialect.td
Normal file
23
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEDialect.td
Normal file
@@ -0,0 +1,23 @@
|
||||
//===- HLFHEDialect.td - HLFHE dialect ----------------*- tablegen -*-===//
|
||||
//
|
||||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef ZAMALANG_DIALECT_HLFHE_IR_HLFHE_DIALECT
|
||||
#define ZAMALANG_DIALECT_HLFHE_IR_HLFHE_DIALECT
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
def HLFHE_Dialect : Dialect {
|
||||
let name = "HLFHE";
|
||||
let summary = "High Level Fully Homorphic Encryption dialect";
|
||||
let description = [{
|
||||
A dialect for representation of high level operation on fully homomorphic ciphertext.
|
||||
}];
|
||||
let cppNamespace = "::mlir::zamalang::HLFHE";
|
||||
}
|
||||
|
||||
#endif
|
||||
10
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEOps.h
Normal file
10
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEOps.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef ZAMALANG_DIALECT_HLFHE_HLFHE_OPS_H
|
||||
#define ZAMALANG_DIALECT_HLFHE_HLFHE_OPS_H
|
||||
|
||||
#include <mlir/IR/BuiltinOps.h>
|
||||
#include <mlir/IR/BuiltinTypes.h>
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.h.inc"
|
||||
|
||||
#endif
|
||||
17
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEOps.td
Normal file
17
compiler/include/zamalang/Dialect/HLFHE/IR/HLFHEOps.td
Normal file
@@ -0,0 +1,17 @@
|
||||
//===- HLFHEOps.td - High level FHE dialect ops ----------------*- tablegen -*-===//
|
||||
//
|
||||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef ZAMALANG_DIALECT_HLFHE_IR_HLFHE_OPS
|
||||
#define ZAMALANG_DIALECT_HLFHE_IR_HLFHE_OPS
|
||||
|
||||
include "zamalang/Dialect/HLFHE/IR/HLFHEDialect.td"
|
||||
|
||||
class HLFHE_Op<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<HLFHE_Dialect, mnemonic, traits>;
|
||||
|
||||
#endif
|
||||
1
compiler/lib/CMakeLists.txt
Normal file
1
compiler/lib/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(Dialect)
|
||||
1
compiler/lib/Dialect/CMakeLists.txt
Normal file
1
compiler/lib/Dialect/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(HLFHE)
|
||||
1
compiler/lib/Dialect/HLFHE/CMakeLists.txt
Normal file
1
compiler/lib/Dialect/HLFHE/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(IR)
|
||||
14
compiler/lib/Dialect/HLFHE/IR/CMakeLists.txt
Normal file
14
compiler/lib/Dialect/HLFHE/IR/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
add_mlir_dialect_library(HLFHEDialect
|
||||
HLFHEDialect.cpp
|
||||
HLFHEOps.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${PROJECT_SOURCE_DIR}/include/zamalang/Dialect/HLFHE
|
||||
|
||||
DEPENDS
|
||||
MLIRHLFHEOpsIncGen
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRIR)
|
||||
|
||||
target_link_libraries(HLFHEDialect PUBLIC MLIRIR)
|
||||
11
compiler/lib/Dialect/HLFHE/IR/HLFHEDialect.cpp
Normal file
11
compiler/lib/Dialect/HLFHE/IR/HLFHEDialect.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEDialect.h"
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.h"
|
||||
|
||||
using namespace mlir::zamalang::HLFHE;
|
||||
|
||||
void HLFHEDialect::initialize() {
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.cpp.inc"
|
||||
>();
|
||||
}
|
||||
4
compiler/lib/Dialect/HLFHE/IR/HLFHEOps.cpp
Normal file
4
compiler/lib/Dialect/HLFHE/IR/HLFHEOps.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.h"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.cpp.inc"
|
||||
9
compiler/src/CMakeLists.txt
Normal file
9
compiler/src/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
add_llvm_tool(zamacompiler main.cpp)
|
||||
|
||||
llvm_update_compile_flags(zamacompiler)
|
||||
target_link_libraries(zamacompiler
|
||||
PRIVATE
|
||||
MLIRTransforms
|
||||
HLFHEDialect)
|
||||
|
||||
mlir_check_all_link_libraries(zamacompiler)
|
||||
24
compiler/src/main.cpp
Normal file
24
compiler/src/main.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEDialect.h"
|
||||
#include "zamalang/Dialect/HLFHE/IR/HLFHEOps.h"
|
||||
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
|
||||
#include <mlir/Dialect/StandardOps/IR/Ops.h>
|
||||
#include <mlir/IR/Builders.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
mlir::MLIRContext context;
|
||||
|
||||
// Load our Dialect in this MLIR Context.
|
||||
context.getOrLoadDialect<mlir::zamalang::HLFHE::HLFHEDialect>();
|
||||
context.getOrLoadDialect<mlir::StandardOpsDialect>();
|
||||
|
||||
mlir::OpBuilder builder(&context);
|
||||
|
||||
mlir::ModuleOp module = mlir::ModuleOp::create(builder.getUnknownLoc());
|
||||
|
||||
module.dump();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user