119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//===-- SystemZAsmPrinter.cpp - SystemZ LLVM assembly writer ---------------===//
219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//
319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//                     The LLVM Compiler Infrastructure
419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//
519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// This file is distributed under the University of Illinois Open Source
619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// License. See LICENSE.TXT for details.
719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//
819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//===----------------------------------------------------------------------===//
919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//
1019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// This file contains a printer that converts from our internal representation
1119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// of machine-dependent LLVM code to the SystemZ assembly language.
1219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//
1319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman//===----------------------------------------------------------------------===//
1419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
1519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#define DEBUG_TYPE "asm-printer"
1619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "SystemZ.h"
1719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "SystemZInstrInfo.h"
1819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "SystemZTargetMachine.h"
1919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Constants.h"
2019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/DerivedTypes.h"
2119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Module.h"
2219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Assembly/Writer.h"
2319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/CodeGen/AsmPrinter.h"
2419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/CodeGen/MachineModuleInfo.h"
2519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/CodeGen/MachineFunctionPass.h"
2619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/CodeGen/MachineConstantPool.h"
2719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/MC/MCStreamer.h"
2819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/MC/MCAsmInfo.h"
2919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/MC/MCSymbol.h"
3019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Target/Mangler.h"
3119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/ADT/SmallString.h"
3219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/TargetRegistry.h"
3319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/raw_ostream.h"
3419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanusing namespace llvm;
3519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
3619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumannamespace {
3719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  class SystemZAsmPrinter : public AsmPrinter {
3819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  public:
3919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    SystemZAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
4019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      : AsmPrinter(TM, Streamer) {}
4119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
4219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    virtual const char *getPassName() const {
4319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      return "SystemZ Assembly Printer";
4419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
4519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
4619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
4719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                      const char* Modifier = 0);
4819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printPCRelImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
4919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printRIAddrOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
5019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                            const char* Modifier = 0);
5119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printRRIAddrOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
5219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                             const char* Modifier = 0);
5319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printS16ImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O) {
5419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << (int16_t)MI->getOperand(OpNum).getImm();
5519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printU16ImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O) {
5719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << (uint16_t)MI->getOperand(OpNum).getImm();
5819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
5919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printS32ImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O) {
6019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << (int32_t)MI->getOperand(OpNum).getImm();
6119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
6219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printU32ImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O) {
6319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << (uint32_t)MI->getOperand(OpNum).getImm();
6419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
6519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
6619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void printInstruction(const MachineInstr *MI, raw_ostream &O);
6719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    static const char *getRegisterName(unsigned RegNo);
6819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
6919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    void EmitInstruction(const MachineInstr *MI);
7019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  };
7119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman} // end of anonymous namespace
7219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
7319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "SystemZGenAsmWriter.inc"
7419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
7519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanvoid SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) {
7619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  SmallString<128> Str;
7719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  raw_svector_ostream OS(Str);
7819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  printInstruction(MI, OS);
7919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  OutStreamer.EmitRawText(OS.str());
8019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
8119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
8219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanvoid SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum,
8319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                             raw_ostream &O) {
8419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const MachineOperand &MO = MI->getOperand(OpNum);
8519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  switch (MO.getType()) {
8619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_Immediate:
8719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << MO.getImm();
8819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
8919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_MachineBasicBlock:
9019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << *MO.getMBB()->getSymbol();
9119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
9219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_GlobalAddress: {
9319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    const GlobalValue *GV = MO.getGlobal();
9419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << *Mang->getSymbol(GV);
9519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
9619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    // Assemble calls via PLT for externally visible symbols if PIC.
9719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    if (TM.getRelocationModel() == Reloc::PIC_ &&
9819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman        !GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
9919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman        !GV->hasLocalLinkage())
10019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << "@PLT";
10119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
10219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    printOffset(MO.getOffset(), O);
10319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
10419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
10519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_ExternalSymbol: {
10619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    std::string Name(MAI->getGlobalPrefix());
10719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    Name += MO.getSymbolName();
10819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << Name;
10919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
11019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    if (TM.getRelocationModel() == Reloc::PIC_)
11119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << "@PLT";
11219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
11319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
11419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
11519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  default:
11619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    assert(0 && "Not implemented yet!");
11719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
11819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
11919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
12019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
12119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanvoid SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
12219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                     raw_ostream &O, const char *Modifier) {
12319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const MachineOperand &MO = MI->getOperand(OpNum);
12419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  switch (MO.getType()) {
12519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_Register: {
12619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    assert (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
12719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman            "Virtual registers should be already mapped!");
12819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    unsigned Reg = MO.getReg();
12919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    if (Modifier && strncmp(Modifier, "subreg", 6) == 0) {
13019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      if (strncmp(Modifier + 7, "even", 4) == 0)
13119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman        Reg = TM.getRegisterInfo()->getSubReg(Reg, SystemZ::subreg_32bit);
13219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      else if (strncmp(Modifier + 7, "odd", 3) == 0)
13319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman        Reg = TM.getRegisterInfo()->getSubReg(Reg, SystemZ::subreg_odd32);
13419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      else
13519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman        assert(0 && "Invalid subreg modifier");
13619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
13719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
13819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << '%' << getRegisterName(Reg);
13919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
14019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
14119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_Immediate:
14219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << MO.getImm();
14319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
14419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_MachineBasicBlock:
14519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << *MO.getMBB()->getSymbol();
14619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
14719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_JumpTableIndex:
14819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
14919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      << MO.getIndex();
15019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
15119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    return;
15219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_ConstantPoolIndex:
15319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
15419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      << MO.getIndex();
15519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
15619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    printOffset(MO.getOffset(), O);
15719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    break;
15819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_GlobalAddress:
15919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << *Mang->getSymbol(MO.getGlobal());
16019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    break;
16119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case MachineOperand::MO_ExternalSymbol: {
16219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << *GetExternalSymbolSymbol(MO.getSymbolName());
16319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    break;
16419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
16519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  default:
16619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    assert(0 && "Not implemented yet!");
16719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
16819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
16919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  switch (MO.getTargetFlags()) {
17019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  default: assert(0 && "Unknown target flag on GV operand");
17119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case SystemZII::MO_NO_FLAG:
17219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    break;
17319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case SystemZII::MO_GOTENT:    O << "@GOTENT";    break;
17419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  case SystemZII::MO_PLT:       O << "@PLT";       break;
17519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
17619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
17719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  printOffset(MO.getOffset(), O);
17819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
17919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
18019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanvoid SystemZAsmPrinter::printRIAddrOperand(const MachineInstr *MI, int OpNum,
18119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                           raw_ostream &O,
18219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                           const char *Modifier) {
18319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const MachineOperand &Base = MI->getOperand(OpNum);
18419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
18519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Print displacement operand.
18619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  printOperand(MI, OpNum+1, O);
18719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
18819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Print base operand (if any)
18919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  if (Base.getReg()) {
19019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << '(';
19119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    printOperand(MI, OpNum, O);
19219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << ')';
19319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  }
19419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
19519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
19619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanvoid SystemZAsmPrinter::printRRIAddrOperand(const MachineInstr *MI, int OpNum,
19719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                            raw_ostream &O,
19819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                            const char *Modifier) {
19919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const MachineOperand &Base = MI->getOperand(OpNum);
20019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const MachineOperand &Index = MI->getOperand(OpNum+2);
20119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
20219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Print displacement operand.
20319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  printOperand(MI, OpNum+1, O);
20419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
20519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Print base operand (if any)
20619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  if (Base.getReg()) {
20719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << '(';
20819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    printOperand(MI, OpNum, O);
20919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    if (Index.getReg()) {
21019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      O << ',';
21119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      printOperand(MI, OpNum+2, O);
21219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    }
21319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    O << ')';
21419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  } else
21519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    assert(!Index.getReg() && "Should allocate base register first!");
21619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
21719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
21819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman// Force static initialization.
21919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Baumanextern "C" void LLVMInitializeSystemZAsmPrinter() {
22019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  RegisterAsmPrinter<SystemZAsmPrinter> X(TheSystemZTarget);
22119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman}
222