diff options
author | Meghan Denny <hello@nektro.net> | 2023-02-15 09:47:32 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-02-15 09:57:01 +0100 |
commit | 35276f16e5a2cae0dfb49c0fbf874d4d2f177acc (patch) | |
tree | f860bed3916fa485cce5f83fc0652fd27002fc8a /llvm/lib/IR/Core.cpp | |
parent | 71712440bbb26b8e1789372024c3a14428b68eae (diff) | |
download | llvm-35276f16e5a2cae0dfb49c0fbf874d4d2f177acc.zip llvm-35276f16e5a2cae0dfb49c0fbf874d4d2f177acc.tar.gz llvm-35276f16e5a2cae0dfb49c0fbf874d4d2f177acc.tar.bz2 |
[llvm-c] Add C API methods to match 64bit ArrayType C++ API signatures
Fixes https://github.com/llvm/llvm-project/issues/56496.
As mentioned in the issue, new functions LLVMArrayType2 and
LLVMGetArrayLength2 are created so as to not break the old API.
The old methods are then marked as deprecated and callers are
updated.
Differential Revision: https://reviews.llvm.org/D143700
Diffstat (limited to 'llvm/lib/IR/Core.cpp')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index a93fc85..a0fade9 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -788,6 +788,10 @@ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); } +LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount) { + return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); +} + LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) { return wrap(PointerType::get(unwrap(ElementType), AddressSpace)); } @@ -822,6 +826,10 @@ unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy) { return unwrap<ArrayType>(ArrayTy)->getNumElements(); } +uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy) { + return unwrap<ArrayType>(ArrayTy)->getNumElements(); +} + unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy) { return unwrap<PointerType>(PointerTy)->getAddressSpace(); } @@ -1493,6 +1501,12 @@ LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V)); } +LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, + uint64_t Length) { + ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length); + return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V)); +} + LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed) { |