Change 'AttrVal' to 'AttrKind' to better reflect that it's a kind of attribute instead of the value of the attribute.

llvm-svn: 170972
This commit is contained in:
Bill Wendling 2012-12-22 00:37:52 +00:00
parent c632467e2b
commit c79e42c5ce
9 changed files with 40 additions and 40 deletions

View File

@ -53,7 +53,7 @@ public:
/// an exception might pass by. /// an exception might pass by.
/// uwtable + nounwind = Needs an entry because the ABI says so. /// uwtable + nounwind = Needs an entry because the ABI says so.
enum AttrVal { enum AttrKind {
// IR-Level Attributes // IR-Level Attributes
None, ///< No attributes have been set None, ///< No attributes have been set
AddressSafety, ///< Address safety checking is on. AddressSafety, ///< Address safety checking is on.
@ -100,11 +100,11 @@ public:
/// \brief Return a uniquified Attribute object. This takes the uniquified /// \brief Return a uniquified Attribute object. This takes the uniquified
/// value from the Builder and wraps it in the Attribute class. /// value from the Builder and wraps it in the Attribute class.
static Attribute get(LLVMContext &Context, ArrayRef<AttrVal> Vals); static Attribute get(LLVMContext &Context, ArrayRef<AttrKind> Vals);
static Attribute get(LLVMContext &Context, AttrBuilder &B); static Attribute get(LLVMContext &Context, AttrBuilder &B);
/// \brief Return true if the attribute is present. /// \brief Return true if the attribute is present.
bool hasAttribute(AttrVal Val) const; bool hasAttribute(AttrKind Val) const;
/// \brief Return true if attributes exist /// \brief Return true if attributes exist
bool hasAttributes() const; bool hasAttributes() const;
@ -165,10 +165,10 @@ public:
void clear() { Bits = 0; } void clear() { Bits = 0; }
/// addAttribute - Add an attribute to the builder. /// addAttribute - Add an attribute to the builder.
AttrBuilder &addAttribute(Attribute::AttrVal Val); AttrBuilder &addAttribute(Attribute::AttrKind Val);
/// removeAttribute - Remove an attribute from the builder. /// removeAttribute - Remove an attribute from the builder.
AttrBuilder &removeAttribute(Attribute::AttrVal Val); AttrBuilder &removeAttribute(Attribute::AttrKind Val);
/// addAttribute - Add the attributes from A to the builder. /// addAttribute - Add the attributes from A to the builder.
AttrBuilder &addAttributes(const Attribute &A); AttrBuilder &addAttributes(const Attribute &A);
@ -177,7 +177,7 @@ public:
AttrBuilder &removeAttributes(const Attribute &A); AttrBuilder &removeAttributes(const Attribute &A);
/// contains - Return true if the builder has the specified attribute. /// contains - Return true if the builder has the specified attribute.
bool hasAttribute(Attribute::AttrVal A) const; bool hasAttribute(Attribute::AttrKind A) const;
/// hasAttributes - Return true if the builder has IR-level attributes. /// hasAttributes - Return true if the builder has IR-level attributes.
bool hasAttributes() const; bool hasAttributes() const;
@ -252,7 +252,7 @@ struct AttributeWithIndex {
///< Index ~0U is used for function attributes. ///< Index ~0U is used for function attributes.
static AttributeWithIndex get(LLVMContext &C, unsigned Idx, static AttributeWithIndex get(LLVMContext &C, unsigned Idx,
ArrayRef<Attribute::AttrVal> Attrs) { ArrayRef<Attribute::AttrKind> Attrs) {
return get(Idx, Attribute::get(C, Attrs)); return get(Idx, Attribute::get(C, Attrs));
} }
static AttributeWithIndex get(unsigned Idx, Attribute Attrs) { static AttributeWithIndex get(unsigned Idx, Attribute Attrs) {
@ -343,7 +343,7 @@ public:
/// \brief Return true if the specified attribute is set for at least one /// \brief Return true if the specified attribute is set for at least one
/// parameter or for the return value. /// parameter or for the return value.
bool hasAttrSomewhere(Attribute::AttrVal Attr) const; bool hasAttrSomewhere(Attribute::AttrKind Attr) const;
unsigned getNumAttrs() const; unsigned getNumAttrs() const;
Attribute &getAttributesAtIndex(unsigned i) const; Attribute &getAttributesAtIndex(unsigned i) const;

View File

@ -176,7 +176,7 @@ public:
/// addFnAttr - Add function attributes to this function. /// addFnAttr - Add function attributes to this function.
/// ///
void addFnAttr(Attribute::AttrVal N) { void addFnAttr(Attribute::AttrKind N) {
// Function Attribute are stored at ~0 index // Function Attribute are stored at ~0 index
addAttribute(AttributeSet::FunctionIndex, Attribute::get(getContext(), N)); addAttribute(AttributeSet::FunctionIndex, Attribute::get(getContext(), N));
} }

View File

@ -1278,10 +1278,10 @@ public:
void removeAttribute(unsigned i, Attribute attr); void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the given attribute. /// \brief Determine whether this call has the given attribute.
bool hasFnAttr(Attribute::AttrVal A) const; bool hasFnAttr(Attribute::AttrKind A) const;
/// \brief Determine whether the call or the callee has the given attributes. /// \brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attribute::AttrVal A) const; bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
/// \brief Extract the alignment for a call or parameter (0=unknown). /// \brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const { unsigned getParamAlignment(unsigned i) const {
@ -3034,10 +3034,10 @@ public:
void removeAttribute(unsigned i, Attribute attr); void removeAttribute(unsigned i, Attribute attr);
/// \brief Determine whether this call has the NoAlias attribute. /// \brief Determine whether this call has the NoAlias attribute.
bool hasFnAttr(Attribute::AttrVal A) const; bool hasFnAttr(Attribute::AttrKind A) const;
/// \brief Determine whether the call or the callee has the given attributes. /// \brief Determine whether the call or the callee has the given attributes.
bool paramHasAttr(unsigned i, Attribute::AttrVal A) const; bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
/// \brief Extract the alignment for a call or parameter (0=unknown). /// \brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const { unsigned getParamAlignment(unsigned i) const {

View File

@ -185,12 +185,12 @@ public:
} }
/// \brief Return true if this function has the given attribute. /// \brief Return true if this function has the given attribute.
bool hasFnAttr(Attribute::AttrVal A) const { bool hasFnAttr(Attribute::AttrKind A) const {
CALLSITE_DELEGATE_GETTER(hasFnAttr(A)); CALLSITE_DELEGATE_GETTER(hasFnAttr(A));
} }
/// \brief Return true if the call or the callee has the given attribute. /// \brief Return true if the call or the callee has the given attribute.
bool paramHasAttr(unsigned i, Attribute::AttrVal A) const { bool paramHasAttr(unsigned i, Attribute::AttrKind A) const {
CALLSITE_DELEGATE_GETTER(paramHasAttr(i, A)); CALLSITE_DELEGATE_GETTER(paramHasAttr(i, A));
} }

View File

@ -40,9 +40,9 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout *TD,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrLen = M->getOrInsertFunction("strlen", Constant *StrLen = M->getOrInsertFunction("strlen",
@ -69,9 +69,9 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI[2]; AttributeWithIndex AWI[2];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AWI[1] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Constant *StrNLen = M->getOrInsertFunction("strnlen", Constant *StrNLen = M->getOrInsertFunction("strnlen",
@ -97,10 +97,10 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
return 0; return 0;
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AttributeWithIndex AWI = AttributeWithIndex AWI =
AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
Type *I8Ptr = B.getInt8PtrTy(); Type *I8Ptr = B.getInt8PtrTy();
Type *I32Ty = B.getInt32Ty(); Type *I32Ty = B.getInt32Ty();
@ -126,9 +126,9 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
AttributeWithIndex AWI[3]; AttributeWithIndex AWI[3];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *StrNCmp = M->getOrInsertFunction("strncmp", Value *StrNCmp = M->getOrInsertFunction("strncmp",
@ -236,9 +236,9 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
AttributeWithIndex AWI; AttributeWithIndex AWI;
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AWI = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemChr = M->getOrInsertFunction("memchr", Value *MemChr = M->getOrInsertFunction("memchr",
AttributeSet::get(M->getContext(), AWI), AttributeSet::get(M->getContext(), AWI),
@ -266,9 +266,9 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
AttributeWithIndex AWI[3]; AttributeWithIndex AWI[3];
AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture); AWI[0] = AttributeWithIndex::get(M->getContext(), 1, Attribute::NoCapture);
AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture); AWI[1] = AttributeWithIndex::get(M->getContext(), 2, Attribute::NoCapture);
Attribute::AttrVal AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind }; Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex, AWI[2] = AttributeWithIndex::get(M->getContext(), AttributeSet::FunctionIndex,
ArrayRef<Attribute::AttrVal>(AVs, 2)); ArrayRef<Attribute::AttrKind>(AVs, 2));
LLVMContext &Context = B.GetInsertBlock()->getContext(); LLVMContext &Context = B.GetInsertBlock()->getContext();
Value *MemCmp = M->getOrInsertFunction("memcmp", Value *MemCmp = M->getOrInsertFunction("memcmp",

View File

@ -94,7 +94,7 @@ struct LoopVectorize : public LoopPass {
// Check the function attribues to find out if this function should be // Check the function attribues to find out if this function should be
// optimized for size. // optimized for size.
Function *F = L->getHeader()->getParent(); Function *F = L->getHeader()->getParent();
Attribute::AttrVal SzAttr= Attribute::OptimizeForSize; Attribute::AttrKind SzAttr= Attribute::OptimizeForSize;
bool OptForSize = F->getFnAttributes().hasAttribute(SzAttr); bool OptForSize = F->getFnAttributes().hasAttribute(SzAttr);
unsigned VF = CM.selectVectorizationFactor(OptForSize, VectorizationFactor); unsigned VF = CM.selectVectorizationFactor(OptForSize, VectorizationFactor);

View File

@ -29,9 +29,9 @@ using namespace llvm;
// Attribute Implementation // Attribute Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) { Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrKind> Vals) {
AttrBuilder B; AttrBuilder B;
for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end(); for (ArrayRef<AttrKind>::iterator I = Vals.begin(), E = Vals.end();
I != E; ++I) I != E; ++I)
B.addAttribute(*I); B.addAttribute(*I);
return Attribute::get(Context, B); return Attribute::get(Context, B);
@ -61,7 +61,7 @@ Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
return Attribute(PA); return Attribute(PA);
} }
bool Attribute::hasAttribute(AttrVal Val) const { bool Attribute::hasAttribute(AttrKind Val) const {
return pImpl && pImpl->hasAttribute(Val); return pImpl && pImpl->hasAttribute(Val);
} }
@ -225,7 +225,7 @@ std::string Attribute::getAsString() const {
// AttrBuilder Implementation // AttrBuilder Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrVal Val){ AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){
Bits |= AttributeImpl::getAttrMask(Val); Bits |= AttributeImpl::getAttrMask(Val);
return *this; return *this;
} }
@ -251,7 +251,7 @@ AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
return *this; return *this;
} }
AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrVal Val) { AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
Bits &= ~AttributeImpl::getAttrMask(Val); Bits &= ~AttributeImpl::getAttrMask(Val);
return *this; return *this;
} }
@ -266,7 +266,7 @@ AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
return *this; return *this;
} }
bool AttrBuilder::hasAttribute(Attribute::AttrVal A) const { bool AttrBuilder::hasAttribute(Attribute::AttrKind A) const {
return Bits & AttributeImpl::getAttrMask(A); return Bits & AttributeImpl::getAttrMask(A);
} }
@ -432,7 +432,7 @@ Attribute AttributeSet::getAttributes(unsigned Idx) const {
/// hasAttrSomewhere - Return true if the specified attribute is set for at /// hasAttrSomewhere - Return true if the specified attribute is set for at
/// least one parameter or for the return value. /// least one parameter or for the return value.
bool AttributeSet::hasAttrSomewhere(Attribute::AttrVal Attr) const { bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
if (AttrList == 0) return false; if (AttrList == 0) return false;
const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs; const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;

View File

@ -343,7 +343,7 @@ void CallInst::removeAttribute(unsigned i, Attribute attr) {
setAttributes(PAL); setAttributes(PAL);
} }
bool CallInst::hasFnAttr(Attribute::AttrVal A) const { bool CallInst::hasFnAttr(Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex) if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex)
.hasAttribute(A)) .hasAttribute(A))
return true; return true;
@ -352,7 +352,7 @@ bool CallInst::hasFnAttr(Attribute::AttrVal A) const {
return false; return false;
} }
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrVal A) const { bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A)) if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true; return true;
if (const Function *F = getCalledFunction()) if (const Function *F = getCalledFunction())
@ -572,7 +572,7 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
return setSuccessor(idx, B); return setSuccessor(idx, B);
} }
bool InvokeInst::hasFnAttr(Attribute::AttrVal A) const { bool InvokeInst::hasFnAttr(Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex). if (AttributeList.getParamAttributes(AttributeSet::FunctionIndex).
hasAttribute(A)) hasAttribute(A))
return true; return true;
@ -581,7 +581,7 @@ bool InvokeInst::hasFnAttr(Attribute::AttrVal A) const {
return false; return false;
} }
bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrVal A) const { bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A)) if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true; return true;
if (const Function *F = getCalledFunction()) if (const Function *F = getCalledFunction())

View File

@ -548,7 +548,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n"; OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n";
OS << " unsigned NumAttrs = 0;\n"; OS << " unsigned NumAttrs = 0;\n";
OS << " if (id != 0) {\n"; OS << " if (id != 0) {\n";
OS << " SmallVector<Attribute::AttrVal, 8> AttrVec;\n"; OS << " SmallVector<Attribute::AttrKind, 8> AttrVec;\n";
OS << " switch(IntrinsicsToAttributesMap[id - "; OS << " switch(IntrinsicsToAttributesMap[id - ";
if (TargetOnly) if (TargetOnly)
OS << "Intrinsic::num_intrinsics"; OS << "Intrinsic::num_intrinsics";