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

View File

@ -318,7 +318,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr,
return false; return false;
// It's not safe to eliminate the sign / zero extension of the return value. // 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; return false;
// Otherwise, make sure the unmodified return value of I is the return value. // 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; return false;
// It's not safe to eliminate the sign / zero extension of the return value. // 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; return false;
// Check if the only use is a function return node. // 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 Attribute::getAsString(Attributes Attrs) {
std::string Result; std::string Result;
if (Attrs & Attribute::ZExt) if (Attrs.hasZExtAttr())
Result += "zeroext "; Result += "zeroext ";
if (Attrs & Attribute::SExt) if (Attrs.hasSExtAttr())
Result += "signext "; Result += "signext ";
if (Attrs & Attribute::NoReturn) if (Attrs.hasNoReturnAttr())
Result += "noreturn "; Result += "noreturn ";
if (Attrs & Attribute::NoUnwind) if (Attrs.hasNoUnwindAttr())
Result += "nounwind "; Result += "nounwind ";
if (Attrs & Attribute::UWTable) if (Attrs.hasUWTableAttr())
Result += "uwtable "; Result += "uwtable ";
if (Attrs & Attribute::ReturnsTwice) if (Attrs.hasReturnsTwiceAttr())
Result += "returns_twice "; Result += "returns_twice ";
if (Attrs & Attribute::InReg) if (Attrs.hasInRegAttr())
Result += "inreg "; Result += "inreg ";
if (Attrs & Attribute::NoAlias) if (Attrs.hasNoAliasAttr())
Result += "noalias "; Result += "noalias ";
if (Attrs & Attribute::NoCapture) if (Attrs.hasNoCaptureAttr())
Result += "nocapture "; Result += "nocapture ";
if (Attrs & Attribute::StructRet) if (Attrs.hasStructRetAttr())
Result += "sret "; Result += "sret ";
if (Attrs & Attribute::ByVal) if (Attrs.hasByValAttr())
Result += "byval "; Result += "byval ";
if (Attrs & Attribute::Nest) if (Attrs.hasNestAttr())
Result += "nest "; Result += "nest ";
if (Attrs & Attribute::ReadNone) if (Attrs.hasReadNoneAttr())
Result += "readnone "; Result += "readnone ";
if (Attrs & Attribute::ReadOnly) if (Attrs.hasReadOnlyAttr())
Result += "readonly "; Result += "readonly ";
if (Attrs & Attribute::OptimizeForSize) if (Attrs.hasOptimizeForSizeAttr())
Result += "optsize "; Result += "optsize ";
if (Attrs & Attribute::NoInline) if (Attrs.hasNoInlineAttr())
Result += "noinline "; Result += "noinline ";
if (Attrs & Attribute::InlineHint) if (Attrs.hasInlineHintAttr())
Result += "inlinehint "; Result += "inlinehint ";
if (Attrs & Attribute::AlwaysInline) if (Attrs.hasAlwaysInlineAttr())
Result += "alwaysinline "; Result += "alwaysinline ";
if (Attrs & Attribute::StackProtect) if (Attrs.hasStackProtectAttr())
Result += "ssp "; Result += "ssp ";
if (Attrs & Attribute::StackProtectReq) if (Attrs.hasStackProtectReqAttr())
Result += "sspreq "; Result += "sspreq ";
if (Attrs & Attribute::NoRedZone) if (Attrs.hasNoRedZoneAttr())
Result += "noredzone "; Result += "noredzone ";
if (Attrs & Attribute::NoImplicitFloat) if (Attrs.hasNoImplicitFloatAttr())
Result += "noimplicitfloat "; Result += "noimplicitfloat ";
if (Attrs & Attribute::Naked) if (Attrs.hasNakedAttr())
Result += "naked "; Result += "naked ";
if (Attrs & Attribute::NonLazyBind) if (Attrs.hasNonLazyBindAttr())
Result += "nonlazybind "; Result += "nonlazybind ";
if (Attrs & Attribute::AddressSafety) if (Attrs.hasAddressSafetyAttr())
Result += "address_safety "; Result += "address_safety ";
if (Attrs & Attribute::StackAlignment) { if (Attrs & Attribute::StackAlignment) {
Result += "alignstack("; Result += "alignstack(";

View File

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