summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-08-05 22:26:15 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-08-05 22:26:15 +0000
commit5672a893e536a3865d9592cc2f21e8e608af52ac (patch)
treec6b3381164634e332c8c0ddd43c4bd89e33fc859 /llvm/lib/CodeGen/MIRParser
parent2b34fd932069e068ea55494706b8b2012f3270d0 (diff)
downloadbcm5719-llvm-5672a893e536a3865d9592cc2f21e8e608af52ac.tar.gz
bcm5719-llvm-5672a893e536a3865d9592cc2f21e8e608af52ac.zip
MIR Serialization: Serialize the machine operand's offset.
This commit serializes the offset for the following operands: target index, global address, external symbol, constant pool index, and block address. llvm-svn: 244157
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.cpp4
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.h2
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp39
3 files changed, 40 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index da79e1c070d..fece542d60e 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -399,6 +399,10 @@ static MIToken::TokenKind symbolToken(char C) {
return MIToken::lparen;
case ')':
return MIToken::rparen;
+ case '+':
+ return MIToken::plus;
+ case '-':
+ return MIToken::minus;
default:
return MIToken::Error;
}
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h
index 9896f7bcad7..064f68e2d5d 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.h
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.h
@@ -40,6 +40,8 @@ struct MIToken {
exclaim,
lparen,
rparen,
+ plus,
+ minus,
// Keywords
kw_implicit,
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index a30a4a9a83f..1a47c5865bb 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -120,6 +120,7 @@ public:
bool parseBlockAddressOperand(MachineOperand &Dest);
bool parseTargetIndexOperand(MachineOperand &Dest);
bool parseMachineOperand(MachineOperand &Dest);
+ bool parseOperandsOffset(MachineOperand &Op);
bool parseIRValue(Value *&V);
bool parseMemoryOperandFlag(unsigned &Flags);
bool parseMachineMemoryOperand(MachineMemOperand *&Dest);
@@ -693,9 +694,11 @@ bool MIParser::parseGlobalAddressOperand(MachineOperand &Dest) {
GlobalValue *GV = nullptr;
if (parseGlobalValue(GV))
return true;
- Dest = MachineOperand::CreateGA(GV, /*Offset=*/0);
- // TODO: Parse offset and target flags.
lex();
+ Dest = MachineOperand::CreateGA(GV, /*Offset=*/0);
+ // TODO: Parse the target flags.
+ if (parseOperandsOffset(Dest))
+ return true;
return false;
}
@@ -708,8 +711,10 @@ bool MIParser::parseConstantPoolIndexOperand(MachineOperand &Dest) {
if (ConstantInfo == PFS.ConstantPoolSlots.end())
return error("use of undefined constant '%const." + Twine(ID) + "'");
lex();
- // TODO: Parse offset and target flags.
+ // TODO: Parse the target flags.
Dest = MachineOperand::CreateCPI(ID, /*Offset=*/0);
+ if (parseOperandsOffset(Dest))
+ return true;
return false;
}
@@ -733,6 +738,8 @@ bool MIParser::parseExternalSymbolOperand(MachineOperand &Dest) {
lex();
// TODO: Parse the target flags.
Dest = MachineOperand::CreateES(Symbol);
+ if (parseOperandsOffset(Dest))
+ return true;
return false;
}
@@ -882,8 +889,10 @@ bool MIParser::parseBlockAddressOperand(MachineOperand &Dest) {
lex();
if (expectAndConsume(MIToken::rparen))
return true;
- // TODO: parse offset and target flags.
+ // TODO: parse the target flags.
Dest = MachineOperand::CreateBA(BlockAddress::get(F, BB), /*Offset=*/0);
+ if (parseOperandsOffset(Dest))
+ return true;
return false;
}
@@ -900,8 +909,10 @@ bool MIParser::parseTargetIndexOperand(MachineOperand &Dest) {
lex();
if (expectAndConsume(MIToken::rparen))
return true;
- // TODO: Parse the offset and target flags.
+ // TODO: Parse the target flags.
Dest = MachineOperand::CreateTargetIndex(unsigned(Index), /*Offset=*/0);
+ if (parseOperandsOffset(Dest))
+ return true;
return false;
}
@@ -971,6 +982,24 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest) {
return false;
}
+bool MIParser::parseOperandsOffset(MachineOperand &Op) {
+ if (Token.isNot(MIToken::plus) && Token.isNot(MIToken::minus))
+ return false;
+ StringRef Sign = Token.stringValue();
+ bool IsNegative = Token.is(MIToken::minus);
+ lex();
+ if (Token.isNot(MIToken::IntegerLiteral))
+ return error("expected an integer literal after '" + Sign + "'");
+ if (Token.integerValue().getMinSignedBits() > 64)
+ return error("expected 64-bit integer (too large)");
+ int64_t Offset = Token.integerValue().getExtValue();
+ if (IsNegative)
+ Offset = -Offset;
+ lex();
+ Op.setOffset(Offset);
+ return false;
+}
+
bool MIParser::parseIRValue(Value *&V) {
switch (Token.kind()) {
case MIToken::NamedIRValue: {
OpenPOWER on IntegriCloud