diff options
| author | Reid Kleckner <rnk@google.com> | 2016-06-08 20:34:29 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2016-06-08 20:34:29 +0000 |
| commit | de3d8b500f536bf091844a3fa5afa0848981f8ee (patch) | |
| tree | c523ec40adfa362f0d1cdd6f4da60702180d4263 /llvm/lib/AsmParser | |
| parent | 384d0f219d92b327a3a38ca613257dbf5e0911f1 (diff) | |
| download | bcm5719-llvm-de3d8b500f536bf091844a3fa5afa0848981f8ee.tar.gz bcm5719-llvm-de3d8b500f536bf091844a3fa5afa0848981f8ee.zip | |
[DebugInfo] Add calling convention support for DWARF and CodeView
Summary:
Now DISubroutineType has a 'cc' field which should be a DW_CC_ enum. If
it is present and non-zero, the backend will emit it as a
DW_AT_calling_convention attribute. On the CodeView side, we translate
it to the appropriate enum for the LF_PROCEDURE record.
I added a new LLVM vendor specific enum to the list of DWARF calling
conventions. DWARF does not appear to attempt to standardize these, so I
assume it's OK to do this until we coordinate with GCC on how to emit
vectorcall convention functions.
Reviewers: dexonsmith, majnemer, aaboud, amccarth
Subscribers: mehdi_amini, llvm-commits
Differential Revision: http://reviews.llvm.org/D21114
llvm-svn: 272197
Diffstat (limited to 'llvm/lib/AsmParser')
| -rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 25 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 1 |
3 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index bf457a95cd7..1ba698ebd61 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -793,6 +793,7 @@ lltok::Kind LLLexer::LexIdentifier() { DWKEYWORD(ATE, DwarfAttEncoding); DWKEYWORD(VIRTUALITY, DwarfVirtuality); DWKEYWORD(LANG, DwarfLang); + DWKEYWORD(CC, DwarfCC); DWKEYWORD(OP, DwarfOp); DWKEYWORD(MACINFO, DwarfMacinfo); #undef DWKEYWORD diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 8081ef23297..cc7b98fa56d 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3341,6 +3341,9 @@ struct DwarfVirtualityField : public MDUnsignedField { struct DwarfLangField : public MDUnsignedField { DwarfLangField() : MDUnsignedField(0, dwarf::DW_LANG_hi_user) {} }; +struct DwarfCCField : public MDUnsignedField { + DwarfCCField() : MDUnsignedField(0, dwarf::DW_CC_hi_user) {} +}; struct EmissionKindField : public MDUnsignedField { EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {} }; @@ -3484,6 +3487,24 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfLangField &Result) { } template <> +bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfCCField &Result) { + if (Lex.getKind() == lltok::APSInt) + return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result)); + + if (Lex.getKind() != lltok::DwarfCC) + return TokError("expected DWARF calling convention"); + + unsigned CC = dwarf::getCallingConvention(Lex.getStrVal()); + if (!CC) + return TokError("invalid DWARF calling convention" + Twine(" '") + Lex.getStrVal() + + "'"); + assert(CC <= Result.Max && "Expected valid DWARF calling convention"); + Result.assign(CC); + Lex.Lex(); + return false; +} + +template <> bool LLParser::ParseMDField(LocTy Loc, StringRef Name, EmissionKindField &Result) { if (Lex.getKind() == lltok::APSInt) return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result)); @@ -3863,11 +3884,13 @@ bool LLParser::ParseDICompositeType(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseDISubroutineType(MDNode *&Result, bool IsDistinct) { #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ OPTIONAL(flags, DIFlagField, ); \ + OPTIONAL(cc, DwarfCCField, ); \ REQUIRED(types, MDField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS - Result = GET_OR_DISTINCT(DISubroutineType, (Context, flags.Val, types.Val)); + Result = GET_OR_DISTINCT(DISubroutineType, + (Context, flags.Val, cc.Val, types.Val)); return false; } diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 9713cd67598..85881d6f11b 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -344,6 +344,7 @@ enum Kind { DwarfAttEncoding, // DW_ATE_foo DwarfVirtuality, // DW_VIRTUALITY_foo DwarfLang, // DW_LANG_foo + DwarfCC, // DW_CC_foo EmissionKind, // lineTablesOnly DwarfOp, // DW_OP_foo DIFlag, // DIFlagFoo |

