X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FAttributeImpl.h;h=0448dc17409e9e063ccbc34d39b96864fa46b601;hb=540b4f6c08a089f487edad2befb7caf98c127ac5;hp=5a72c37505e1769e25ad4cbc91f579b385007430;hpb=e22cde01a63c907cb23f425ba4f4f16ede754dbe;p=oota-llvm.git diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index 5a72c37505e..0448dc17409 100644 --- a/lib/IR/AttributeImpl.h +++ b/lib/IR/AttributeImpl.h @@ -13,8 +13,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_ATTRIBUTESIMPL_H -#define LLVM_ATTRIBUTESIMPL_H +#ifndef LLVM_LIB_IR_ATTRIBUTEIMPL_H +#define LLVM_LIB_IR_ATTRIBUTEIMPL_H #include "llvm/ADT/FoldingSet.h" #include "llvm/IR/Attributes.h" @@ -39,7 +39,7 @@ class AttributeImpl : public FoldingSetNode { protected: enum AttrEntryKind { EnumAttrEntry, - AlignAttrEntry, + IntAttrEntry, StringAttrEntry }; @@ -49,7 +49,7 @@ public: virtual ~AttributeImpl(); bool isEnumAttribute() const { return KindID == EnumAttrEntry; } - bool isAlignAttribute() const { return KindID == AlignAttrEntry; } + bool isIntAttribute() const { return KindID == IntAttrEntry; } bool isStringAttribute() const { return KindID == StringAttrEntry; } bool hasAttribute(Attribute::AttrKind A) const; @@ -67,7 +67,7 @@ public: void Profile(FoldingSetNodeID &ID) const { if (isEnumAttribute()) Profile(ID, getKindAsEnum(), 0); - else if (isAlignAttribute()) + else if (isIntAttribute()) Profile(ID, getKindAsEnum(), getValueAsInt()); else Profile(ID, getKindAsString(), getValueAsString()); @@ -94,6 +94,7 @@ public: /// attribute enties, which are for target-dependent attributes. class EnumAttributeImpl : public AttributeImpl { + virtual void anchor(); Attribute::AttrKind Kind; protected: @@ -107,21 +108,24 @@ public: Attribute::AttrKind getEnumKind() const { return Kind; } }; -class AlignAttributeImpl : public EnumAttributeImpl { - unsigned Align; +class IntAttributeImpl : public EnumAttributeImpl { + void anchor() override; + uint64_t Val; public: - AlignAttributeImpl(Attribute::AttrKind Kind, unsigned Align) - : EnumAttributeImpl(AlignAttrEntry, Kind), Align(Align) { + IntAttributeImpl(Attribute::AttrKind Kind, uint64_t Val) + : EnumAttributeImpl(IntAttrEntry, Kind), Val(Val) { assert( - (Kind == Attribute::Alignment || Kind == Attribute::StackAlignment) && - "Wrong kind for alignment attribute!"); + (Kind == Attribute::Alignment || Kind == Attribute::StackAlignment || + Kind == Attribute::Dereferenceable) && + "Wrong kind for int attribute!"); } - unsigned getAlignment() const { return Align; } + uint64_t getValue() const { return Val; } }; class StringAttributeImpl : public AttributeImpl { + virtual void anchor(); std::string Kind; std::string Val; @@ -161,6 +165,7 @@ public: unsigned getAlignment() const; unsigned getStackAlignment() const; + uint64_t getDereferenceableBytes() const; std::string getAsString(bool InAttrGrp) const; typedef const Attribute *iterator; @@ -200,6 +205,15 @@ public: AttributeSetImpl(LLVMContext &C, ArrayRef > Attrs) : Context(C), NumAttrs(Attrs.size()) { +#ifndef NDEBUG + if (Attrs.size() >= 2) { + for (const std::pair *i = Attrs.begin() + 1, + *e = Attrs.end(); + i != e; ++i) { + assert((i-1)->first <= i->first && "Attribute set not ordered!"); + } + } +#endif // There's memory after the node where we can store the entries in. std::copy(Attrs.begin(), Attrs.end(), reinterpret_cast(this + 1)); @@ -249,6 +263,8 @@ public: // FIXME: This atrocity is temporary. uint64_t Raw(unsigned Index) const; + + void dump() const; }; } // end llvm namespace