Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more memory management built-ins #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/BuiltinsAssigner.def
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
// letters: https://github.com/NilFoundation/zkllvm-circifier/blob/master/clang/include/clang/Basic/Builtins.def#L20
// numbers: https://github.com/NilFoundation/zkllvm-circifier/blob/master/clang/lib/AST/ASTContext.cpp#L11086-L11118
BUILTIN(__builtin_assigner_malloc, "v*z", "n")
BUILTIN(__builtin_assigner_aligned_alloc, "v*zz", "n")
BUILTIN(__builtin_assigner_calloc, "v*zz", "n")
BUILTIN(__builtin_assigner_realloc, "v*v*z", "n")
BUILTIN(__builtin_assigner_free, "vv*", "n")
BUILTIN(__builtin_assigner_poseidon_pallas_base, "E3g1E3g1", "n")
BUILTIN(__builtin_assigner_sha2_256_pallas_base, "E2g1E2g1E2g1", "n")
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20563,6 +20563,15 @@ Value *CodeGenFunction::EmitAssignerBuiltinExpr(unsigned int BuiltinID,
case assigner::BI__builtin_assigner_malloc:
ID = Intrinsic::assigner_malloc;
break;
case assigner::BI__builtin_assigner_aligned_alloc:
ID = Intrinsic::assigner_aligned_alloc;
break;
case assigner::BI__builtin_assigner_calloc:
ID = Intrinsic::assigner_calloc;
break;
case assigner::BI__builtin_assigner_realloc:
ID = Intrinsic::assigner_realloc;
break;
case assigner::BI__builtin_assigner_free:
ID = Intrinsic::assigner_free;
break;
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 @@ -11,6 +11,9 @@
//===----------------------------------------------------------------------===//

def int_assigner_malloc: Intrinsic<[llvm_ptr_ty], [llvm_i64_ty]>;
def int_assigner_aligned_alloc: Intrinsic<[llvm_ptr_ty], [llvm_i64_ty, llvm_i64_ty]>;
def int_assigner_calloc: Intrinsic<[llvm_ptr_ty], [llvm_i64_ty, llvm_i64_ty]>;
def int_assigner_realloc: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i64_ty]>;
def int_assigner_free: Intrinsic<[], [llvm_ptr_ty]>;
def int_assigner_poseidon: Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>]>;
def int_assigner_sha2_256: Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
Expand Down