Index: lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp =================================================================== --- lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -243,6 +243,11 @@ return Kind == KindImmTLS; } + const ImmTLSOp getImmTLS() const { + assert(Kind == KindImmTLS && "Not a TLS immediate"); + return ImmTLS; + } + // Memory operands. bool isMem() const override { return Kind == KindMem; @@ -623,8 +628,46 @@ { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_BDAddr64Disp12, MCK_AnyReg } } }; +static void printMCExpr(const MCExpr *E, raw_ostream &OS) { + if (!E) { + OS << "?"; + return; + } + if (auto *CE = dyn_cast(E)) + OS << "'" << *CE << "'"; + else if (auto *UE = dyn_cast(E)) + OS << "'" << *UE << "'"; + else if (auto *BE = dyn_cast(E)) + OS << "'" << *BE << "'"; + else if (auto *SRE = dyn_cast(E)) + OS << "'" << *SRE << "'"; + else + OS << "'" << *E << "'"; +} + void SystemZOperand::print(raw_ostream &OS) const { - llvm_unreachable("Not implemented"); + switch (Kind) { + break; + case KindToken: + OS << "'" << getToken() << "'"; + break; + case KindReg: + OS << "'" << getReg() << "'"; + break; + case KindImm: + printMCExpr(getImm(), OS); + break; + case KindImmTLS: + printMCExpr(getImmTLS().Imm, OS); + OS << ", "; + printMCExpr(getImmTLS().Sym, OS); + break; + default: + case KindMem: + case KindInvalid: + OS << "?"; + break; + } } // Parse one register of the form %. Index: test/MC/SystemZ/asm-match.s =================================================================== --- /dev/null +++ test/MC/SystemZ/asm-match.s @@ -0,0 +1,27 @@ +// REQUIRES: asserts +// RUN: llvm-mc -triple s390x-linux-gnu -debug-only=asm-matcher %s 2>&1 | FileCheck %s +// +// Check that debug output gives some reasonable output. + +// CHECK: AsmMatcher: found 1 encodings with mnemonic 'llill' +// CHECK: Trying to match opcode LLILL +// CHECK: Matching formal operand class MCK_GR64 against actual operand at index 1 ('138'): match success using generic matcher +// CHECK: Matching formal operand class MCK_U16Imm against actual operand at index 2 (0): match success using generic matcher +// CHECK: Matching formal operand class InvalidMatchClass against actual operand at index 3: actual operand index out of range Opcode result: complete match, selecting this opcode +// CHECK: AsmMatcher: found 1 encodings with mnemonic 'lgr' +// CHECK: Trying to match opcode LGR +// CHECK: Matching formal operand class MCK_GR64 against actual operand at index 1 ('139'): match success using generic matcher +// CHECK: Matching formal operand class MCK_GR64 against actual operand at index 2 ('138'): match success using generic matcher +// CHECK: Matching formal operand class InvalidMatchClass against actual operand at index 3: actual operand index out of range Opcode result: complete match, selecting this opcode +// CHECK: AsmMatcher: found 1 encodings with mnemonic 'j' +// CHECK: Trying to match opcode J +// CHECK: Matching formal operand class MCK_PCRel16 against actual operand at index 1 (.Ltmp0+2): match success using generic matcher +// CHECK: Matching formal operand class InvalidMatchClass against actual operand at index 2: actual operand index out of range Opcode result: complete match, selecting this opcode + +.Ltmp0: + llill %r0, 0 + lgr %r1, %r0 + j .Ltmp0+2 + stmg %r13, %r15, 104(%r15) + brasl %r14, fun +