summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-08-04 00:24:45 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-08-04 00:24:45 +0000
commita518b79601dda654d0f96bc82a5a0dcca10ab9c4 (patch)
tree20e175158509eb39490799549a973c2435b03bc2 /llvm/lib/CodeGen
parent845f40ada6707d2571e6410a7e1989c8c7073f5e (diff)
downloadbcm5719-llvm-a518b79601dda654d0f96bc82a5a0dcca10ab9c4.tar.gz
bcm5719-llvm-a518b79601dda654d0f96bc82a5a0dcca10ab9c4.zip
MIR Serialization: Serialize the 'volatile' machine memory operand flag.
llvm-svn: 243923
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.cpp1
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.h3
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp22
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp2
4 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index 81cb9e7d6f9..adc72e2a566 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -156,6 +156,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
.Case("x86_fp80", MIToken::kw_x86_fp80)
.Case("fp128", MIToken::kw_fp128)
.Case("ppc_fp128", MIToken::kw_ppc_fp128)
+ .Case("volatile", MIToken::kw_volatile)
.Default(MIToken::Identifier);
}
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h
index d33e0499f27..ccf8ffe15e5 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.h
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.h
@@ -61,6 +61,7 @@ struct MIToken {
kw_x86_fp80,
kw_fp128,
kw_ppc_fp128,
+ kw_volatile,
// Identifier tokens
Identifier,
@@ -115,6 +116,8 @@ public:
Kind == kw_dead || Kind == kw_killed || Kind == kw_undef;
}
+ bool isMemoryOperandFlag() const { return Kind == kw_volatile; }
+
bool is(TokenKind K) const { return Kind == K; }
bool isNot(TokenKind K) const { return Kind != K; }
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index e1770cd7fdb..70ce67f132f 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -135,6 +135,7 @@ public:
bool parseTargetIndexOperand(MachineOperand &Dest);
bool parseMachineOperand(MachineOperand &Dest);
bool parseIRValue(Value *&V);
+ bool parseMemoryOperandFlag(unsigned &Flags);
bool parseMachineMemoryOperand(MachineMemOperand *&Dest);
private:
@@ -987,14 +988,31 @@ bool MIParser::getUint64(uint64_t &Result) {
return false;
}
+bool MIParser::parseMemoryOperandFlag(unsigned &Flags) {
+ switch (Token.kind()) {
+ case MIToken::kw_volatile:
+ Flags |= MachineMemOperand::MOVolatile;
+ break;
+ // TODO: report an error when we specify the same flag more than once.
+ // TODO: parse the other memory operand flags.
+ default:
+ llvm_unreachable("The current token should be a memory operand flag");
+ }
+ lex();
+ return false;
+}
+
bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
if (expectAndConsume(MIToken::lparen))
return true;
- // TODO: Parse the operand's flags.
+ unsigned Flags = 0;
+ while (Token.isMemoryOperandFlag()) {
+ if (parseMemoryOperandFlag(Flags))
+ return true;
+ }
if (Token.isNot(MIToken::Identifier) ||
(Token.stringValue() != "load" && Token.stringValue() != "store"))
return error("expected 'load' or 'store' memory operation");
- unsigned Flags = 0;
if (Token.stringValue() == "load")
Flags |= MachineMemOperand::MOLoad;
else
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 9c5988c32e4..fb5a36ce9a7 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -608,6 +608,8 @@ void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) {
void MIPrinter::print(const MachineMemOperand &Op) {
OS << '(';
// TODO: Print operand's other flags.
+ if (Op.isVolatile())
+ OS << "volatile ";
if (Op.isLoad())
OS << "load ";
else {
OpenPOWER on IntegriCloud