Skip to content

Commit

Permalink
[AsmParser] Unify parsing of attributes
Browse files Browse the repository at this point in the history
Continuing on from D105780, this should be the last major bit of
attribute cleanup. Currently, LLParser implements attribute parsing
for functions, parameters and returns separately, enumerating all
supported (and unsupported) attributes each time. This patch
extracts the common parsing logic, and performs a check afterwards
whether the attribute is valid in the given position. Parameters
and returns are handled together, while function attributes need
slightly different logic to support attribute groups.

Differential Revision: https://reviews.llvm.org/D105938
  • Loading branch information
nikic committed Jul 15, 2021
1 parent e33446e commit f59209a
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 436 deletions.
11 changes: 9 additions & 2 deletions llvm/include/llvm/AsmParser/LLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,15 @@ namespace llvm {
return parseOptionalAddrSpace(
AddrSpace, M->getDataLayout().getProgramAddressSpace());
};
bool parseOptionalParamAttrs(AttrBuilder &B);
bool parseOptionalReturnAttrs(AttrBuilder &B);
bool parseEnumAttribute(Attribute::AttrKind Attr, AttrBuilder &B,
bool InAttrGroup);
bool parseOptionalParamOrReturnAttrs(AttrBuilder &B, bool IsParam);
bool parseOptionalParamAttrs(AttrBuilder &B) {
return parseOptionalParamOrReturnAttrs(B, true);
}
bool parseOptionalReturnAttrs(AttrBuilder &B) {
return parseOptionalParamOrReturnAttrs(B, false);
}
bool parseOptionalLinkage(unsigned &Res, bool &HasLinkage,
unsigned &Visibility, unsigned &DLLStorageClass,
bool &DSOLocal);
Expand Down
Loading

0 comments on commit f59209a

Please sign in to comment.