diff options
author | Nikita Popov <npopov@redhat.com> | 2022-10-31 10:34:51 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-10-31 10:44:51 +0100 |
commit | a2ab8fc46c63e6d21b6648202907a33064fbfb6e (patch) | |
tree | 77281cf0e05d7277606a4eeb74c86d082e6ef6be /llvm/lib/IR/Attributes.cpp | |
parent | df23ede2f117c8a6483cf6cded09fa63f1deda23 (diff) | |
download | llvm-a2ab8fc46c63e6d21b6648202907a33064fbfb6e.zip llvm-a2ab8fc46c63e6d21b6648202907a33064fbfb6e.tar.gz llvm-a2ab8fc46c63e6d21b6648202907a33064fbfb6e.tar.bz2 |
[Attributes] Add additional MemoryEffects APIs (NFC)
This adds the usual complement of APIs for creating and fetching
a non-trivial attribute.
Split out from D135780.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 333caf7..fc5d274 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -211,6 +211,11 @@ Attribute Attribute::getWithUWTableKind(LLVMContext &Context, return get(Context, UWTable, uint64_t(Kind)); } +Attribute Attribute::getWithMemoryEffects(LLVMContext &Context, + MemoryEffects ME) { + return get(Context, Memory, ME.toIntValue()); +} + Attribute Attribute::getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional<unsigned> &NumElemsArg) { @@ -831,6 +836,10 @@ AllocFnKind AttributeSet::getAllocKind() const { return SetNode ? SetNode->getAllocKind() : AllocFnKind::Unknown; } +MemoryEffects AttributeSet::getMemoryEffects() const { + return SetNode ? SetNode->getMemoryEffects() : MemoryEffects::unknown(); +} + std::string AttributeSet::getAsString(bool InAttrGrp) const { return SetNode ? SetNode->getAsString(InAttrGrp) : ""; } @@ -1009,6 +1018,12 @@ AllocFnKind AttributeSetNode::getAllocKind() const { return AllocFnKind::Unknown; } +MemoryEffects AttributeSetNode::getMemoryEffects() const { + if (auto A = findEnumAttribute(Attribute::Memory)) + return A->getMemoryEffects(); + return MemoryEffects::unknown(); +} + std::string AttributeSetNode::getAsString(bool InAttrGrp) const { std::string Str; for (iterator I = begin(), E = end(); I != E; ++I) { @@ -1561,6 +1576,10 @@ AllocFnKind AttributeList::getAllocKind() const { return getFnAttrs().getAllocKind(); } +MemoryEffects AttributeList::getMemoryEffects() const { + return getFnAttrs().getMemoryEffects(); +} + std::string AttributeList::getAsString(unsigned Index, bool InAttrGrp) const { return getAttributes(Index).getAsString(InAttrGrp); } |