Add a few more c'tors:
* One that accepts a single Attribute::AttrKind.
* One that accepts an Attribute::AttrKind plus a list of values. This is for
attributes defined like this:
#1 = attributes { align = 4 }
* One that accepts a string, for target-specific attributes like this:
#2 = attributes { "cpu=cortex-a8" }
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171249 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/AttributeImpl.h b/lib/VMCore/AttributeImpl.h
index 38eef6f..cab1c94 100644
--- a/lib/VMCore/AttributeImpl.h
+++ b/lib/VMCore/AttributeImpl.h
@@ -27,12 +27,20 @@
//===----------------------------------------------------------------------===//
/// \class
/// \brief This class represents a single, uniqued attribute. That attribute
-/// could be a single enum, a tuple, or a string. It uses a discriminated union
-/// to distinguish them.
+/// could be a single enum, a tuple, or a string.
class AttributeImpl : public FoldingSetNode {
Constant *Data;
+ SmallVector<Constant*, 0> Vals;
public:
- AttributeImpl(LLVMContext &C, uint64_t data);
+ explicit AttributeImpl(LLVMContext &C, uint64_t data);
+ explicit AttributeImpl(LLVMContext &C, Attribute::AttrKind data);
+ AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
+ ArrayRef<Constant*> values);
+ AttributeImpl(LLVMContext &C, StringRef data);
+
+ ArrayRef<Constant*> getValues() const {
+ return Vals;
+ }
bool contains(Attribute::AttrKind Kind) const;
bool contains(StringRef Kind) const;
@@ -64,10 +72,14 @@
static uint64_t getAttrMask(uint64_t Val);
void Profile(FoldingSetNodeID &ID) const {
- Profile(ID, Data);
+ Profile(ID, Data, Vals);
}
- static void Profile(FoldingSetNodeID &ID, Constant *Data) {
+ static void Profile(FoldingSetNodeID &ID, Constant *Data,
+ ArrayRef<Constant*> Vals) {
ID.AddPointer(Data);
+ for (ArrayRef<Constant*>::iterator I = Vals.begin(), E = Vals.end();
+ I != E; ++I)
+ ID.AddPointer(*I);
}
};
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index 52405f2..0db1eb5 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -301,6 +301,18 @@
AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
Data = ConstantInt::get(Type::getInt64Ty(C), data);
}
+AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data) {
+ Data = ConstantInt::get(Type::getInt64Ty(C), data);
+}
+AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
+ ArrayRef<Constant*> values) {
+ Data = ConstantInt::get(Type::getInt64Ty(C), data);
+ Vals.reserve(values.size());
+ Vals.append(values.begin(), values.end());
+}
+AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
+ Data = ConstantDataArray::getString(C, data);
+}
bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))