diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 9 |
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 << ' '; |

