mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
feat(compiler): Add !HLFHE.ciphertext
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef ZAMALANG_DIALECT_MidLFHE_IR_MidLFHE_TYPES
|
||||
#define ZAMALANG_DIALECT_MidLFHE_IR_MidLFHE_TYPES
|
||||
|
||||
// TODO: MLWE / GSW
|
||||
|
||||
include "zamalang/Dialect/MidLFHE/IR/MidLFHEDialect.td"
|
||||
|
||||
class MidLFHE_Type<string name> : TypeDef<MidLFHE_Dialect, name> { }
|
||||
@@ -112,4 +114,31 @@ def GGSWCipherTextType : MidLFHE_Type<"GGSWCipherText"> {
|
||||
}];
|
||||
}
|
||||
|
||||
def AnyCipherTextType : MidLFHE_Type<"AnyCipherText"> {
|
||||
let mnemonic = "ciphertext";
|
||||
|
||||
let summary = "Any cipher text";
|
||||
|
||||
let description = [{
|
||||
Any cipher text
|
||||
}];
|
||||
|
||||
// We define the printer inline.
|
||||
let printer = [{
|
||||
$_printer << "ciphertext";
|
||||
}];
|
||||
|
||||
// The parser is defined here also.
|
||||
let parser = [{
|
||||
return get($_ctxt);
|
||||
}];
|
||||
}
|
||||
|
||||
def CipherTextType: TypeConstraint<Or<[
|
||||
LWECipherTextType.predicate,
|
||||
GLWECipherTextType.predicate,
|
||||
GGSWCipherTextType.predicate,
|
||||
AnyCipherTextType.predicate,
|
||||
]>, "ciphertext-like">;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,9 @@ void MidLFHEDialect::initialize() {
|
||||
return GLWECipherTextType::parse(this->getContext(), parser);
|
||||
if(parser.parseOptionalKeyword("ggsw").succeeded())
|
||||
return GGSWCipherTextType::parse(this->getContext(), parser);
|
||||
if(parser.parseOptionalKeyword("ciphertext").succeeded())
|
||||
return AnyCipherTextType::parse(this->getContext(), parser);
|
||||
parser.emitError(parser.getCurrentLocation(), "Unknown MidLFHE type");
|
||||
return ::mlir::Type();
|
||||
}
|
||||
|
||||
@@ -48,6 +51,11 @@ void MidLFHEDialect::printType(::mlir::Type type,
|
||||
ggsw.print(printer);
|
||||
return;
|
||||
}
|
||||
mlir::zamalang::MidLFHE::AnyCipherTextType any = type.dyn_cast_or_null<mlir::zamalang::MidLFHE::AnyCipherTextType>();
|
||||
if (any != nullptr) {
|
||||
any.print(printer);
|
||||
return;
|
||||
}
|
||||
// TODO - What should be done here?
|
||||
printer << "unknwontype";
|
||||
}
|
||||
7
compiler/tests/Dialect/MidLFHE/types_ciphertext.mlir
Normal file
7
compiler/tests/Dialect/MidLFHE/types_ciphertext.mlir
Normal file
@@ -0,0 +1,7 @@
|
||||
// RUN: zamacompiler %s 2>&1| FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @ciphertext(%arg0: !MidLFHE.ciphertext) -> !MidLFHE.ciphertext
|
||||
func @ciphertext(%arg0: !MidLFHE.ciphertext) -> !MidLFHE.ciphertext {
|
||||
// CHECK-LABEL: return %arg0 : !MidLFHE.ciphertext
|
||||
return %arg0: !MidLFHE.ciphertext
|
||||
}
|
||||
Reference in New Issue
Block a user