diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2015-07-22 17:58:46 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2015-07-22 17:58:46 +0000 |
| commit | 35e4446903a4edb1a7b0b2e4738185f38da83861 (patch) | |
| tree | 9bb4ba2a5294f520b5b397d6d4c17bb3e3c26544 /llvm/lib/CodeGen/MIRParser | |
| parent | cd1646823b5c8c62a6baa662de07cecfd993815f (diff) | |
| download | bcm5719-llvm-35e4446903a4edb1a7b0b2e4738185f38da83861.tar.gz bcm5719-llvm-35e4446903a4edb1a7b0b2e4738185f38da83861.zip | |
MIR Serialization: Serialize the metadata machine operands.
llvm-svn: 242916
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser')
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.h | 1 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 20 |
3 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp index c88333e6f59..6c3d2e064ac 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -310,6 +310,8 @@ static MIToken::TokenKind symbolToken(char C) { return MIToken::equal; case ':': return MIToken::colon; + case '!': + return MIToken::exclaim; default: return MIToken::Error; } diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h index 771f6047e5c..79972bbc533 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -36,6 +36,7 @@ struct MIToken { equal, underscore, colon, + exclaim, // Keywords kw_implicit, diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 498ca0615d5..212996bfaf5 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -112,6 +112,7 @@ public: bool parseConstantPoolIndexOperand(MachineOperand &Dest); bool parseJumpTableIndexOperand(MachineOperand &Dest); bool parseExternalSymbolOperand(MachineOperand &Dest); + bool parseMetadataOperand(MachineOperand &Dest); bool parseCFIOffset(int &Offset); bool parseCFIOperand(MachineOperand &Dest); bool parseMachineOperand(MachineOperand &Dest); @@ -575,6 +576,23 @@ bool MIParser::parseExternalSymbolOperand(MachineOperand &Dest) { return false; } +bool MIParser::parseMetadataOperand(MachineOperand &Dest) { + assert(Token.is(MIToken::exclaim)); + auto Loc = Token.location(); + lex(); + if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isSigned()) + return error("expected metadata id after '!'"); + unsigned ID; + if (getUnsigned(ID)) + return true; + auto NodeInfo = IRSlots.MetadataNodes.find(ID); + if (NodeInfo == IRSlots.MetadataNodes.end()) + return error(Loc, "use of undefined metadata '!" + Twine(ID) + "'"); + lex(); + Dest = MachineOperand::CreateMetadata(NodeInfo->second.get()); + return false; +} + bool MIParser::parseCFIOffset(int &Offset) { if (Token.isNot(MIToken::IntegerLiteral)) return error("expected a cfi offset"); @@ -628,6 +646,8 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest) { case MIToken::ExternalSymbol: case MIToken::QuotedExternalSymbol: return parseExternalSymbolOperand(Dest); + case MIToken::exclaim: + return parseMetadataOperand(Dest); case MIToken::kw_cfi_def_cfa_offset: return parseCFIOperand(Dest); case MIToken::Error: |

