mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
MIR Serialization: Serialize the metadata machine operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242916 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ struct MIToken {
|
||||
equal,
|
||||
underscore,
|
||||
colon,
|
||||
exclaim,
|
||||
|
||||
// Keywords
|
||||
kw_implicit,
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user