Convert some attribute existence queries over to use the predicate methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164268 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2012-09-19 23:54:18 +00:00
parent f5958e9dea
commit e603fe4664
4 changed files with 38 additions and 38 deletions

View File

@ -2726,16 +2726,16 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
std::vector<Type*> ParamTypeList;
SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs != Attribute::None)
if (RetAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
ParamTypeList.push_back(ArgList[i].Ty);
if (ArgList[i].Attrs != Attribute::None)
if (ArgList[i].Attrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs));
}
if (FuncAttrs != Attribute::None)
if (FuncAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(~0, FuncAttrs));
AttrListPtr PAL = AttrListPtr::get(Attrs);
@ -3253,7 +3253,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
// Set up the Attributes for the function.
SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs != Attribute::None)
if (RetAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
SmallVector<Value*, 8> Args;
@ -3274,14 +3274,14 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
return Error(ArgList[i].Loc, "argument is not of expected type '" +
getTypeString(ExpectedTy) + "'");
Args.push_back(ArgList[i].V);
if (ArgList[i].Attrs != Attribute::None)
if (ArgList[i].Attrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs));
}
if (I != E)
return Error(CallLoc, "not enough parameters specified for call");
if (FnAttrs != Attribute::None)
if (FnAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs));
// Finish off the Attributes and check them
@ -3649,7 +3649,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
// Set up the Attributes for the function.
SmallVector<AttributeWithIndex, 8> Attrs;
if (RetAttrs != Attribute::None)
if (RetAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(0, RetAttrs));
SmallVector<Value*, 8> Args;
@ -3670,14 +3670,14 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
return Error(ArgList[i].Loc, "argument is not of expected type '" +
getTypeString(ExpectedTy) + "'");
Args.push_back(ArgList[i].V);
if (ArgList[i].Attrs != Attribute::None)
if (ArgList[i].Attrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs));
}
if (I != E)
return Error(CallLoc, "not enough parameters specified for call");
if (FnAttrs != Attribute::None)
if (FnAttrs.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs));
// Finish off the Attributes and check them

View File

@ -318,7 +318,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr,
return false;
// It's not safe to eliminate the sign / zero extension of the return value.
if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt))
if (CallerRetAttr.hasZExtAttr() || CallerRetAttr.hasSExtAttr())
return false;
// Otherwise, make sure the unmodified return value of I is the return value.
@ -358,7 +358,7 @@ bool llvm::isInTailCallPosition(SelectionDAG &DAG, SDNode *Node,
return false;
// It's not safe to eliminate the sign / zero extension of the return value.
if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt))
if (CallerRetAttr.hasZExtAttr() || CallerRetAttr.hasSExtAttr())
return false;
// Check if the only use is a function return node.

View File

@ -28,55 +28,55 @@ using namespace llvm;
std::string Attribute::getAsString(Attributes Attrs) {
std::string Result;
if (Attrs & Attribute::ZExt)
if (Attrs.hasZExtAttr())
Result += "zeroext ";
if (Attrs & Attribute::SExt)
if (Attrs.hasSExtAttr())
Result += "signext ";
if (Attrs & Attribute::NoReturn)
if (Attrs.hasNoReturnAttr())
Result += "noreturn ";
if (Attrs & Attribute::NoUnwind)
if (Attrs.hasNoUnwindAttr())
Result += "nounwind ";
if (Attrs & Attribute::UWTable)
if (Attrs.hasUWTableAttr())
Result += "uwtable ";
if (Attrs & Attribute::ReturnsTwice)
if (Attrs.hasReturnsTwiceAttr())
Result += "returns_twice ";
if (Attrs & Attribute::InReg)
if (Attrs.hasInRegAttr())
Result += "inreg ";
if (Attrs & Attribute::NoAlias)
if (Attrs.hasNoAliasAttr())
Result += "noalias ";
if (Attrs & Attribute::NoCapture)
if (Attrs.hasNoCaptureAttr())
Result += "nocapture ";
if (Attrs & Attribute::StructRet)
if (Attrs.hasStructRetAttr())
Result += "sret ";
if (Attrs & Attribute::ByVal)
if (Attrs.hasByValAttr())
Result += "byval ";
if (Attrs & Attribute::Nest)
if (Attrs.hasNestAttr())
Result += "nest ";
if (Attrs & Attribute::ReadNone)
if (Attrs.hasReadNoneAttr())
Result += "readnone ";
if (Attrs & Attribute::ReadOnly)
if (Attrs.hasReadOnlyAttr())
Result += "readonly ";
if (Attrs & Attribute::OptimizeForSize)
if (Attrs.hasOptimizeForSizeAttr())
Result += "optsize ";
if (Attrs & Attribute::NoInline)
if (Attrs.hasNoInlineAttr())
Result += "noinline ";
if (Attrs & Attribute::InlineHint)
if (Attrs.hasInlineHintAttr())
Result += "inlinehint ";
if (Attrs & Attribute::AlwaysInline)
if (Attrs.hasAlwaysInlineAttr())
Result += "alwaysinline ";
if (Attrs & Attribute::StackProtect)
if (Attrs.hasStackProtectAttr())
Result += "ssp ";
if (Attrs & Attribute::StackProtectReq)
if (Attrs.hasStackProtectReqAttr())
Result += "sspreq ";
if (Attrs & Attribute::NoRedZone)
if (Attrs.hasNoRedZoneAttr())
Result += "noredzone ";
if (Attrs & Attribute::NoImplicitFloat)
if (Attrs.hasNoImplicitFloatAttr())
Result += "noimplicitfloat ";
if (Attrs & Attribute::Naked)
if (Attrs.hasNakedAttr())
Result += "naked ";
if (Attrs & Attribute::NonLazyBind)
if (Attrs.hasNonLazyBindAttr())
Result += "nonlazybind ";
if (Attrs & Attribute::AddressSafety)
if (Attrs.hasAddressSafetyAttr())
Result += "address_safety ";
if (Attrs & Attribute::StackAlignment) {
Result += "alignstack(";

View File

@ -585,12 +585,12 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
VerifyParameterAttrs(Attr.Attrs, Ty, Attr.Index == 0, V);
if (Attr.Attrs & Attribute::Nest) {
if (Attr.Attrs.hasNestAttr()) {
Assert1(!SawNest, "More than one parameter has attribute nest!", V);
SawNest = true;
}
if (Attr.Attrs & Attribute::StructRet)
if (Attr.Attrs.hasStructRetAttr())
Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V);
}