|
6 | 6 | #include "llvm/IR/GlobalVariable.h" |
7 | 7 | #include "llvm/IR/Instructions.h" |
8 | 8 | #include "llvm/IR/Intrinsics.h" |
| 9 | +#include "llvm/IR/IntrinsicsARM.h" |
9 | 10 | #include "llvm/IR/Mangler.h" |
10 | 11 | #include "llvm/Object/Archive.h" |
11 | 12 | #include "llvm/Object/COFFImportFile.h" |
@@ -300,6 +301,14 @@ extern "C" LLVMAttributeRef LLVMRustCreateStructRetAttr(LLVMContextRef C, LLVMTy |
300 | 301 | return wrap(Attribute::getWithStructRetType(*unwrap(C), unwrap(Ty))); |
301 | 302 | } |
302 | 303 |
|
| 304 | +extern "C" LLVMAttributeRef LLVMRustCreateElementTypeAttr(LLVMContextRef C, LLVMTypeRef Ty) { |
| 305 | +#if LLVM_VERSION_GE(15, 0) |
| 306 | + return wrap(Attribute::get(*unwrap(C), Attribute::ElementType, unwrap(Ty))); |
| 307 | +#else |
| 308 | + report_fatal_error("Should not be needed on LLVM < 15"); |
| 309 | +#endif |
| 310 | +} |
| 311 | + |
303 | 312 | extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Async) { |
304 | 313 | #if LLVM_VERSION_LT(15, 0) |
305 | 314 | return wrap(Attribute::get(*unwrap(C), Attribute::UWTable)); |
@@ -1943,3 +1952,16 @@ extern "C" LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx) { |
1943 | 1952 | return wrap(unwrap<Constant>(C)->getAggregateElement(Idx)); |
1944 | 1953 | } |
1945 | 1954 | #endif |
| 1955 | + |
| 1956 | +extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) { |
| 1957 | +#if LLVM_VERSION_GE(15, 0) |
| 1958 | + auto *CB = unwrap<CallBase>(CallSite); |
| 1959 | + switch (CB->getIntrinsicID()) { |
| 1960 | + case Intrinsic::arm_ldrex: |
| 1961 | + return 0; |
| 1962 | + case Intrinsic::arm_strex: |
| 1963 | + return 1; |
| 1964 | + } |
| 1965 | +#endif |
| 1966 | + return -1; |
| 1967 | +} |
0 commit comments