diff options
author | Manman Ren <manman.ren@gmail.com> | 2016-04-01 21:41:15 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2016-04-01 21:41:15 +0000 |
commit | 9bfd0d03e92d4bbb0ebf6171f5e0692edf9820c3 (patch) | |
tree | 9a24f292b9df7e108e4a60d458c5668a2409157d /llvm/lib/AsmParser/LLParser.cpp | |
parent | a3d15f3a5e645e75093f2f5f2b2065bca396c16e (diff) | |
download | llvm-9bfd0d03e92d4bbb0ebf6171f5e0692edf9820c3.zip llvm-9bfd0d03e92d4bbb0ebf6171f5e0692edf9820c3.tar.gz llvm-9bfd0d03e92d4bbb0ebf6171f5e0692edf9820c3.tar.bz2 |
Swift Calling Convention: add swifterror attribute.
A ``swifterror`` attribute can be applied to a function parameter or an
AllocaInst.
This commit does not include any target-specific change. The target-specific
optimization will come as a follow-up patch.
Differential Revision: http://reviews.llvm.org/D18092
llvm-svn: 265189
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index e72686d..d326edf 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1088,6 +1088,7 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B, case lltok::kw_nonnull: case lltok::kw_returned: case lltok::kw_sret: + case lltok::kw_swifterror: case lltok::kw_swiftself: HaveError |= Error(Lex.getLoc(), @@ -1362,6 +1363,7 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) { case lltok::kw_returned: B.addAttribute(Attribute::Returned); break; case lltok::kw_signext: B.addAttribute(Attribute::SExt); break; case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break; + case lltok::kw_swifterror: B.addAttribute(Attribute::SwiftError); break; case lltok::kw_swiftself: B.addAttribute(Attribute::SwiftSelf); break; case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break; @@ -1450,6 +1452,7 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) { case lltok::kw_nocapture: case lltok::kw_returned: case lltok::kw_sret: + case lltok::kw_swifterror: case lltok::kw_swiftself: HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute"); break; @@ -5802,7 +5805,8 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, //===----------------------------------------------------------------------===// /// ParseAlloc -/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)? +/// ::= 'alloca' 'inalloca'? 'swifterror'? Type (',' TypeAndValue)? +/// (',' 'align' i32)? int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { Value *Size = nullptr; LocTy SizeLoc, TyLoc; @@ -5810,6 +5814,7 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { Type *Ty = nullptr; bool IsInAlloca = EatIfPresent(lltok::kw_inalloca); + bool IsSwiftError = EatIfPresent(lltok::kw_swifterror); if (ParseType(Ty, TyLoc)) return true; @@ -5834,6 +5839,7 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { AllocaInst *AI = new AllocaInst(Ty, Size, Alignment); AI->setUsedWithInAlloca(IsInAlloca); + AI->setSwiftError(IsSwiftError); Inst = AI; return AteExtraComma ? InstExtraComma : InstNormal; } |