LLVM 16: Switch to using MemoryEffects
This commit is contained in:
parent
47c008e440
commit
c15cfc91c4
8 changed files with 67 additions and 12 deletions
|
@ -8,6 +8,9 @@
|
|||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/IntrinsicsARM.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
#include "llvm/IR/ModRef.h"
|
||||
#endif
|
||||
#include "llvm/Object/Archive.h"
|
||||
#include "llvm/Object/COFFImportFile.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
|
@ -213,8 +216,6 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
|
|||
return Attribute::ReturnsTwice;
|
||||
case ReadNone:
|
||||
return Attribute::ReadNone;
|
||||
case InaccessibleMemOnly:
|
||||
return Attribute::InaccessibleMemOnly;
|
||||
case SanitizeHWAddress:
|
||||
return Attribute::SanitizeHWAddress;
|
||||
case WillReturn:
|
||||
|
@ -379,6 +380,43 @@ extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C, uint64
|
|||
#endif
|
||||
}
|
||||
|
||||
// Simplified representation of `MemoryEffects` across the FFI boundary.
|
||||
//
|
||||
// Each variant corresponds to one of the static factory methods on `MemoryEffects`.
|
||||
enum class LLVMRustMemoryEffects {
|
||||
None,
|
||||
ReadOnly,
|
||||
InaccessibleMemOnly,
|
||||
};
|
||||
|
||||
extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
|
||||
LLVMRustMemoryEffects Effects) {
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
switch (Effects) {
|
||||
case LLVMRustMemoryEffects::None:
|
||||
return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none()));
|
||||
case LLVMRustMemoryEffects::ReadOnly:
|
||||
return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::readOnly()));
|
||||
case LLVMRustMemoryEffects::InaccessibleMemOnly:
|
||||
return wrap(Attribute::getWithMemoryEffects(*unwrap(C),
|
||||
MemoryEffects::inaccessibleMemOnly()));
|
||||
default:
|
||||
report_fatal_error("bad MemoryEffects.");
|
||||
}
|
||||
#else
|
||||
switch (Effects) {
|
||||
case LLVMRustMemoryEffects::None:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::ReadNone));
|
||||
case LLVMRustMemoryEffects::ReadOnly:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::ReadOnly));
|
||||
case LLVMRustMemoryEffects::InaccessibleMemOnly:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::InaccessibleMemOnly));
|
||||
default:
|
||||
report_fatal_error("bad MemoryEffects.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable a fast-math flag
|
||||
//
|
||||
// https://llvm.org/docs/LangRef.html#fast-math-flags
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue