summaryrefslogtreecommitdiff
path: root/lib/AsmParser
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-03-21 16:57:19 +0000
committerReid Kleckner <rnk@google.com>2017-03-21 16:57:19 +0000
commit6707770d481ea95dee07c22f675a8de8879e4557 (patch)
tree2f443c18fe06baadbf7af79a82306a24adb3cc0e /lib/AsmParser
parent45fb365cc4f4a1e7aa31d4fbe4e08dc47919cafc (diff)
Rename AttributeSet to AttributeList
Summary: This class is a list of AttributeSetNodes corresponding the function prototype of a call or function declaration. This class used to be called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is typically accessed by parameter and return value index, so "AttributeList" seems like a more intuitive name. Rename AttributeSetImpl to AttributeListImpl to follow suit. It's useful to rename this class so that we can rename AttributeSetNode to AttributeSet later. AttributeSet is the set of attributes that apply to a single function, argument, or return value. Reviewers: sanjoy, javed.absar, chandlerc, pete Reviewed By: pete Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits Differential Revision: https://reviews.llvm.org/D31102 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/LLParser.cpp98
-rw-r--r--lib/AsmParser/LLParser.h12
2 files changed, 50 insertions, 60 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index b9415a26590..ab315dd2c7f 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -130,9 +130,9 @@ bool LLParser::ValidateEndOfModule() {
B.merge(NumberedAttrBuilders[Attr]);
if (Function *Fn = dyn_cast<Function>(V)) {
- AttributeSet AS = Fn->getAttributes();
- AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeSet::FunctionIndex);
- AS = AS.removeAttributes(Context, AttributeSet::FunctionIndex,
+ AttributeList AS = Fn->getAttributes();
+ AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex);
+ AS = AS.removeAttributes(Context, AttributeList::FunctionIndex,
AS.getFnAttributes());
FnAttrs.merge(B);
@@ -144,32 +144,29 @@ bool LLParser::ValidateEndOfModule() {
FnAttrs.removeAttribute(Attribute::Alignment);
}
- AS = AS.addAttributes(Context, AttributeSet::FunctionIndex,
- AttributeSet::get(Context,
- AttributeSet::FunctionIndex,
- FnAttrs));
+ AS = AS.addAttributes(
+ Context, AttributeList::FunctionIndex,
+ AttributeList::get(Context, AttributeList::FunctionIndex, FnAttrs));
Fn->setAttributes(AS);
} else if (CallInst *CI = dyn_cast<CallInst>(V)) {
- AttributeSet AS = CI->getAttributes();
- AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeSet::FunctionIndex);
- AS = AS.removeAttributes(Context, AttributeSet::FunctionIndex,
+ AttributeList AS = CI->getAttributes();
+ AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex);
+ AS = AS.removeAttributes(Context, AttributeList::FunctionIndex,
AS.getFnAttributes());
FnAttrs.merge(B);
- AS = AS.addAttributes(Context, AttributeSet::FunctionIndex,
- AttributeSet::get(Context,
- AttributeSet::FunctionIndex,
- FnAttrs));
+ AS = AS.addAttributes(
+ Context, AttributeList::FunctionIndex,
+ AttributeList::get(Context, AttributeList::FunctionIndex, FnAttrs));
CI->setAttributes(AS);
} else if (InvokeInst *II = dyn_cast<InvokeInst>(V)) {
- AttributeSet AS = II->getAttributes();
- AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeSet::FunctionIndex);
- AS = AS.removeAttributes(Context, AttributeSet::FunctionIndex,
+ AttributeList AS = II->getAttributes();
+ AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex);
+ AS = AS.removeAttributes(Context, AttributeList::FunctionIndex,
AS.getFnAttributes());
FnAttrs.merge(B);
- AS = AS.addAttributes(Context, AttributeSet::FunctionIndex,
- AttributeSet::get(Context,
- AttributeSet::FunctionIndex,
- FnAttrs));
+ AS = AS.addAttributes(
+ Context, AttributeList::FunctionIndex,
+ AttributeList::get(Context, AttributeList::FunctionIndex, FnAttrs));
II->setAttributes(AS);
} else {
llvm_unreachable("invalid object with forward attribute group reference");
@@ -2132,9 +2129,8 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
if (ParseOptionalParamAttrs(ArgAttrs) || ParseValue(ArgTy, V, PFS))
return true;
}
- ArgList.push_back(ParamInfo(ArgLoc, V, AttributeSet::get(V->getContext(),
- AttrIndex++,
- ArgAttrs)));
+ ArgList.push_back(ParamInfo(
+ ArgLoc, V, AttributeList::get(V->getContext(), AttrIndex++, ArgAttrs)));
}
if (IsMustTailCall && InVarArgsFunc)
@@ -2240,8 +2236,8 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
return Error(TypeLoc, "invalid type for function argument");
unsigned AttrIndex = 1;
- ArgList.emplace_back(TypeLoc, ArgTy, AttributeSet::get(ArgTy->getContext(),
- AttrIndex++, Attrs),
+ ArgList.emplace_back(TypeLoc, ArgTy, AttributeList::get(ArgTy->getContext(),
+ AttrIndex++, Attrs),
std::move(Name));
while (EatIfPresent(lltok::comma)) {
@@ -2270,7 +2266,7 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
ArgList.emplace_back(
TypeLoc, ArgTy,
- AttributeSet::get(ArgTy->getContext(), AttrIndex++, Attrs),
+ AttributeList::get(ArgTy->getContext(), AttrIndex++, Attrs),
std::move(Name));
}
}
@@ -4741,27 +4737,25 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
// Okay, if we got here, the function is syntactically valid. Convert types
// and do semantic checks.
std::vector<Type*> ParamTypeList;
- SmallVector<AttributeSet, 8> Attrs;
+ SmallVector<AttributeList, 8> Attrs;
if (RetAttrs.hasAttributes())
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::ReturnIndex,
- RetAttrs));
+ Attrs.push_back(AttributeList::get(RetType->getContext(),
+ AttributeList::ReturnIndex, RetAttrs));
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
ParamTypeList.push_back(ArgList[i].Ty);
if (ArgList[i].Attrs.hasAttributes(i + 1)) {
AttrBuilder B(ArgList[i].Attrs, i + 1);
- Attrs.push_back(AttributeSet::get(RetType->getContext(), i + 1, B));
+ Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B));
}
}
if (FuncAttrs.hasAttributes())
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::FunctionIndex,
- FuncAttrs));
+ Attrs.push_back(AttributeList::get(
+ RetType->getContext(), AttributeList::FunctionIndex, FuncAttrs));
- AttributeSet PAL = AttributeSet::get(Context, Attrs);
+ AttributeList PAL = AttributeList::get(Context, Attrs);
if (PAL.hasAttribute(1, Attribute::StructRet) && !RetType->isVoidTy())
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
@@ -5371,11 +5365,10 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
return true;
// Set up the Attribute for the function.
- SmallVector<AttributeSet, 8> Attrs;
+ SmallVector<AttributeList, 8> Attrs;
if (RetAttrs.hasAttributes())
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::ReturnIndex,
- RetAttrs));
+ Attrs.push_back(AttributeList::get(RetType->getContext(),
+ AttributeList::ReturnIndex, RetAttrs));
SmallVector<Value*, 8> Args;
@@ -5397,7 +5390,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
Args.push_back(ArgList[i].V);
if (ArgList[i].Attrs.hasAttributes(i + 1)) {
AttrBuilder B(ArgList[i].Attrs, i + 1);
- Attrs.push_back(AttributeSet::get(RetType->getContext(), i + 1, B));
+ Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B));
}
}
@@ -5408,13 +5401,12 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
if (FnAttrs.hasAlignmentAttr())
return Error(CallLoc, "invoke instructions may not have an alignment");
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::FunctionIndex,
- FnAttrs));
+ Attrs.push_back(AttributeList::get(RetType->getContext(),
+ AttributeList::FunctionIndex, FnAttrs));
}
// Finish off the Attribute and check them
- AttributeSet PAL = AttributeSet::get(Context, Attrs);
+ AttributeList PAL = AttributeList::get(Context, Attrs);
InvokeInst *II =
InvokeInst::Create(Ty, Callee, NormalBB, UnwindBB, Args, BundleList);
@@ -5975,11 +5967,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
return true;
// Set up the Attribute for the function.
- SmallVector<AttributeSet, 8> Attrs;
+ SmallVector<AttributeList, 8> Attrs;
if (RetAttrs.hasAttributes())
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::ReturnIndex,
- RetAttrs));
+ Attrs.push_back(AttributeList::get(RetType->getContext(),
+ AttributeList::ReturnIndex, RetAttrs));
SmallVector<Value*, 8> Args;
@@ -6001,7 +5992,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
Args.push_back(ArgList[i].V);
if (ArgList[i].Attrs.hasAttributes(i + 1)) {
AttrBuilder B(ArgList[i].Attrs, i + 1);
- Attrs.push_back(AttributeSet::get(RetType->getContext(), i + 1, B));
+ Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B));
}
}
@@ -6012,13 +6003,12 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
if (FnAttrs.hasAlignmentAttr())
return Error(CallLoc, "call instructions may not have an alignment");
- Attrs.push_back(AttributeSet::get(RetType->getContext(),
- AttributeSet::FunctionIndex,
- FnAttrs));
+ Attrs.push_back(AttributeList::get(RetType->getContext(),
+ AttributeList::FunctionIndex, FnAttrs));
}
// Finish off the Attribute and check them
- AttributeSet PAL = AttributeSet::get(Context, Attrs);
+ AttributeList PAL = AttributeList::get(Context, Attrs);
CallInst *CI = CallInst::Create(Ty, Callee, Args, BundleList);
CI->setTailCallKind(TCK);
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index 16d4e8b5baa..7dae33480ed 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -391,9 +391,9 @@ namespace llvm {
struct ParamInfo {
LocTy Loc;
Value *V;
- AttributeSet Attrs;
- ParamInfo(LocTy loc, Value *v, AttributeSet attrs)
- : Loc(loc), V(v), Attrs(attrs) {}
+ AttributeList Attrs;
+ ParamInfo(LocTy loc, Value *v, AttributeList attrs)
+ : Loc(loc), V(v), Attrs(attrs) {}
};
bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
PerFunctionState &PFS,
@@ -444,10 +444,10 @@ namespace llvm {
struct ArgInfo {
LocTy Loc;
Type *Ty;
- AttributeSet Attrs;
+ AttributeList Attrs;
std::string Name;
- ArgInfo(LocTy L, Type *ty, AttributeSet Attr, const std::string &N)
- : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
+ ArgInfo(LocTy L, Type *ty, AttributeList Attr, const std::string &N)
+ : Loc(L), Ty(ty), Attrs(Attr), Name(N) {}
};
bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg);
bool ParseFunctionHeader(Function *&Fn, bool isDefine);