Skip to content

Commit

Permalink
Bit composition builtins added. #61
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Jul 14, 2023
1 parent 3f8f307 commit f526484
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/BuiltinsAssigner.def
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ BUILTIN(__builtin_assigner_vesta_curve_init, "e2g7g7", "n")
BUILTIN(__builtin_assigner_bls12381_curve_init, "e3g3g3", "n")
BUILTIN(__builtin_assigner_curve25519_curve_init, "e4g5g5", "n")

BUILTIN(__builtin_assigner_bit_decomposition64, "E64g1g1", "n")
BUILTIN(__builtin_assigner_bit_composition128, "g1E64g1E64g1", "n")

#undef BUILTIN
#undef TARGET_BUILTIN
15 changes: 15 additions & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19908,6 +19908,21 @@ Value *CodeGenFunction::EmitAssignerBuiltinExpr(unsigned int BuiltinID,
OverloadTypes = {Curve, BaseField};
break;
}
case assigner::BI__builtin_assigner_bit_composition128: {
ID = Intrinsic::assigner_bit_composition128;
auto ElemTy = llvm::GaloisFieldType::get(context,
llvm::GALOIS_FIELD_PALLAS_BASE);

OverloadTypes = {ElemTy, llvm::FixedVectorType::get(ElemTy, 64)};
break;
}
case assigner::BI__builtin_assigner_bit_decomposition64: {
ID = Intrinsic::assigner_bit_decomposition64;
auto ElemTy = llvm::GaloisFieldType::get(context,
llvm::GALOIS_FIELD_PALLAS_BASE);
OverloadTypes = {llvm::FixedVectorType::get(ElemTy, 64), ElemTy};
break;
}
}

assert(ID != Intrinsic::not_intrinsic);
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsAssigner.td
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ def int_assigner_zkml_pooling: Intrinsic<[llvm_ptrptr_ty], [llvm_ptrptr_t
def int_assigner_zkml_ReLU: Intrinsic<[llvm_float_ty], [llvm_float_ty]>;
def int_assigner_zkml_batch_norm: Intrinsic<[llvm_ptrptr_ty], [llvm_ptrptr_ty]>;
def int_assigner_curve_init: Intrinsic<[llvm_any_ty], [llvm_any_ty, LLVMMatchType<1>]>;

def int_assigner_bit_decomposition64: Intrinsic<[llvm_anyvector_ty], [llvm_any_ty]>;
def int_assigner_bit_composition128: Intrinsic<[llvm_any_ty], [llvm_anyvector_ty, LLVMMatchType<1>]>;

0 comments on commit f526484

Please sign in to comment.