summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-07-26 17:28:01 +0000
committerTim Northover <tnorthover@apple.com>2016-07-26 17:28:01 +0000
commit26e40bdb9b52318c7cb5506adcfcab580f7a02d0 (patch)
tree97c1041392eea35fea5cb67417d26c0ad28f2dda /llvm/lib
parent3104a6bad05b9b1432b7afd5c31e1318bd8e1814 (diff)
downloadbcm5719-llvm-26e40bdb9b52318c7cb5506adcfcab580f7a02d0.tar.gz
bcm5719-llvm-26e40bdb9b52318c7cb5506adcfcab580f7a02d0.zip
GlobalISel: omit braces on MachineInstr types when there's only one.
Tidies up the representation a bit in the common case. llvm-svn: 276772
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp14
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp9
2 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index b1292bb48b0..170f9735d1f 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -598,14 +598,20 @@ bool MIParser::parse(MachineInstr *&MI) {
SmallVector<LLT, 1> Tys;
if (isPreISelGenericOpcode(OpCode)) {
// For generic opcode, at least one type is mandatory.
- expectAndConsume(MIToken::lbrace);
+ auto Loc = Token.location();
+ bool ManyTypes = Token.is(MIToken::lbrace);
+ if (ManyTypes)
+ lex();
+
+ // Now actually parse the type(s).
do {
- auto Loc = Token.location();
Tys.resize(Tys.size() + 1);
if (parseLowLevelType(Loc, Tys[Tys.size() - 1]))
return true;
- } while (consumeIfPresent(MIToken::comma));
- expectAndConsume(MIToken::rbrace);
+ } while (ManyTypes && consumeIfPresent(MIToken::comma));
+
+ if (ManyTypes)
+ expectAndConsume(MIToken::rbrace);
}
// Parse the remaining machine operands.
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 7946fc2676f..f8922dabad9 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -566,13 +566,14 @@ void MIPrinter::print(const MachineInstr &MI) {
OS << TII->getName(MI.getOpcode());
if (isPreISelGenericOpcode(MI.getOpcode())) {
assert(MI.getType().isValid() && "Generic instructions must have a type");
- OS << " { ";
- for (unsigned i = 0; i < MI.getNumTypes(); ++i) {
+ unsigned NumTypes = MI.getNumTypes();
+ OS << (NumTypes > 1 ? " {" : "") << ' ';
+ for (unsigned i = 0; i < NumTypes; ++i) {
MI.getType(i).print(OS);
- if (i + 1 != MI.getNumTypes())
+ if (i + 1 != NumTypes)
OS << ", ";
}
- OS << " } ";
+ OS << (NumTypes > 1 ? " }" : "") << ' ';
}
if (I < E)
OS << ' ';
OpenPOWER on IntegriCloud