mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-13 17:00:01 +00:00
Try again to revert the bad patch. The tree was reverted for some unknown reason
before the last time. --- Reverse-merging r171442 into '.': U include/llvm/IR/Attributes.h U lib/IR/Attributes.cpp U lib/IR/AttributeImpl.h llvm-svn: 171448
This commit is contained in:
parent
0d20c75b66
commit
e0967fda18
@ -17,7 +17,8 @@
|
||||
#define LLVM_ATTRIBUTES_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
@ -151,25 +152,6 @@ public:
|
||||
std::string getAsString() const;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// \class
|
||||
/// \brief Provide DenseMapInfo for Attribute::AttrKind.
|
||||
template<> struct DenseMapInfo<Attribute::AttrKind> {
|
||||
static inline Attribute::AttrKind getEmptyKey() {
|
||||
return Attribute::AttrKind(-1);
|
||||
}
|
||||
static inline Attribute::AttrKind getTombstoneKey() {
|
||||
return Attribute::AttrKind(~0UL - 1L);
|
||||
}
|
||||
static unsigned getHashValue(const Attribute::AttrKind &Val) {
|
||||
return (unsigned)(Val * 37UL);
|
||||
}
|
||||
static bool isEqual(const Attribute::AttrKind &LHS,
|
||||
const Attribute::AttrKind &RHS) {
|
||||
return LHS == RHS;
|
||||
}
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// \class
|
||||
/// \brief This class is used in conjunction with the Attribute::get method to
|
||||
@ -177,61 +159,58 @@ template<> struct DenseMapInfo<Attribute::AttrKind> {
|
||||
/// value, however, is not. So this can be used as a quick way to test for
|
||||
/// equality, presence of attributes, etc.
|
||||
class AttrBuilder {
|
||||
DenseSet<Attribute::AttrKind> AttrSet;
|
||||
uint64_t Alignment;
|
||||
uint64_t StackAlignment;
|
||||
|
||||
uint64_t Bits; // FIXME: Remove after encoding the attr list in the bc file.
|
||||
uint64_t Bits;
|
||||
public:
|
||||
AttrBuilder() : Alignment(0), StackAlignment(0), Bits(0) {}
|
||||
AttrBuilder() : Bits(0) {}
|
||||
explicit AttrBuilder(uint64_t B) : Bits(B) {}
|
||||
AttrBuilder(const Attribute &A) : Bits(A.getBitMask()) {}
|
||||
|
||||
/// \brief Clear out the builder's internals.
|
||||
void clear();
|
||||
void clear() { Bits = 0; }
|
||||
|
||||
/// \brief Add an attribute to the builder.
|
||||
/// addAttribute - Add an attribute to the builder.
|
||||
AttrBuilder &addAttribute(Attribute::AttrKind Val);
|
||||
|
||||
/// \brief Remove an attribute from the builder.
|
||||
/// removeAttribute - Remove an attribute from the builder.
|
||||
AttrBuilder &removeAttribute(Attribute::AttrKind Val);
|
||||
|
||||
/// \brief Add the attributes from A to the builder.
|
||||
/// addAttribute - Add the attributes from A to the builder.
|
||||
AttrBuilder &addAttributes(const Attribute &A);
|
||||
|
||||
/// \brief Remove the attributes from A from the builder.
|
||||
/// removeAttribute - Remove the attributes from A from the builder.
|
||||
AttrBuilder &removeAttributes(const Attribute &A);
|
||||
|
||||
/// \brief Return true if the builder has IR-level attributes.
|
||||
/// \brief Return true if the builder has the specified attribute.
|
||||
bool contains(Attribute::AttrKind A) const;
|
||||
|
||||
/// hasAttributes - Return true if the builder has IR-level attributes.
|
||||
bool hasAttributes() const;
|
||||
|
||||
/// \brief Return true if the builder has any attribute that's in the
|
||||
/// hasAttributes - Return true if the builder has any attribute that's in the
|
||||
/// specified attribute.
|
||||
bool hasAttributes(const Attribute &A) const;
|
||||
|
||||
/// \brief Return true if the builder has an alignment attribute.
|
||||
/// hasAlignmentAttr - Return true if the builder has an alignment attribute.
|
||||
bool hasAlignmentAttr() const;
|
||||
|
||||
/// \brief Retrieve the alignment attribute, if it exists.
|
||||
/// getAlignment - Retrieve the alignment attribute, if it exists.
|
||||
uint64_t getAlignment() const;
|
||||
|
||||
/// \brief Retrieve the stack alignment attribute, if it exists.
|
||||
/// getStackAlignment - Retrieve the stack alignment attribute, if it exists.
|
||||
uint64_t getStackAlignment() const;
|
||||
|
||||
/// \brief This turns an int alignment (which must be a power of 2) into the
|
||||
/// form used internally in Attribute.
|
||||
/// addAlignmentAttr - This turns an int alignment (which must be a power of
|
||||
/// 2) into the form used internally in Attribute.
|
||||
AttrBuilder &addAlignmentAttr(unsigned Align);
|
||||
|
||||
/// \brief This turns an int stack alignment (which must be a power of 2) into
|
||||
/// the form used internally in Attribute.
|
||||
/// addStackAlignmentAttr - This turns an int stack alignment (which must be a
|
||||
/// power of 2) into the form used internally in Attribute.
|
||||
AttrBuilder &addStackAlignmentAttr(unsigned Align);
|
||||
|
||||
/// \brief Add the raw value to the internal representation.
|
||||
///
|
||||
/// addRawValue - Add the raw value to the internal representation.
|
||||
/// N.B. This should be used ONLY for decoding LLVM bitcode!
|
||||
AttrBuilder &addRawValue(uint64_t Val);
|
||||
|
||||
/// \brief Remove attributes that are used on functions only.
|
||||
/// @brief Remove attributes that are used on functions only.
|
||||
void removeFunctionOnlyAttrs() {
|
||||
removeAttribute(Attribute::NoReturn)
|
||||
.removeAttribute(Attribute::NoUnwind)
|
||||
@ -257,15 +236,12 @@ public:
|
||||
|
||||
uint64_t getBitMask() const { return Bits; }
|
||||
|
||||
bool operator==(const AttrBuilder &B) const {
|
||||
bool operator==(const AttrBuilder &B) {
|
||||
return Bits == B.Bits;
|
||||
}
|
||||
bool operator!=(const AttrBuilder &B) const {
|
||||
bool operator!=(const AttrBuilder &B) {
|
||||
return Bits != B.Bits;
|
||||
}
|
||||
|
||||
bool operator==(Attribute::AttrKind A) const;
|
||||
bool operator!=(Attribute::AttrKind A) const;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -42,6 +42,9 @@ public:
|
||||
return Vals;
|
||||
}
|
||||
|
||||
bool contains(Attribute::AttrKind Kind) const;
|
||||
bool contains(StringRef Kind) const;
|
||||
|
||||
bool hasAttribute(Attribute::AttrKind A) const;
|
||||
|
||||
bool hasAttributes() const;
|
||||
@ -50,11 +53,19 @@ public:
|
||||
uint64_t getAlignment() const;
|
||||
uint64_t getStackAlignment() const;
|
||||
|
||||
bool operator==(Attribute::AttrKind Kind) const;
|
||||
bool operator!=(Attribute::AttrKind Kind) const;
|
||||
bool operator==(Attribute::AttrKind Kind) const {
|
||||
return contains(Kind);
|
||||
}
|
||||
bool operator!=(Attribute::AttrKind Kind) const {
|
||||
return !contains(Kind);
|
||||
}
|
||||
|
||||
bool operator==(StringRef Kind) const;
|
||||
bool operator!=(StringRef Kind) const;
|
||||
bool operator==(StringRef Kind) const {
|
||||
return contains(Kind);
|
||||
}
|
||||
bool operator!=(StringRef Kind) const {
|
||||
return !contains(Kind);
|
||||
}
|
||||
|
||||
uint64_t getBitMask() const; // FIXME: Remove.
|
||||
|
||||
|
@ -89,11 +89,11 @@ unsigned Attribute::getStackAlignment() const {
|
||||
}
|
||||
|
||||
bool Attribute::operator==(AttrKind K) const {
|
||||
return pImpl && *pImpl == K;
|
||||
return pImpl && pImpl->contains(K);
|
||||
}
|
||||
|
||||
bool Attribute::operator!=(AttrKind K) const {
|
||||
return !(pImpl && *pImpl == K);
|
||||
return !(pImpl && pImpl->contains(K));
|
||||
}
|
||||
|
||||
uint64_t Attribute::getBitMask() const {
|
||||
@ -293,14 +293,10 @@ AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool AttrBuilder::operator==(Attribute::AttrKind A) const {
|
||||
bool AttrBuilder::contains(Attribute::AttrKind A) const {
|
||||
return Bits & AttributeImpl::getAttrMask(A);
|
||||
}
|
||||
|
||||
bool AttrBuilder::operator!=(Attribute::AttrKind A) const {
|
||||
return !(*this == A);
|
||||
}
|
||||
|
||||
bool AttrBuilder::hasAttributes() const {
|
||||
return Bits != 0;
|
||||
}
|
||||
@ -345,24 +341,18 @@ AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
|
||||
Data = ConstantDataArray::getString(C, data);
|
||||
}
|
||||
|
||||
bool AttributeImpl::operator==(Attribute::AttrKind Kind) const {
|
||||
bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
|
||||
return CI->getZExtValue() == Kind;
|
||||
return false;
|
||||
}
|
||||
bool AttributeImpl::operator!=(Attribute::AttrKind Kind) const {
|
||||
return !(*this == Kind);
|
||||
}
|
||||
|
||||
bool AttributeImpl::operator==(StringRef Kind) const {
|
||||
bool AttributeImpl::contains(StringRef Kind) const {
|
||||
if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
|
||||
if (CDA->isString())
|
||||
return CDA->getAsString() == Kind;
|
||||
return false;
|
||||
}
|
||||
bool AttributeImpl::operator!=(StringRef Kind) const {
|
||||
return !(*this == Kind);
|
||||
}
|
||||
|
||||
uint64_t AttributeImpl::getBitMask() const {
|
||||
// FIXME: Remove this.
|
||||
|
Loading…
x
Reference in New Issue
Block a user