diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-12-30 02:22:16 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-12-30 02:22:16 +0000 |
commit | 979aff6399a79d155e98bbbe064f4a183a237f23 (patch) | |
tree | f56d4513e8f4f7f01799355c129b696891290ebd | |
parent | a51edf0986567bd81e261950f75a72b7462b2274 (diff) | |
download | external_llvm-979aff6399a79d155e98bbbe064f4a183a237f23.zip external_llvm-979aff6399a79d155e98bbbe064f4a183a237f23.tar.gz external_llvm-979aff6399a79d155e98bbbe064f4a183a237f23.tar.bz2 |
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
-rw-r--r-- | lib/VMCore/AttributeImpl.h | 22 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 12 |
2 files changed, 29 insertions, 5 deletions
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 LLVMContext; //===----------------------------------------------------------------------===// /// \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 @@ public: 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 @@ uint64_t AttrBuilder::getStackAlignment() const { 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)) |