diff options
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 87 |
1 files changed, 80 insertions, 7 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp index 584737e1d940..46ccd2129969 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -126,10 +126,15 @@ static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode) { void SystemZAsmPrinter::emitInstruction(const MachineInstr *MI) { SystemZMCInstLower Lower(MF->getContext(), *this); + const SystemZSubtarget *Subtarget = &MF->getSubtarget<SystemZSubtarget>(); MCInst LoweredMI; switch (MI->getOpcode()) { case SystemZ::Return: - LoweredMI = MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D); + if (Subtarget->isTargetXPLINK64()) + LoweredMI = + MCInstBuilder(SystemZ::B).addReg(SystemZ::R7D).addImm(2).addReg(0); + else + LoweredMI = MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D); break; case SystemZ::CondReturn: @@ -211,6 +216,26 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr *MI) { .addImm(0); break; + case SystemZ::CallBRASL_XPLINK64: + EmitToStreamer(*OutStreamer, + MCInstBuilder(SystemZ::BRASL) + .addReg(SystemZ::R7D) + .addExpr(Lower.getExpr(MI->getOperand(0), + MCSymbolRefExpr::VK_PLT))); + EmitToStreamer( + *OutStreamer, + MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R3D)); + return; + + case SystemZ::CallBASR_XPLINK64: + EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BASR) + .addReg(SystemZ::R7D) + .addReg(MI->getOperand(0).getReg())); + EmitToStreamer( + *OutStreamer, + MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D)); + return; + case SystemZ::CallBRASL: LoweredMI = MCInstBuilder(SystemZ::BRASL) .addReg(SystemZ::R14D) @@ -516,6 +541,30 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr *MI) { LowerPATCHPOINT(*MI, Lower); return; + case SystemZ::EXRL_Pseudo: { + unsigned TargetInsOpc = MI->getOperand(0).getImm(); + Register LenMinus1Reg = MI->getOperand(1).getReg(); + Register DestReg = MI->getOperand(2).getReg(); + int64_t DestDisp = MI->getOperand(3).getImm(); + Register SrcReg = MI->getOperand(4).getReg(); + int64_t SrcDisp = MI->getOperand(5).getImm(); + + MCSymbol *DotSym = nullptr; + MCInst ET = MCInstBuilder(TargetInsOpc).addReg(DestReg) + .addImm(DestDisp).addImm(1).addReg(SrcReg).addImm(SrcDisp); + MCInstSTIPair ET_STI(ET, &MF->getSubtarget()); + EXRLT2SymMap::iterator I = EXRLTargets2Sym.find(ET_STI); + if (I != EXRLTargets2Sym.end()) + DotSym = I->second; + else + EXRLTargets2Sym[ET_STI] = DotSym = OutContext.createTempSymbol(); + const MCSymbolRefExpr *Dot = MCSymbolRefExpr::create(DotSym, OutContext); + EmitToStreamer( + *OutStreamer, + MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot)); + return; + } + default: Lower.lower(MI, LoweredMI); break; @@ -673,6 +722,19 @@ void SystemZAsmPrinter::LowerPATCHPOINT(const MachineInstr &MI, getSubtargetInfo()); } +void SystemZAsmPrinter::emitEXRLTargetInstructions() { + if (EXRLTargets2Sym.empty()) + return; + // Switch to the .text section. + OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); + for (auto &I : EXRLTargets2Sym) { + OutStreamer->emitLabel(I.second); + const MCInstSTIPair &MCI_STI = I.first; + OutStreamer->emitInstruction(MCI_STI.first, *MCI_STI.second); + } + EXRLTargets2Sym.clear(); +} + // Convert a SystemZ-specific constant pool modifier into the associated // MCSymbolRefExpr variant kind. static MCSymbolRefExpr::VariantKind @@ -702,11 +764,21 @@ void SystemZAsmPrinter::emitMachineConstantPoolValue( bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) { - if (ExtraCode) - return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS); - SystemZMCInstLower Lower(MF->getContext(), *this); - MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo))); - SystemZInstPrinter::printOperand(MO, MAI, OS); + const MCRegisterInfo &MRI = *TM.getMCRegisterInfo(); + const MachineOperand &MO = MI->getOperand(OpNo); + MCOperand MCOp; + if (ExtraCode) { + if (ExtraCode[0] == 'N' && !ExtraCode[1] && MO.isReg() && + SystemZ::GR128BitRegClass.contains(MO.getReg())) + MCOp = + MCOperand::createReg(MRI.getSubReg(MO.getReg(), SystemZ::subreg_l64)); + else + return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS); + } else { + SystemZMCInstLower Lower(MF->getContext(), *this); + MCOp = Lower.lowerOperand(MO); + } + SystemZInstPrinter::printOperand(MCOp, MAI, OS); return false; } @@ -714,13 +786,14 @@ bool SystemZAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) { - SystemZInstPrinter::printAddress(MI->getOperand(OpNo).getReg(), + SystemZInstPrinter::printAddress(MAI, MI->getOperand(OpNo).getReg(), MI->getOperand(OpNo + 1).getImm(), MI->getOperand(OpNo + 2).getReg(), OS); return false; } void SystemZAsmPrinter::emitEndOfAsmFile(Module &M) { + emitEXRLTargetInstructions(); emitStackMaps(SM); } |