aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-07-14 21:09:06 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-07-14 21:10:56 +0200
commitcd88a01cb8e90b5eae9f8bde82ff362b222a61c4 (patch)
tree2f33a277fde8e2b93baf4eb515ba51f883ad1b42 /llvm/lib/IR/Attributes.cpp
parenta4856c739c570d5115d0b7646a58b918890d37d4 (diff)
downloadllvm-cd88a01cb8e90b5eae9f8bde82ff362b222a61c4.zip
llvm-cd88a01cb8e90b5eae9f8bde82ff362b222a61c4.tar.gz
llvm-cd88a01cb8e90b5eae9f8bde82ff362b222a61c4.tar.bz2
[Attributes] Use single method to fetch type from AttributeSet (NFC)
While it is nice to have separate methods in the public AttributeSet API, we can fetch the type from the internal AttributeSetNode using a generic API for all type attribute kinds.
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r--llvm/lib/IR/Attributes.cpp38
1 files changed, 7 insertions, 31 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 31cef09..368fc87 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -689,23 +689,23 @@ uint64_t AttributeSet::getDereferenceableOrNullBytes() const {
}
Type *AttributeSet::getByRefType() const {
- return SetNode ? SetNode->getByRefType() : nullptr;
+ return SetNode ? SetNode->getAttributeType(Attribute::ByRef) : nullptr;
}
Type *AttributeSet::getByValType() const {
- return SetNode ? SetNode->getByValType() : nullptr;
+ return SetNode ? SetNode->getAttributeType(Attribute::ByVal) : nullptr;
}
Type *AttributeSet::getStructRetType() const {
- return SetNode ? SetNode->getStructRetType() : nullptr;
+ return SetNode ? SetNode->getAttributeType(Attribute::StructRet) : nullptr;
}
Type *AttributeSet::getPreallocatedType() const {
- return SetNode ? SetNode->getPreallocatedType() : nullptr;
+ return SetNode ? SetNode->getAttributeType(Attribute::Preallocated) : nullptr;
}
Type *AttributeSet::getInAllocaType() const {
- return SetNode ? SetNode->getInAllocaType() : nullptr;
+ return SetNode ? SetNode->getAttributeType(Attribute::InAlloca) : nullptr;
}
std::pair<unsigned, Optional<unsigned>> AttributeSet::getAllocSizeArgs() const {
@@ -897,32 +897,8 @@ MaybeAlign AttributeSetNode::getStackAlignment() const {
return None;
}
-Type *AttributeSetNode::getByValType() const {
- if (auto A = findEnumAttribute(Attribute::ByVal))
- return A->getValueAsType();
- return nullptr;
-}
-
-Type *AttributeSetNode::getStructRetType() const {
- if (auto A = findEnumAttribute(Attribute::StructRet))
- return A->getValueAsType();
- return nullptr;
-}
-
-Type *AttributeSetNode::getByRefType() const {
- if (auto A = findEnumAttribute(Attribute::ByRef))
- return A->getValueAsType();
- return nullptr;
-}
-
-Type *AttributeSetNode::getPreallocatedType() const {
- if (auto A = findEnumAttribute(Attribute::Preallocated))
- return A->getValueAsType();
- return nullptr;
-}
-
-Type *AttributeSetNode::getInAllocaType() const {
- if (auto A = findEnumAttribute(Attribute::InAlloca))
+Type *AttributeSetNode::getAttributeType(Attribute::AttrKind Kind) const {
+ if (auto A = findEnumAttribute(Kind))
return A->getValueAsType();
return nullptr;
}