summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/IR/AttributeImpl.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-03-21 17:53:59 +0000
committerdim <dim@FreeBSD.org>2014-03-21 17:53:59 +0000
commit9cedb8bb69b89b0f0c529937247a6a80cabdbaec (patch)
treec978f0e9ec1ab92dc8123783f30b08a7fd1e2a39 /contrib/llvm/lib/IR/AttributeImpl.h
parent03fdc2934eb61c44c049a02b02aa974cfdd8a0eb (diff)
downloadFreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.zip
FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.tar.gz
MFC 261991:
Upgrade our copy of llvm/clang to 3.4 release. This version supports all of the features in the current working draft of the upcoming C++ standard, provisionally named C++1y. The code generator's performance is greatly increased, and the loop auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The PowerPC backend has made several major improvements to code generation quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ backends have all seen major feature work. Release notes for llvm and clang can be found here: <http://llvm.org/releases/3.4/docs/ReleaseNotes.html> <http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html> MFC 262121 (by emaste): Update lldb for clang/llvm 3.4 import This commit largely restores the lldb source to the upstream r196259 snapshot with the addition of threaded inferior support and a few bug fixes. Specific upstream lldb revisions restored include: SVN git 181387 779e6ac 181703 7bef4e2 182099 b31044e 182650 f2dcf35 182683 0d91b80 183862 15c1774 183929 99447a6 184177 0b2934b 184948 4dc3761 184954 007e7bc 186990 eebd175 Sponsored by: DARPA, AFRL MFC 262186 (by emaste): Fix mismerge in r262121 A break statement was lost in the merge. The error had no functional impact, but restore it to reduce the diff against upstream. MFC 262303: Pull in r197521 from upstream clang trunk (by rdivacky): Use the integrated assembler by default on FreeBSD/ppc and ppc64. Requested by: jhibbits MFC 262611: Pull in r196874 from upstream llvm trunk: Fix a crash that occurs when PWD is invalid. MCJIT needs to be able to run in hostile environments, even when PWD is invalid. There's no need to crash MCJIT in this case. The obvious fix is to simply leave MCContext's CompilationDir empty when PWD can't be determined. This way, MCJIT clients, and other clients that link with LLVM don't need a valid working directory. If we do want to guarantee valid CompilationDir, that should be done only for clients of getCompilationDir(). This is as simple as checking for an empty string. The only current use of getCompilationDir is EmitGenDwarfInfo, which won't conceivably run with an invalid working dir. However, in the purely hypothetically and untestable case that this happens, the AT_comp_dir will be omitted from the compilation_unit DIE. This should help fix assertions occurring with ports-mgmt/tinderbox, when it is using jails, and sometimes invalidates clang's current working directory. Reported by: decke MFC 262809: Pull in r203007 from upstream clang trunk: Don't produce an alias between destructors with different calling conventions. Fixes pr19007. (Please note that is an LLVM PR identifier, not a FreeBSD one.) This should fix Firefox and/or libxul crashes (due to problems with regparm/stdcall calling conventions) on i386. Reported by: multiple users on freebsd-current PR: bin/187103 MFC 263048: Repair recognition of "CC" as an alias for the C++ compiler, since it was silently broken by upstream for a Windows-specific use-case. Apparently some versions of CMake still rely on this archaic feature... Reported by: rakuco MFC 263049: Garbage collect the old way of adding the libstdc++ include directories in clang's InitHeaderSearch.cpp. This has been superseded by David Chisnall's commit in r255321. Moreover, if libc++ is used, the libstdc++ include directories should not be in the search path at all. These directories are now only used if you pass -stdlib=libstdc++.
Diffstat (limited to 'contrib/llvm/lib/IR/AttributeImpl.h')
-rw-r--r--contrib/llvm/lib/IR/AttributeImpl.h220
1 files changed, 106 insertions, 114 deletions
diff --git a/contrib/llvm/lib/IR/AttributeImpl.h b/contrib/llvm/lib/IR/AttributeImpl.h
index 0b6228b..ea954ac 100644
--- a/contrib/llvm/lib/IR/AttributeImpl.h
+++ b/contrib/llvm/lib/IR/AttributeImpl.h
@@ -27,97 +27,30 @@ class LLVMContext;
//===----------------------------------------------------------------------===//
/// \class
-/// \brief A set of classes that contain the kind and (optional) value of the
-/// attribute object. There are three main categories: enum attribute entries,
-/// represented by Attribute::AttrKind; alignment attribute entries; and string
-/// attribute enties, which are for target-dependent attributes.
-class AttributeEntry {
- unsigned char KindID;
+/// \brief This class represents a single, uniqued attribute. That attribute
+/// could be a single enum, a tuple, or a string.
+class AttributeImpl : public FoldingSetNode {
+ unsigned char KindID; ///< Holds the AttrEntryKind of the attribute
+
+ // AttributesImpl is uniqued, these should not be publicly available.
+ void operator=(const AttributeImpl &) LLVM_DELETED_FUNCTION;
+ AttributeImpl(const AttributeImpl &) LLVM_DELETED_FUNCTION;
+
protected:
enum AttrEntryKind {
EnumAttrEntry,
AlignAttrEntry,
StringAttrEntry
};
-public:
- AttributeEntry(AttrEntryKind Kind)
- : KindID(Kind) {}
- virtual ~AttributeEntry() {}
- unsigned getKindID() const { return KindID; }
+ AttributeImpl(AttrEntryKind KindID) : KindID(KindID) {}
- static inline bool classof(const AttributeEntry *) { return true; }
-};
-
-class EnumAttributeEntry : public AttributeEntry {
- Attribute::AttrKind Kind;
public:
- EnumAttributeEntry(Attribute::AttrKind Kind)
- : AttributeEntry(EnumAttrEntry), Kind(Kind) {}
-
- Attribute::AttrKind getEnumKind() const { return Kind; }
-
- static inline bool classof(const AttributeEntry *AE) {
- return AE->getKindID() == EnumAttrEntry;
- }
- static inline bool classof(const EnumAttributeEntry *) { return true; }
-};
+ virtual ~AttributeImpl();
-class AlignAttributeEntry : public AttributeEntry {
- Attribute::AttrKind Kind;
- unsigned Align;
-public:
- AlignAttributeEntry(Attribute::AttrKind Kind, unsigned Align)
- : AttributeEntry(AlignAttrEntry), Kind(Kind), Align(Align) {}
-
- Attribute::AttrKind getEnumKind() const { return Kind; }
- unsigned getAlignment() const { return Align; }
-
- static inline bool classof(const AttributeEntry *AE) {
- return AE->getKindID() == AlignAttrEntry;
- }
- static inline bool classof(const AlignAttributeEntry *) { return true; }
-};
-
-class StringAttributeEntry : public AttributeEntry {
- std::string Kind;
- std::string Val;
-public:
- StringAttributeEntry(StringRef Kind, StringRef Val = StringRef())
- : AttributeEntry(StringAttrEntry), Kind(Kind), Val(Val) {}
-
- StringRef getStringKind() const { return Kind; }
- StringRef getStringValue() const { return Val; }
-
- static inline bool classof(const AttributeEntry *AE) {
- return AE->getKindID() == StringAttrEntry;
- }
- static inline bool classof(const StringAttributeEntry *) { return true; }
-};
-
-//===----------------------------------------------------------------------===//
-/// \class
-/// \brief This class represents a single, uniqued attribute. That attribute
-/// could be a single enum, a tuple, or a string.
-class AttributeImpl : public FoldingSetNode {
- LLVMContext &Context; ///< Global context for uniquing objects
-
- AttributeEntry *Entry; ///< Holds the kind and value of the attribute
-
- // AttributesImpl is uniqued, these should not be publicly available.
- void operator=(const AttributeImpl &) LLVM_DELETED_FUNCTION;
- AttributeImpl(const AttributeImpl &) LLVM_DELETED_FUNCTION;
-public:
- AttributeImpl(LLVMContext &C, Attribute::AttrKind Kind);
- AttributeImpl(LLVMContext &C, Attribute::AttrKind Kind, unsigned Align);
- AttributeImpl(LLVMContext &C, StringRef Kind, StringRef Val = StringRef());
- ~AttributeImpl();
-
- LLVMContext &getContext() { return Context; }
-
- bool isEnumAttribute() const;
- bool isAlignAttribute() const;
- bool isStringAttribute() const;
+ bool isEnumAttribute() const { return KindID == EnumAttrEntry; }
+ bool isAlignAttribute() const { return KindID == AlignAttrEntry; }
+ bool isStringAttribute() const { return KindID == StringAttrEntry; }
bool hasAttribute(Attribute::AttrKind A) const;
bool hasAttribute(StringRef Kind) const;
@@ -155,13 +88,66 @@ public:
//===----------------------------------------------------------------------===//
/// \class
+/// \brief A set of classes that contain the value of the
+/// attribute object. There are three main categories: enum attribute entries,
+/// represented by Attribute::AttrKind; alignment attribute entries; and string
+/// attribute enties, which are for target-dependent attributes.
+
+class EnumAttributeImpl : public AttributeImpl {
+ virtual void anchor();
+ Attribute::AttrKind Kind;
+
+protected:
+ EnumAttributeImpl(AttrEntryKind ID, Attribute::AttrKind Kind)
+ : AttributeImpl(ID), Kind(Kind) {}
+
+public:
+ EnumAttributeImpl(Attribute::AttrKind Kind)
+ : AttributeImpl(EnumAttrEntry), Kind(Kind) {}
+
+ Attribute::AttrKind getEnumKind() const { return Kind; }
+};
+
+class AlignAttributeImpl : public EnumAttributeImpl {
+ virtual void anchor();
+ unsigned Align;
+
+public:
+ AlignAttributeImpl(Attribute::AttrKind Kind, unsigned Align)
+ : EnumAttributeImpl(AlignAttrEntry, Kind), Align(Align) {
+ assert(
+ (Kind == Attribute::Alignment || Kind == Attribute::StackAlignment) &&
+ "Wrong kind for alignment attribute!");
+ }
+
+ unsigned getAlignment() const { return Align; }
+};
+
+class StringAttributeImpl : public AttributeImpl {
+ virtual void anchor();
+ std::string Kind;
+ std::string Val;
+
+public:
+ StringAttributeImpl(StringRef Kind, StringRef Val = StringRef())
+ : AttributeImpl(StringAttrEntry), Kind(Kind), Val(Val) {}
+
+ StringRef getStringKind() const { return Kind; }
+ StringRef getStringValue() const { return Val; }
+};
+
+//===----------------------------------------------------------------------===//
+/// \class
/// \brief This class represents a group of attributes that apply to one
/// element: function, return type, or parameter.
class AttributeSetNode : public FoldingSetNode {
- SmallVector<Attribute, 4> AttrList;
+ unsigned NumAttrs; ///< Number of attributes in this node.
- AttributeSetNode(ArrayRef<Attribute> Attrs)
- : AttrList(Attrs.begin(), Attrs.end()) {}
+ AttributeSetNode(ArrayRef<Attribute> Attrs) : NumAttrs(Attrs.size()) {
+ // There's memory after the node where we can store the entries in.
+ std::copy(Attrs.begin(), Attrs.end(),
+ reinterpret_cast<Attribute *>(this + 1));
+ }
// AttributesSetNode is uniqued, these should not be publicly available.
void operator=(const AttributeSetNode &) LLVM_DELETED_FUNCTION;
@@ -171,7 +157,7 @@ public:
bool hasAttribute(Attribute::AttrKind Kind) const;
bool hasAttribute(StringRef Kind) const;
- bool hasAttributes() const { return !AttrList.empty(); }
+ bool hasAttributes() const { return NumAttrs != 0; }
Attribute getAttribute(Attribute::AttrKind Kind) const;
Attribute getAttribute(StringRef Kind) const;
@@ -180,17 +166,12 @@ public:
unsigned getStackAlignment() const;
std::string getAsString(bool InAttrGrp) const;
- typedef SmallVectorImpl<Attribute>::iterator iterator;
- typedef SmallVectorImpl<Attribute>::const_iterator const_iterator;
-
- iterator begin() { return AttrList.begin(); }
- iterator end() { return AttrList.end(); }
-
- const_iterator begin() const { return AttrList.begin(); }
- const_iterator end() const { return AttrList.end(); }
+ typedef const Attribute *iterator;
+ iterator begin() const { return reinterpret_cast<iterator>(this + 1); }
+ iterator end() const { return begin() + NumAttrs; }
void Profile(FoldingSetNodeID &ID) const {
- Profile(ID, AttrList);
+ Profile(ID, makeArrayRef(begin(), end()));
}
static void Profile(FoldingSetNodeID &ID, ArrayRef<Attribute> AttrList) {
for (unsigned I = 0, E = AttrList.size(); I != E; ++I)
@@ -208,58 +189,67 @@ class AttributeSetImpl : public FoldingSetNode {
LLVMContext &Context;
typedef std::pair<unsigned, AttributeSetNode*> IndexAttrPair;
- SmallVector<IndexAttrPair, 4> AttrNodes;
+ unsigned NumAttrs; ///< Number of entries in this set.
+
+ /// \brief Return a pointer to the IndexAttrPair for the specified slot.
+ const IndexAttrPair *getNode(unsigned Slot) const {
+ return reinterpret_cast<const IndexAttrPair *>(this + 1) + Slot;
+ }
// AttributesSet is uniqued, these should not be publicly available.
void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
public:
AttributeSetImpl(LLVMContext &C,
- ArrayRef<std::pair<unsigned, AttributeSetNode*> > attrs)
- : Context(C), AttrNodes(attrs.begin(), attrs.end()) {}
+ ArrayRef<std::pair<unsigned, AttributeSetNode *> > Attrs)
+ : Context(C), NumAttrs(Attrs.size()) {
+#ifndef NDEBUG
+ if (Attrs.size() >= 2) {
+ for (const std::pair<unsigned, AttributeSetNode *> *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<IndexAttrPair *>(this + 1));
+ }
/// \brief Get the context that created this AttributeSetImpl.
LLVMContext &getContext() { return Context; }
/// \brief Return the number of attributes this AttributeSet contains.
- unsigned getNumAttributes() const { return AttrNodes.size(); }
+ unsigned getNumAttributes() const { return NumAttrs; }
/// \brief Get the index of the given "slot" in the AttrNodes list. This index
/// is the index of the return, parameter, or function object that the
/// attributes are applied to, not the index into the AttrNodes list where the
/// attributes reside.
unsigned getSlotIndex(unsigned Slot) const {
- return AttrNodes[Slot].first;
+ return getNode(Slot)->first;
}
/// \brief Retrieve the attributes for the given "slot" in the AttrNode list.
/// \p Slot is an index into the AttrNodes list, not the index of the return /
/// parameter/ function which the attributes apply to.
AttributeSet getSlotAttributes(unsigned Slot) const {
- return AttributeSet::get(Context, AttrNodes[Slot]);
+ return AttributeSet::get(Context, *getNode(Slot));
}
/// \brief Retrieve the attribute set node for the given "slot" in the
/// AttrNode list.
AttributeSetNode *getSlotNode(unsigned Slot) const {
- return AttrNodes[Slot].second;
+ return getNode(Slot)->second;
}
- typedef AttributeSetNode::iterator iterator;
- typedef AttributeSetNode::const_iterator const_iterator;
-
- iterator begin(unsigned Slot)
- { return AttrNodes[Slot].second->begin(); }
- iterator end(unsigned Slot)
- { return AttrNodes[Slot].second->end(); }
-
- const_iterator begin(unsigned Slot) const
- { return AttrNodes[Slot].second->begin(); }
- const_iterator end(unsigned Slot) const
- { return AttrNodes[Slot].second->end(); }
+ typedef AttributeSetNode::iterator iterator;
+ iterator begin(unsigned Slot) const { return getSlotNode(Slot)->begin(); }
+ iterator end(unsigned Slot) const { return getSlotNode(Slot)->end(); }
void Profile(FoldingSetNodeID &ID) const {
- Profile(ID, AttrNodes);
+ Profile(ID, makeArrayRef(getNode(0), getNumAttributes()));
}
static void Profile(FoldingSetNodeID &ID,
ArrayRef<std::pair<unsigned, AttributeSetNode*> > Nodes) {
@@ -271,6 +261,8 @@ public:
// FIXME: This atrocity is temporary.
uint64_t Raw(unsigned Index) const;
+
+ void dump() const;
};
} // end llvm namespace
OpenPOWER on IntegriCloud