feat(compiler): Add operation HLFHE.zero generating an encrypted zero

This commit is contained in:
Andi Drebes
2021-07-30 14:47:50 +02:00
committed by Quentin Bourgerie
parent 8796754513
commit cb580f16d2
2 changed files with 15 additions and 0 deletions

View File

@@ -18,6 +18,12 @@ include "zamalang/Dialect/HLFHE/IR/HLFHETypes.td"
class HLFHE_Op<string mnemonic, list<OpTrait> traits = []> :
Op<HLFHE_Dialect, mnemonic, traits>;
// Generates an encrypted zero constant
def ZeroOp : HLFHE_Op<"zero"> {
let arguments = (ins);
let results = (outs EncryptedIntegerType:$out);
}
def AddEintIntOp : HLFHE_Op<"add_eint_int"> {
let arguments = (ins EncryptedIntegerType:$a, AnyInteger:$b);
let results = (outs EncryptedIntegerType);

View File

@@ -1,5 +1,14 @@
// RUN: zamacompiler --round-trip %s 2>&1| FileCheck %s
// CHECK-LABEL: func @zero() -> !HLFHE.eint<2>
func @zero() -> !HLFHE.eint<2> {
// CHECK-NEXT: %[[RET:.*]] = "HLFHE.zero"() : () -> !HLFHE.eint<2>
// CHECK-NEXT: return %[[RET]] : !HLFHE.eint<2>
%1 = "HLFHE.zero"() : () -> !HLFHE.eint<2>
return %1: !HLFHE.eint<2>
}
// CHECK-LABEL: func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2>
func @add_eint_int(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> {
// CHECK-NEXT: %[[V1:.*]] = constant 1 : i3