diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-07-22 21:15:11 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-07-22 21:15:11 +0000 |
commit | 46d760d161d4d6255d02cde48831c079fb362769 (patch) | |
tree | 4e8afa5095c4eef9512f4a66b0592f5a186ed855 /llvm/lib/CodeGen/MIRParser | |
parent | 2873810c6f81a288bcb53b0da9af4c21858a4f20 (diff) | |
download | bcm5719-llvm-46d760d161d4d6255d02cde48831c079fb362769.tar.gz bcm5719-llvm-46d760d161d4d6255d02cde48831c079fb362769.zip |
MIR Serialization: Serialize the machine instruction's debug location.
llvm-svn: 242938
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.h | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 15 |
3 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp index 6c3d2e064ac..1b483330e54 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -123,6 +123,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) { .Case("killed", MIToken::kw_killed) .Case("undef", MIToken::kw_undef) .Case("frame-setup", MIToken::kw_frame_setup) + .Case("debug-location", MIToken::kw_debug_location) .Case(".cfi_def_cfa_offset", MIToken::kw_cfi_def_cfa_offset) .Default(MIToken::Identifier); } diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h index 79972bbc533..71356e37971 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -45,6 +45,7 @@ struct MIToken { kw_killed, kw_undef, kw_frame_setup, + kw_debug_location, kw_cfi_def_cfa_offset, // Identifier tokens diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index edb4259fea7..de2f6158b45 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -205,7 +205,7 @@ bool MIParser::parse(MachineInstr *&MI) { // TODO: Parse the bundle instruction flags and memory operands. // Parse the remaining machine operands. - while (Token.isNot(MIToken::Eof)) { + while (Token.isNot(MIToken::Eof) && Token.isNot(MIToken::kw_debug_location)) { auto Loc = Token.location(); if (parseMachineOperand(MO)) return true; @@ -217,6 +217,17 @@ bool MIParser::parse(MachineInstr *&MI) { lex(); } + DebugLoc DebugLocation; + if (Token.is(MIToken::kw_debug_location)) { + lex(); + if (Token.isNot(MIToken::exclaim)) + return error("expected a metadata node after 'debug-location'"); + MDNode *Node = nullptr; + if (parseMDNode(Node)) + return true; + DebugLocation = DebugLoc(Node); + } + const auto &MCID = MF.getSubtarget().getInstrInfo()->get(OpCode); if (!MCID.isVariadic()) { // FIXME: Move the implicit operand verification to the machine verifier. @@ -225,7 +236,7 @@ bool MIParser::parse(MachineInstr *&MI) { } // TODO: Check for extraneous machine operands. - MI = MF.CreateMachineInstr(MCID, DebugLoc(), /*NoImplicit=*/true); + MI = MF.CreateMachineInstr(MCID, DebugLocation, /*NoImplicit=*/true); MI->setFlags(Flags); for (const auto &Operand : Operands) MI->addOperand(MF, Operand.Operand); |