10b57cec5SDimitry Andric //===-- MipsSEInstrInfo.cpp - Mips32/64 Instruction Information -----------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file contains the Mips32/64 implementation of the TargetInstrInfo class. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #include "MipsSEInstrInfo.h" 140b57cec5SDimitry Andric #include "MCTargetDesc/MipsInstPrinter.h" 150b57cec5SDimitry Andric #include "MipsAnalyzeImmediate.h" 160b57cec5SDimitry Andric #include "MipsMachineFunction.h" 170b57cec5SDimitry Andric #include "MipsTargetMachine.h" 180b57cec5SDimitry Andric #include "llvm/ADT/STLExtras.h" 190b57cec5SDimitry Andric #include "llvm/CodeGen/MachineInstrBuilder.h" 200b57cec5SDimitry Andric #include "llvm/CodeGen/MachineRegisterInfo.h" 21349cc55cSDimitry Andric #include "llvm/MC/TargetRegistry.h" 220b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 230b57cec5SDimitry Andric #include "llvm/Support/MathExtras.h" 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric using namespace llvm; 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric static unsigned getUnconditionalBranch(const MipsSubtarget &STI) { 280b57cec5SDimitry Andric if (STI.inMicroMipsMode()) 290b57cec5SDimitry Andric return STI.isPositionIndependent() ? Mips::B_MM : Mips::J_MM; 300b57cec5SDimitry Andric return STI.isPositionIndependent() ? Mips::B : Mips::J; 310b57cec5SDimitry Andric } 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric MipsSEInstrInfo::MipsSEInstrInfo(const MipsSubtarget &STI) 340b57cec5SDimitry Andric : MipsInstrInfo(STI, getUnconditionalBranch(STI)), RI() {} 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric const MipsRegisterInfo &MipsSEInstrInfo::getRegisterInfo() const { 370b57cec5SDimitry Andric return RI; 380b57cec5SDimitry Andric } 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric /// isLoadFromStackSlot - If the specified machine instruction is a direct 410b57cec5SDimitry Andric /// load from a stack slot, return the virtual or physical register number of 420b57cec5SDimitry Andric /// the destination along with the FrameIndex of the loaded stack slot. If 430b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 440b57cec5SDimitry Andric /// any side effects other than loading from the stack slot. 45*0fca6ea1SDimitry Andric Register MipsSEInstrInfo::isLoadFromStackSlot(const MachineInstr &MI, 460b57cec5SDimitry Andric int &FrameIndex) const { 470b57cec5SDimitry Andric unsigned Opc = MI.getOpcode(); 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric if ((Opc == Mips::LW) || (Opc == Mips::LD) || 500b57cec5SDimitry Andric (Opc == Mips::LWC1) || (Opc == Mips::LDC1) || (Opc == Mips::LDC164)) { 510b57cec5SDimitry Andric if ((MI.getOperand(1).isFI()) && // is a stack slot 520b57cec5SDimitry Andric (MI.getOperand(2).isImm()) && // the imm is zero 530b57cec5SDimitry Andric (isZeroImm(MI.getOperand(2)))) { 540b57cec5SDimitry Andric FrameIndex = MI.getOperand(1).getIndex(); 550b57cec5SDimitry Andric return MI.getOperand(0).getReg(); 560b57cec5SDimitry Andric } 570b57cec5SDimitry Andric } 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric return 0; 600b57cec5SDimitry Andric } 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric /// isStoreToStackSlot - If the specified machine instruction is a direct 630b57cec5SDimitry Andric /// store to a stack slot, return the virtual or physical register number of 640b57cec5SDimitry Andric /// the source reg along with the FrameIndex of the loaded stack slot. If 650b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 660b57cec5SDimitry Andric /// any side effects other than storing to the stack slot. 67*0fca6ea1SDimitry Andric Register MipsSEInstrInfo::isStoreToStackSlot(const MachineInstr &MI, 680b57cec5SDimitry Andric int &FrameIndex) const { 690b57cec5SDimitry Andric unsigned Opc = MI.getOpcode(); 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric if ((Opc == Mips::SW) || (Opc == Mips::SD) || 720b57cec5SDimitry Andric (Opc == Mips::SWC1) || (Opc == Mips::SDC1) || (Opc == Mips::SDC164)) { 730b57cec5SDimitry Andric if ((MI.getOperand(1).isFI()) && // is a stack slot 740b57cec5SDimitry Andric (MI.getOperand(2).isImm()) && // the imm is zero 750b57cec5SDimitry Andric (isZeroImm(MI.getOperand(2)))) { 760b57cec5SDimitry Andric FrameIndex = MI.getOperand(1).getIndex(); 770b57cec5SDimitry Andric return MI.getOperand(0).getReg(); 780b57cec5SDimitry Andric } 790b57cec5SDimitry Andric } 800b57cec5SDimitry Andric return 0; 810b57cec5SDimitry Andric } 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB, 840b57cec5SDimitry Andric MachineBasicBlock::iterator I, 85480093f4SDimitry Andric const DebugLoc &DL, MCRegister DestReg, 86480093f4SDimitry Andric MCRegister SrcReg, bool KillSrc) const { 870b57cec5SDimitry Andric unsigned Opc = 0, ZeroReg = 0; 880b57cec5SDimitry Andric bool isMicroMips = Subtarget.inMicroMipsMode(); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric if (Mips::GPR32RegClass.contains(DestReg)) { // Copy to CPU Reg. 910b57cec5SDimitry Andric if (Mips::GPR32RegClass.contains(SrcReg)) { 920b57cec5SDimitry Andric if (isMicroMips) 930b57cec5SDimitry Andric Opc = Mips::MOVE16_MM; 940b57cec5SDimitry Andric else 950b57cec5SDimitry Andric Opc = Mips::OR, ZeroReg = Mips::ZERO; 960b57cec5SDimitry Andric } else if (Mips::CCRRegClass.contains(SrcReg)) 970b57cec5SDimitry Andric Opc = Mips::CFC1; 980b57cec5SDimitry Andric else if (Mips::FGR32RegClass.contains(SrcReg)) 990b57cec5SDimitry Andric Opc = Mips::MFC1; 1000b57cec5SDimitry Andric else if (Mips::HI32RegClass.contains(SrcReg)) { 1010b57cec5SDimitry Andric Opc = isMicroMips ? Mips::MFHI16_MM : Mips::MFHI; 1020b57cec5SDimitry Andric SrcReg = 0; 1030b57cec5SDimitry Andric } else if (Mips::LO32RegClass.contains(SrcReg)) { 1040b57cec5SDimitry Andric Opc = isMicroMips ? Mips::MFLO16_MM : Mips::MFLO; 1050b57cec5SDimitry Andric SrcReg = 0; 1060b57cec5SDimitry Andric } else if (Mips::HI32DSPRegClass.contains(SrcReg)) 1070b57cec5SDimitry Andric Opc = Mips::MFHI_DSP; 1080b57cec5SDimitry Andric else if (Mips::LO32DSPRegClass.contains(SrcReg)) 1090b57cec5SDimitry Andric Opc = Mips::MFLO_DSP; 1100b57cec5SDimitry Andric else if (Mips::DSPCCRegClass.contains(SrcReg)) { 1110b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::RDDSP), DestReg).addImm(1 << 4) 1120b57cec5SDimitry Andric .addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc)); 1130b57cec5SDimitry Andric return; 1140b57cec5SDimitry Andric } 1150b57cec5SDimitry Andric else if (Mips::MSACtrlRegClass.contains(SrcReg)) 1160b57cec5SDimitry Andric Opc = Mips::CFCMSA; 1170b57cec5SDimitry Andric } 1180b57cec5SDimitry Andric else if (Mips::GPR32RegClass.contains(SrcReg)) { // Copy from CPU Reg. 1190b57cec5SDimitry Andric if (Mips::CCRRegClass.contains(DestReg)) 1200b57cec5SDimitry Andric Opc = Mips::CTC1; 1210b57cec5SDimitry Andric else if (Mips::FGR32RegClass.contains(DestReg)) 1220b57cec5SDimitry Andric Opc = Mips::MTC1; 1230b57cec5SDimitry Andric else if (Mips::HI32RegClass.contains(DestReg)) 1240b57cec5SDimitry Andric Opc = Mips::MTHI, DestReg = 0; 1250b57cec5SDimitry Andric else if (Mips::LO32RegClass.contains(DestReg)) 1260b57cec5SDimitry Andric Opc = Mips::MTLO, DestReg = 0; 1270b57cec5SDimitry Andric else if (Mips::HI32DSPRegClass.contains(DestReg)) 1280b57cec5SDimitry Andric Opc = Mips::MTHI_DSP; 1290b57cec5SDimitry Andric else if (Mips::LO32DSPRegClass.contains(DestReg)) 1300b57cec5SDimitry Andric Opc = Mips::MTLO_DSP; 1310b57cec5SDimitry Andric else if (Mips::DSPCCRegClass.contains(DestReg)) { 1320b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::WRDSP)) 1330b57cec5SDimitry Andric .addReg(SrcReg, getKillRegState(KillSrc)).addImm(1 << 4) 1340b57cec5SDimitry Andric .addReg(DestReg, RegState::ImplicitDefine); 1350b57cec5SDimitry Andric return; 1360b57cec5SDimitry Andric } else if (Mips::MSACtrlRegClass.contains(DestReg)) { 1370b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::CTCMSA)) 1380b57cec5SDimitry Andric .addReg(DestReg) 1390b57cec5SDimitry Andric .addReg(SrcReg, getKillRegState(KillSrc)); 1400b57cec5SDimitry Andric return; 1410b57cec5SDimitry Andric } 1420b57cec5SDimitry Andric } 1430b57cec5SDimitry Andric else if (Mips::FGR32RegClass.contains(DestReg, SrcReg)) 1440b57cec5SDimitry Andric Opc = Mips::FMOV_S; 1450b57cec5SDimitry Andric else if (Mips::AFGR64RegClass.contains(DestReg, SrcReg)) 1460b57cec5SDimitry Andric Opc = Mips::FMOV_D32; 1470b57cec5SDimitry Andric else if (Mips::FGR64RegClass.contains(DestReg, SrcReg)) 1480b57cec5SDimitry Andric Opc = Mips::FMOV_D64; 1490b57cec5SDimitry Andric else if (Mips::GPR64RegClass.contains(DestReg)) { // Copy to CPU64 Reg. 1500b57cec5SDimitry Andric if (Mips::GPR64RegClass.contains(SrcReg)) 1510b57cec5SDimitry Andric Opc = Mips::OR64, ZeroReg = Mips::ZERO_64; 1520b57cec5SDimitry Andric else if (Mips::HI64RegClass.contains(SrcReg)) 1530b57cec5SDimitry Andric Opc = Mips::MFHI64, SrcReg = 0; 1540b57cec5SDimitry Andric else if (Mips::LO64RegClass.contains(SrcReg)) 1550b57cec5SDimitry Andric Opc = Mips::MFLO64, SrcReg = 0; 1560b57cec5SDimitry Andric else if (Mips::FGR64RegClass.contains(SrcReg)) 1570b57cec5SDimitry Andric Opc = Mips::DMFC1; 1580b57cec5SDimitry Andric } 1590b57cec5SDimitry Andric else if (Mips::GPR64RegClass.contains(SrcReg)) { // Copy from CPU64 Reg. 1600b57cec5SDimitry Andric if (Mips::HI64RegClass.contains(DestReg)) 1610b57cec5SDimitry Andric Opc = Mips::MTHI64, DestReg = 0; 1620b57cec5SDimitry Andric else if (Mips::LO64RegClass.contains(DestReg)) 1630b57cec5SDimitry Andric Opc = Mips::MTLO64, DestReg = 0; 1640b57cec5SDimitry Andric else if (Mips::FGR64RegClass.contains(DestReg)) 1650b57cec5SDimitry Andric Opc = Mips::DMTC1; 1660b57cec5SDimitry Andric } 1670b57cec5SDimitry Andric else if (Mips::MSA128BRegClass.contains(DestReg)) { // Copy to MSA reg 1680b57cec5SDimitry Andric if (Mips::MSA128BRegClass.contains(SrcReg)) 1690b57cec5SDimitry Andric Opc = Mips::MOVE_V; 1700b57cec5SDimitry Andric } 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric assert(Opc && "Cannot copy registers"); 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric MachineInstrBuilder MIB = BuildMI(MBB, I, DL, get(Opc)); 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andric if (DestReg) 1770b57cec5SDimitry Andric MIB.addReg(DestReg, RegState::Define); 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric if (SrcReg) 1800b57cec5SDimitry Andric MIB.addReg(SrcReg, getKillRegState(KillSrc)); 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andric if (ZeroReg) 1830b57cec5SDimitry Andric MIB.addReg(ZeroReg); 1840b57cec5SDimitry Andric } 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andric static bool isORCopyInst(const MachineInstr &MI) { 1870b57cec5SDimitry Andric switch (MI.getOpcode()) { 1880b57cec5SDimitry Andric default: 1890b57cec5SDimitry Andric break; 1900b57cec5SDimitry Andric case Mips::OR_MM: 1910b57cec5SDimitry Andric case Mips::OR: 1920b57cec5SDimitry Andric if (MI.getOperand(2).getReg() == Mips::ZERO) 1930b57cec5SDimitry Andric return true; 1940b57cec5SDimitry Andric break; 1950b57cec5SDimitry Andric case Mips::OR64: 1960b57cec5SDimitry Andric if (MI.getOperand(2).getReg() == Mips::ZERO_64) 1970b57cec5SDimitry Andric return true; 1980b57cec5SDimitry Andric break; 1990b57cec5SDimitry Andric } 2000b57cec5SDimitry Andric return false; 2010b57cec5SDimitry Andric } 2020b57cec5SDimitry Andric 2030b57cec5SDimitry Andric /// We check for the common case of 'or', as it's MIPS' preferred instruction 2040b57cec5SDimitry Andric /// for GPRs but we have to check the operands to ensure that is the case. 2050b57cec5SDimitry Andric /// Other move instructions for MIPS are directly identifiable. 206bdd1243dSDimitry Andric std::optional<DestSourcePair> 207480093f4SDimitry Andric MipsSEInstrInfo::isCopyInstrImpl(const MachineInstr &MI) const { 20806c3fb27SDimitry Andric if (MI.isMoveReg() || isORCopyInst(MI)) 209480093f4SDimitry Andric return DestSourcePair{MI.getOperand(0), MI.getOperand(1)}; 21006c3fb27SDimitry Andric 211bdd1243dSDimitry Andric return std::nullopt; 2120b57cec5SDimitry Andric } 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andric void MipsSEInstrInfo:: 2150b57cec5SDimitry Andric storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 2165ffd83dbSDimitry Andric Register SrcReg, bool isKill, int FI, 2170b57cec5SDimitry Andric const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, 2180b57cec5SDimitry Andric int64_t Offset) const { 2190b57cec5SDimitry Andric DebugLoc DL; 2200b57cec5SDimitry Andric MachineMemOperand *MMO = GetMemOperand(MBB, FI, MachineMemOperand::MOStore); 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andric unsigned Opc = 0; 2230b57cec5SDimitry Andric 2240b57cec5SDimitry Andric if (Mips::GPR32RegClass.hasSubClassEq(RC)) 2250b57cec5SDimitry Andric Opc = Mips::SW; 2260b57cec5SDimitry Andric else if (Mips::GPR64RegClass.hasSubClassEq(RC)) 2270b57cec5SDimitry Andric Opc = Mips::SD; 2280b57cec5SDimitry Andric else if (Mips::ACC64RegClass.hasSubClassEq(RC)) 2290b57cec5SDimitry Andric Opc = Mips::STORE_ACC64; 2300b57cec5SDimitry Andric else if (Mips::ACC64DSPRegClass.hasSubClassEq(RC)) 2310b57cec5SDimitry Andric Opc = Mips::STORE_ACC64DSP; 2320b57cec5SDimitry Andric else if (Mips::ACC128RegClass.hasSubClassEq(RC)) 2330b57cec5SDimitry Andric Opc = Mips::STORE_ACC128; 2340b57cec5SDimitry Andric else if (Mips::DSPCCRegClass.hasSubClassEq(RC)) 2350b57cec5SDimitry Andric Opc = Mips::STORE_CCOND_DSP; 2360b57cec5SDimitry Andric else if (Mips::FGR32RegClass.hasSubClassEq(RC)) 2370b57cec5SDimitry Andric Opc = Mips::SWC1; 2380b57cec5SDimitry Andric else if (Mips::AFGR64RegClass.hasSubClassEq(RC)) 2390b57cec5SDimitry Andric Opc = Mips::SDC1; 2400b57cec5SDimitry Andric else if (Mips::FGR64RegClass.hasSubClassEq(RC)) 2410b57cec5SDimitry Andric Opc = Mips::SDC164; 2420b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v16i8)) 2430b57cec5SDimitry Andric Opc = Mips::ST_B; 2440b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v8i16) || 2450b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v8f16)) 2460b57cec5SDimitry Andric Opc = Mips::ST_H; 2470b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v4i32) || 2480b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v4f32)) 2490b57cec5SDimitry Andric Opc = Mips::ST_W; 2500b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v2i64) || 2510b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v2f64)) 2520b57cec5SDimitry Andric Opc = Mips::ST_D; 2530b57cec5SDimitry Andric else if (Mips::LO32RegClass.hasSubClassEq(RC)) 2540b57cec5SDimitry Andric Opc = Mips::SW; 2550b57cec5SDimitry Andric else if (Mips::LO64RegClass.hasSubClassEq(RC)) 2560b57cec5SDimitry Andric Opc = Mips::SD; 2570b57cec5SDimitry Andric else if (Mips::HI32RegClass.hasSubClassEq(RC)) 2580b57cec5SDimitry Andric Opc = Mips::SW; 2590b57cec5SDimitry Andric else if (Mips::HI64RegClass.hasSubClassEq(RC)) 2600b57cec5SDimitry Andric Opc = Mips::SD; 2610b57cec5SDimitry Andric else if (Mips::DSPRRegClass.hasSubClassEq(RC)) 2620b57cec5SDimitry Andric Opc = Mips::SWDSP; 2630b57cec5SDimitry Andric 2640b57cec5SDimitry Andric // Hi, Lo are normally caller save but they are callee save 2650b57cec5SDimitry Andric // for interrupt handling. 2660b57cec5SDimitry Andric const Function &Func = MBB.getParent()->getFunction(); 2670b57cec5SDimitry Andric if (Func.hasFnAttribute("interrupt")) { 2680b57cec5SDimitry Andric if (Mips::HI32RegClass.hasSubClassEq(RC)) { 2690b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::MFHI), Mips::K0); 2700b57cec5SDimitry Andric SrcReg = Mips::K0; 2710b57cec5SDimitry Andric } else if (Mips::HI64RegClass.hasSubClassEq(RC)) { 2720b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::MFHI64), Mips::K0_64); 2730b57cec5SDimitry Andric SrcReg = Mips::K0_64; 2740b57cec5SDimitry Andric } else if (Mips::LO32RegClass.hasSubClassEq(RC)) { 2750b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::MFLO), Mips::K0); 2760b57cec5SDimitry Andric SrcReg = Mips::K0; 2770b57cec5SDimitry Andric } else if (Mips::LO64RegClass.hasSubClassEq(RC)) { 2780b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Mips::MFLO64), Mips::K0_64); 2790b57cec5SDimitry Andric SrcReg = Mips::K0_64; 2800b57cec5SDimitry Andric } 2810b57cec5SDimitry Andric } 2820b57cec5SDimitry Andric 2830b57cec5SDimitry Andric assert(Opc && "Register class not handled!"); 2840b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Opc)).addReg(SrcReg, getKillRegState(isKill)) 2850b57cec5SDimitry Andric .addFrameIndex(FI).addImm(Offset).addMemOperand(MMO); 2860b57cec5SDimitry Andric } 2870b57cec5SDimitry Andric 2880b57cec5SDimitry Andric void MipsSEInstrInfo:: 2890b57cec5SDimitry Andric loadRegFromStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 2905ffd83dbSDimitry Andric Register DestReg, int FI, const TargetRegisterClass *RC, 2910b57cec5SDimitry Andric const TargetRegisterInfo *TRI, int64_t Offset) const { 2920b57cec5SDimitry Andric DebugLoc DL; 2930b57cec5SDimitry Andric if (I != MBB.end()) DL = I->getDebugLoc(); 2940b57cec5SDimitry Andric MachineMemOperand *MMO = GetMemOperand(MBB, FI, MachineMemOperand::MOLoad); 2950b57cec5SDimitry Andric unsigned Opc = 0; 2960b57cec5SDimitry Andric 2970b57cec5SDimitry Andric const Function &Func = MBB.getParent()->getFunction(); 2980b57cec5SDimitry Andric bool ReqIndirectLoad = Func.hasFnAttribute("interrupt") && 2990b57cec5SDimitry Andric (DestReg == Mips::LO0 || DestReg == Mips::LO0_64 || 3000b57cec5SDimitry Andric DestReg == Mips::HI0 || DestReg == Mips::HI0_64); 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric if (Mips::GPR32RegClass.hasSubClassEq(RC)) 3030b57cec5SDimitry Andric Opc = Mips::LW; 3040b57cec5SDimitry Andric else if (Mips::GPR64RegClass.hasSubClassEq(RC)) 3050b57cec5SDimitry Andric Opc = Mips::LD; 3060b57cec5SDimitry Andric else if (Mips::ACC64RegClass.hasSubClassEq(RC)) 3070b57cec5SDimitry Andric Opc = Mips::LOAD_ACC64; 3080b57cec5SDimitry Andric else if (Mips::ACC64DSPRegClass.hasSubClassEq(RC)) 3090b57cec5SDimitry Andric Opc = Mips::LOAD_ACC64DSP; 3100b57cec5SDimitry Andric else if (Mips::ACC128RegClass.hasSubClassEq(RC)) 3110b57cec5SDimitry Andric Opc = Mips::LOAD_ACC128; 3120b57cec5SDimitry Andric else if (Mips::DSPCCRegClass.hasSubClassEq(RC)) 3130b57cec5SDimitry Andric Opc = Mips::LOAD_CCOND_DSP; 3140b57cec5SDimitry Andric else if (Mips::FGR32RegClass.hasSubClassEq(RC)) 3150b57cec5SDimitry Andric Opc = Mips::LWC1; 3160b57cec5SDimitry Andric else if (Mips::AFGR64RegClass.hasSubClassEq(RC)) 3170b57cec5SDimitry Andric Opc = Mips::LDC1; 3180b57cec5SDimitry Andric else if (Mips::FGR64RegClass.hasSubClassEq(RC)) 3190b57cec5SDimitry Andric Opc = Mips::LDC164; 3200b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v16i8)) 3210b57cec5SDimitry Andric Opc = Mips::LD_B; 3220b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v8i16) || 3230b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v8f16)) 3240b57cec5SDimitry Andric Opc = Mips::LD_H; 3250b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v4i32) || 3260b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v4f32)) 3270b57cec5SDimitry Andric Opc = Mips::LD_W; 3280b57cec5SDimitry Andric else if (TRI->isTypeLegalForClass(*RC, MVT::v2i64) || 3290b57cec5SDimitry Andric TRI->isTypeLegalForClass(*RC, MVT::v2f64)) 3300b57cec5SDimitry Andric Opc = Mips::LD_D; 3310b57cec5SDimitry Andric else if (Mips::HI32RegClass.hasSubClassEq(RC)) 3320b57cec5SDimitry Andric Opc = Mips::LW; 3330b57cec5SDimitry Andric else if (Mips::HI64RegClass.hasSubClassEq(RC)) 3340b57cec5SDimitry Andric Opc = Mips::LD; 3350b57cec5SDimitry Andric else if (Mips::LO32RegClass.hasSubClassEq(RC)) 3360b57cec5SDimitry Andric Opc = Mips::LW; 3370b57cec5SDimitry Andric else if (Mips::LO64RegClass.hasSubClassEq(RC)) 3380b57cec5SDimitry Andric Opc = Mips::LD; 3390b57cec5SDimitry Andric else if (Mips::DSPRRegClass.hasSubClassEq(RC)) 3400b57cec5SDimitry Andric Opc = Mips::LWDSP; 3410b57cec5SDimitry Andric 3420b57cec5SDimitry Andric assert(Opc && "Register class not handled!"); 3430b57cec5SDimitry Andric 3440b57cec5SDimitry Andric if (!ReqIndirectLoad) 3450b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Opc), DestReg) 3460b57cec5SDimitry Andric .addFrameIndex(FI) 3470b57cec5SDimitry Andric .addImm(Offset) 3480b57cec5SDimitry Andric .addMemOperand(MMO); 3490b57cec5SDimitry Andric else { 3500b57cec5SDimitry Andric // Load HI/LO through K0. Notably the DestReg is encoded into the 3510b57cec5SDimitry Andric // instruction itself. 3520b57cec5SDimitry Andric unsigned Reg = Mips::K0; 3530b57cec5SDimitry Andric unsigned LdOp = Mips::MTLO; 3540b57cec5SDimitry Andric if (DestReg == Mips::HI0) 3550b57cec5SDimitry Andric LdOp = Mips::MTHI; 3560b57cec5SDimitry Andric 3570b57cec5SDimitry Andric if (Subtarget.getABI().ArePtrs64bit()) { 3580b57cec5SDimitry Andric Reg = Mips::K0_64; 3590b57cec5SDimitry Andric if (DestReg == Mips::HI0_64) 3600b57cec5SDimitry Andric LdOp = Mips::MTHI64; 3610b57cec5SDimitry Andric else 3620b57cec5SDimitry Andric LdOp = Mips::MTLO64; 3630b57cec5SDimitry Andric } 3640b57cec5SDimitry Andric 3650b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Opc), Reg) 3660b57cec5SDimitry Andric .addFrameIndex(FI) 3670b57cec5SDimitry Andric .addImm(Offset) 3680b57cec5SDimitry Andric .addMemOperand(MMO); 3690b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(LdOp)).addReg(Reg); 3700b57cec5SDimitry Andric } 3710b57cec5SDimitry Andric } 3720b57cec5SDimitry Andric 3730b57cec5SDimitry Andric bool MipsSEInstrInfo::expandPostRAPseudo(MachineInstr &MI) const { 3740b57cec5SDimitry Andric MachineBasicBlock &MBB = *MI.getParent(); 3750b57cec5SDimitry Andric bool isMicroMips = Subtarget.inMicroMipsMode(); 3760b57cec5SDimitry Andric unsigned Opc; 3770b57cec5SDimitry Andric 3780b57cec5SDimitry Andric switch (MI.getDesc().getOpcode()) { 3790b57cec5SDimitry Andric default: 3800b57cec5SDimitry Andric return false; 3810b57cec5SDimitry Andric case Mips::RetRA: 3820b57cec5SDimitry Andric expandRetRA(MBB, MI); 3830b57cec5SDimitry Andric break; 3840b57cec5SDimitry Andric case Mips::ERet: 3850b57cec5SDimitry Andric expandERet(MBB, MI); 3860b57cec5SDimitry Andric break; 3870b57cec5SDimitry Andric case Mips::PseudoMFHI: 3880b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFHI); 3890b57cec5SDimitry Andric break; 3900b57cec5SDimitry Andric case Mips::PseudoMFHI_MM: 3910b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFHI16_MM); 3920b57cec5SDimitry Andric break; 3930b57cec5SDimitry Andric case Mips::PseudoMFLO: 3940b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFLO); 3950b57cec5SDimitry Andric break; 3960b57cec5SDimitry Andric case Mips::PseudoMFLO_MM: 3970b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFLO16_MM); 3980b57cec5SDimitry Andric break; 3990b57cec5SDimitry Andric case Mips::PseudoMFHI64: 4000b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFHI64); 4010b57cec5SDimitry Andric break; 4020b57cec5SDimitry Andric case Mips::PseudoMFLO64: 4030b57cec5SDimitry Andric expandPseudoMFHiLo(MBB, MI, Mips::MFLO64); 4040b57cec5SDimitry Andric break; 4050b57cec5SDimitry Andric case Mips::PseudoMTLOHI: 4060b57cec5SDimitry Andric expandPseudoMTLoHi(MBB, MI, Mips::MTLO, Mips::MTHI, false); 4070b57cec5SDimitry Andric break; 4080b57cec5SDimitry Andric case Mips::PseudoMTLOHI64: 4090b57cec5SDimitry Andric expandPseudoMTLoHi(MBB, MI, Mips::MTLO64, Mips::MTHI64, false); 4100b57cec5SDimitry Andric break; 4110b57cec5SDimitry Andric case Mips::PseudoMTLOHI_DSP: 4120b57cec5SDimitry Andric expandPseudoMTLoHi(MBB, MI, Mips::MTLO_DSP, Mips::MTHI_DSP, true); 4130b57cec5SDimitry Andric break; 4140b57cec5SDimitry Andric case Mips::PseudoMTLOHI_MM: 4150b57cec5SDimitry Andric expandPseudoMTLoHi(MBB, MI, Mips::MTLO_MM, Mips::MTHI_MM, false); 4160b57cec5SDimitry Andric break; 4170b57cec5SDimitry Andric case Mips::PseudoCVT_S_W: 4180b57cec5SDimitry Andric expandCvtFPInt(MBB, MI, Mips::CVT_S_W, Mips::MTC1, false); 4190b57cec5SDimitry Andric break; 4200b57cec5SDimitry Andric case Mips::PseudoCVT_D32_W: 4210b57cec5SDimitry Andric Opc = isMicroMips ? Mips::CVT_D32_W_MM : Mips::CVT_D32_W; 4220b57cec5SDimitry Andric expandCvtFPInt(MBB, MI, Opc, Mips::MTC1, false); 4230b57cec5SDimitry Andric break; 4240b57cec5SDimitry Andric case Mips::PseudoCVT_S_L: 4250b57cec5SDimitry Andric expandCvtFPInt(MBB, MI, Mips::CVT_S_L, Mips::DMTC1, true); 4260b57cec5SDimitry Andric break; 4270b57cec5SDimitry Andric case Mips::PseudoCVT_D64_W: 4280b57cec5SDimitry Andric Opc = isMicroMips ? Mips::CVT_D64_W_MM : Mips::CVT_D64_W; 4290b57cec5SDimitry Andric expandCvtFPInt(MBB, MI, Opc, Mips::MTC1, true); 4300b57cec5SDimitry Andric break; 4310b57cec5SDimitry Andric case Mips::PseudoCVT_D64_L: 4320b57cec5SDimitry Andric expandCvtFPInt(MBB, MI, Mips::CVT_D64_L, Mips::DMTC1, true); 4330b57cec5SDimitry Andric break; 4340b57cec5SDimitry Andric case Mips::BuildPairF64: 4350b57cec5SDimitry Andric expandBuildPairF64(MBB, MI, isMicroMips, false); 4360b57cec5SDimitry Andric break; 4370b57cec5SDimitry Andric case Mips::BuildPairF64_64: 4380b57cec5SDimitry Andric expandBuildPairF64(MBB, MI, isMicroMips, true); 4390b57cec5SDimitry Andric break; 4400b57cec5SDimitry Andric case Mips::ExtractElementF64: 4410b57cec5SDimitry Andric expandExtractElementF64(MBB, MI, isMicroMips, false); 4420b57cec5SDimitry Andric break; 4430b57cec5SDimitry Andric case Mips::ExtractElementF64_64: 4440b57cec5SDimitry Andric expandExtractElementF64(MBB, MI, isMicroMips, true); 4450b57cec5SDimitry Andric break; 4460b57cec5SDimitry Andric case Mips::MIPSeh_return32: 4470b57cec5SDimitry Andric case Mips::MIPSeh_return64: 4480b57cec5SDimitry Andric expandEhReturn(MBB, MI); 4490b57cec5SDimitry Andric break; 4500b57cec5SDimitry Andric } 4510b57cec5SDimitry Andric 4520b57cec5SDimitry Andric MBB.erase(MI); 4530b57cec5SDimitry Andric return true; 4540b57cec5SDimitry Andric } 4550b57cec5SDimitry Andric 4565ffd83dbSDimitry Andric /// isBranchWithImm - Return true if the branch contains an immediate 4575ffd83dbSDimitry Andric /// operand (\see lib/Target/Mips/MipsBranchExpansion.cpp). 4585ffd83dbSDimitry Andric bool MipsSEInstrInfo::isBranchWithImm(unsigned Opc) const { 4595ffd83dbSDimitry Andric switch (Opc) { 4605ffd83dbSDimitry Andric default: 4615ffd83dbSDimitry Andric return false; 4625ffd83dbSDimitry Andric case Mips::BBIT0: 4635ffd83dbSDimitry Andric case Mips::BBIT1: 4645ffd83dbSDimitry Andric case Mips::BBIT032: 4655ffd83dbSDimitry Andric case Mips::BBIT132: 4665ffd83dbSDimitry Andric return true; 4675ffd83dbSDimitry Andric } 4685ffd83dbSDimitry Andric } 4695ffd83dbSDimitry Andric 4700b57cec5SDimitry Andric /// getOppositeBranchOpc - Return the inverse of the specified 4710b57cec5SDimitry Andric /// opcode, e.g. turning BEQ to BNE. 4720b57cec5SDimitry Andric unsigned MipsSEInstrInfo::getOppositeBranchOpc(unsigned Opc) const { 4730b57cec5SDimitry Andric switch (Opc) { 4740b57cec5SDimitry Andric default: llvm_unreachable("Illegal opcode!"); 4750b57cec5SDimitry Andric case Mips::BEQ: return Mips::BNE; 4760b57cec5SDimitry Andric case Mips::BEQ_MM: return Mips::BNE_MM; 4770b57cec5SDimitry Andric case Mips::BNE: return Mips::BEQ; 4780b57cec5SDimitry Andric case Mips::BNE_MM: return Mips::BEQ_MM; 4790b57cec5SDimitry Andric case Mips::BGTZ: return Mips::BLEZ; 4800b57cec5SDimitry Andric case Mips::BGEZ: return Mips::BLTZ; 4810b57cec5SDimitry Andric case Mips::BLTZ: return Mips::BGEZ; 4820b57cec5SDimitry Andric case Mips::BLEZ: return Mips::BGTZ; 4830b57cec5SDimitry Andric case Mips::BGTZ_MM: return Mips::BLEZ_MM; 4840b57cec5SDimitry Andric case Mips::BGEZ_MM: return Mips::BLTZ_MM; 4850b57cec5SDimitry Andric case Mips::BLTZ_MM: return Mips::BGEZ_MM; 4860b57cec5SDimitry Andric case Mips::BLEZ_MM: return Mips::BGTZ_MM; 4870b57cec5SDimitry Andric case Mips::BEQ64: return Mips::BNE64; 4880b57cec5SDimitry Andric case Mips::BNE64: return Mips::BEQ64; 4890b57cec5SDimitry Andric case Mips::BGTZ64: return Mips::BLEZ64; 4900b57cec5SDimitry Andric case Mips::BGEZ64: return Mips::BLTZ64; 4910b57cec5SDimitry Andric case Mips::BLTZ64: return Mips::BGEZ64; 4920b57cec5SDimitry Andric case Mips::BLEZ64: return Mips::BGTZ64; 4930b57cec5SDimitry Andric case Mips::BC1T: return Mips::BC1F; 4940b57cec5SDimitry Andric case Mips::BC1F: return Mips::BC1T; 4950b57cec5SDimitry Andric case Mips::BC1T_MM: return Mips::BC1F_MM; 4960b57cec5SDimitry Andric case Mips::BC1F_MM: return Mips::BC1T_MM; 4970b57cec5SDimitry Andric case Mips::BEQZ16_MM: return Mips::BNEZ16_MM; 4980b57cec5SDimitry Andric case Mips::BNEZ16_MM: return Mips::BEQZ16_MM; 4990b57cec5SDimitry Andric case Mips::BEQZC_MM: return Mips::BNEZC_MM; 5000b57cec5SDimitry Andric case Mips::BNEZC_MM: return Mips::BEQZC_MM; 5010b57cec5SDimitry Andric case Mips::BEQZC: return Mips::BNEZC; 5020b57cec5SDimitry Andric case Mips::BNEZC: return Mips::BEQZC; 5030b57cec5SDimitry Andric case Mips::BLEZC: return Mips::BGTZC; 5040b57cec5SDimitry Andric case Mips::BGEZC: return Mips::BLTZC; 5050b57cec5SDimitry Andric case Mips::BGEC: return Mips::BLTC; 5060b57cec5SDimitry Andric case Mips::BGTZC: return Mips::BLEZC; 5070b57cec5SDimitry Andric case Mips::BLTZC: return Mips::BGEZC; 5080b57cec5SDimitry Andric case Mips::BLTC: return Mips::BGEC; 5090b57cec5SDimitry Andric case Mips::BGEUC: return Mips::BLTUC; 5100b57cec5SDimitry Andric case Mips::BLTUC: return Mips::BGEUC; 5110b57cec5SDimitry Andric case Mips::BEQC: return Mips::BNEC; 5120b57cec5SDimitry Andric case Mips::BNEC: return Mips::BEQC; 5130b57cec5SDimitry Andric case Mips::BC1EQZ: return Mips::BC1NEZ; 5140b57cec5SDimitry Andric case Mips::BC1NEZ: return Mips::BC1EQZ; 5150b57cec5SDimitry Andric case Mips::BEQZC_MMR6: return Mips::BNEZC_MMR6; 5160b57cec5SDimitry Andric case Mips::BNEZC_MMR6: return Mips::BEQZC_MMR6; 5170b57cec5SDimitry Andric case Mips::BLEZC_MMR6: return Mips::BGTZC_MMR6; 5180b57cec5SDimitry Andric case Mips::BGEZC_MMR6: return Mips::BLTZC_MMR6; 5190b57cec5SDimitry Andric case Mips::BGEC_MMR6: return Mips::BLTC_MMR6; 5200b57cec5SDimitry Andric case Mips::BGTZC_MMR6: return Mips::BLEZC_MMR6; 5210b57cec5SDimitry Andric case Mips::BLTZC_MMR6: return Mips::BGEZC_MMR6; 5220b57cec5SDimitry Andric case Mips::BLTC_MMR6: return Mips::BGEC_MMR6; 5230b57cec5SDimitry Andric case Mips::BGEUC_MMR6: return Mips::BLTUC_MMR6; 5240b57cec5SDimitry Andric case Mips::BLTUC_MMR6: return Mips::BGEUC_MMR6; 5250b57cec5SDimitry Andric case Mips::BEQC_MMR6: return Mips::BNEC_MMR6; 5260b57cec5SDimitry Andric case Mips::BNEC_MMR6: return Mips::BEQC_MMR6; 5270b57cec5SDimitry Andric case Mips::BC1EQZC_MMR6: return Mips::BC1NEZC_MMR6; 5280b57cec5SDimitry Andric case Mips::BC1NEZC_MMR6: return Mips::BC1EQZC_MMR6; 5290b57cec5SDimitry Andric case Mips::BEQZC64: return Mips::BNEZC64; 5300b57cec5SDimitry Andric case Mips::BNEZC64: return Mips::BEQZC64; 5310b57cec5SDimitry Andric case Mips::BEQC64: return Mips::BNEC64; 5320b57cec5SDimitry Andric case Mips::BNEC64: return Mips::BEQC64; 5330b57cec5SDimitry Andric case Mips::BGEC64: return Mips::BLTC64; 5340b57cec5SDimitry Andric case Mips::BGEUC64: return Mips::BLTUC64; 5350b57cec5SDimitry Andric case Mips::BLTC64: return Mips::BGEC64; 5360b57cec5SDimitry Andric case Mips::BLTUC64: return Mips::BGEUC64; 5370b57cec5SDimitry Andric case Mips::BGTZC64: return Mips::BLEZC64; 5380b57cec5SDimitry Andric case Mips::BGEZC64: return Mips::BLTZC64; 5390b57cec5SDimitry Andric case Mips::BLTZC64: return Mips::BGEZC64; 5400b57cec5SDimitry Andric case Mips::BLEZC64: return Mips::BGTZC64; 5410b57cec5SDimitry Andric case Mips::BBIT0: return Mips::BBIT1; 5420b57cec5SDimitry Andric case Mips::BBIT1: return Mips::BBIT0; 5430b57cec5SDimitry Andric case Mips::BBIT032: return Mips::BBIT132; 5440b57cec5SDimitry Andric case Mips::BBIT132: return Mips::BBIT032; 5450b57cec5SDimitry Andric case Mips::BZ_B: return Mips::BNZ_B; 5460b57cec5SDimitry Andric case Mips::BZ_H: return Mips::BNZ_H; 5470b57cec5SDimitry Andric case Mips::BZ_W: return Mips::BNZ_W; 5480b57cec5SDimitry Andric case Mips::BZ_D: return Mips::BNZ_D; 5490b57cec5SDimitry Andric case Mips::BZ_V: return Mips::BNZ_V; 5500b57cec5SDimitry Andric case Mips::BNZ_B: return Mips::BZ_B; 5510b57cec5SDimitry Andric case Mips::BNZ_H: return Mips::BZ_H; 5520b57cec5SDimitry Andric case Mips::BNZ_W: return Mips::BZ_W; 5530b57cec5SDimitry Andric case Mips::BNZ_D: return Mips::BZ_D; 5540b57cec5SDimitry Andric case Mips::BNZ_V: return Mips::BZ_V; 5550b57cec5SDimitry Andric } 5560b57cec5SDimitry Andric } 5570b57cec5SDimitry Andric 5580b57cec5SDimitry Andric /// Adjust SP by Amount bytes. 5590b57cec5SDimitry Andric void MipsSEInstrInfo::adjustStackPtr(unsigned SP, int64_t Amount, 5600b57cec5SDimitry Andric MachineBasicBlock &MBB, 5610b57cec5SDimitry Andric MachineBasicBlock::iterator I) const { 5620b57cec5SDimitry Andric MipsABIInfo ABI = Subtarget.getABI(); 5630b57cec5SDimitry Andric DebugLoc DL; 5640b57cec5SDimitry Andric unsigned ADDiu = ABI.GetPtrAddiuOp(); 5650b57cec5SDimitry Andric 5660b57cec5SDimitry Andric if (Amount == 0) 5670b57cec5SDimitry Andric return; 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric if (isInt<16>(Amount)) { 5700b57cec5SDimitry Andric // addi sp, sp, amount 5710b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(ADDiu), SP).addReg(SP).addImm(Amount); 5720b57cec5SDimitry Andric } else { 5730b57cec5SDimitry Andric // For numbers which are not 16bit integers we synthesize Amount inline 5740b57cec5SDimitry Andric // then add or subtract it from sp. 5750b57cec5SDimitry Andric unsigned Opc = ABI.GetPtrAdduOp(); 5760b57cec5SDimitry Andric if (Amount < 0) { 5770b57cec5SDimitry Andric Opc = ABI.GetPtrSubuOp(); 5780b57cec5SDimitry Andric Amount = -Amount; 5790b57cec5SDimitry Andric } 5800b57cec5SDimitry Andric unsigned Reg = loadImmediate(Amount, MBB, I, DL, nullptr); 5810b57cec5SDimitry Andric BuildMI(MBB, I, DL, get(Opc), SP).addReg(SP).addReg(Reg, RegState::Kill); 5820b57cec5SDimitry Andric } 5830b57cec5SDimitry Andric } 5840b57cec5SDimitry Andric 5850b57cec5SDimitry Andric /// This function generates the sequence of instructions needed to get the 5860b57cec5SDimitry Andric /// result of adding register REG and immediate IMM. 5870b57cec5SDimitry Andric unsigned MipsSEInstrInfo::loadImmediate(int64_t Imm, MachineBasicBlock &MBB, 5880b57cec5SDimitry Andric MachineBasicBlock::iterator II, 5890b57cec5SDimitry Andric const DebugLoc &DL, 5900b57cec5SDimitry Andric unsigned *NewImm) const { 5910b57cec5SDimitry Andric MipsAnalyzeImmediate AnalyzeImm; 5920b57cec5SDimitry Andric const MipsSubtarget &STI = Subtarget; 5930b57cec5SDimitry Andric MachineRegisterInfo &RegInfo = MBB.getParent()->getRegInfo(); 5940b57cec5SDimitry Andric unsigned Size = STI.isABI_N64() ? 64 : 32; 5950b57cec5SDimitry Andric unsigned LUi = STI.isABI_N64() ? Mips::LUi64 : Mips::LUi; 5960b57cec5SDimitry Andric unsigned ZEROReg = STI.isABI_N64() ? Mips::ZERO_64 : Mips::ZERO; 5970b57cec5SDimitry Andric const TargetRegisterClass *RC = STI.isABI_N64() ? 5980b57cec5SDimitry Andric &Mips::GPR64RegClass : &Mips::GPR32RegClass; 5990b57cec5SDimitry Andric bool LastInstrIsADDiu = NewImm; 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andric const MipsAnalyzeImmediate::InstSeq &Seq = 6020b57cec5SDimitry Andric AnalyzeImm.Analyze(Imm, Size, LastInstrIsADDiu); 6030b57cec5SDimitry Andric MipsAnalyzeImmediate::InstSeq::const_iterator Inst = Seq.begin(); 6040b57cec5SDimitry Andric 6050b57cec5SDimitry Andric assert(Seq.size() && (!LastInstrIsADDiu || (Seq.size() > 1))); 6060b57cec5SDimitry Andric 6070b57cec5SDimitry Andric // The first instruction can be a LUi, which is different from other 6080b57cec5SDimitry Andric // instructions (ADDiu, ORI and SLL) in that it does not have a register 6090b57cec5SDimitry Andric // operand. 6108bcb0991SDimitry Andric Register Reg = RegInfo.createVirtualRegister(RC); 6110b57cec5SDimitry Andric 6120b57cec5SDimitry Andric if (Inst->Opc == LUi) 6130b57cec5SDimitry Andric BuildMI(MBB, II, DL, get(LUi), Reg).addImm(SignExtend64<16>(Inst->ImmOpnd)); 6140b57cec5SDimitry Andric else 6150b57cec5SDimitry Andric BuildMI(MBB, II, DL, get(Inst->Opc), Reg).addReg(ZEROReg) 6160b57cec5SDimitry Andric .addImm(SignExtend64<16>(Inst->ImmOpnd)); 6170b57cec5SDimitry Andric 6180b57cec5SDimitry Andric // Build the remaining instructions in Seq. 6190b57cec5SDimitry Andric for (++Inst; Inst != Seq.end() - LastInstrIsADDiu; ++Inst) 6200b57cec5SDimitry Andric BuildMI(MBB, II, DL, get(Inst->Opc), Reg).addReg(Reg, RegState::Kill) 6210b57cec5SDimitry Andric .addImm(SignExtend64<16>(Inst->ImmOpnd)); 6220b57cec5SDimitry Andric 6230b57cec5SDimitry Andric if (LastInstrIsADDiu) 6240b57cec5SDimitry Andric *NewImm = Inst->ImmOpnd; 6250b57cec5SDimitry Andric 6260b57cec5SDimitry Andric return Reg; 6270b57cec5SDimitry Andric } 6280b57cec5SDimitry Andric 6290b57cec5SDimitry Andric unsigned MipsSEInstrInfo::getAnalyzableBrOpc(unsigned Opc) const { 6300b57cec5SDimitry Andric return (Opc == Mips::BEQ || Opc == Mips::BEQ_MM || Opc == Mips::BNE || 6310b57cec5SDimitry Andric Opc == Mips::BNE_MM || Opc == Mips::BGTZ || Opc == Mips::BGEZ || 6320b57cec5SDimitry Andric Opc == Mips::BLTZ || Opc == Mips::BLEZ || Opc == Mips::BEQ64 || 6330b57cec5SDimitry Andric Opc == Mips::BNE64 || Opc == Mips::BGTZ64 || Opc == Mips::BGEZ64 || 6340b57cec5SDimitry Andric Opc == Mips::BLTZ64 || Opc == Mips::BLEZ64 || Opc == Mips::BC1T || 6350b57cec5SDimitry Andric Opc == Mips::BC1F || Opc == Mips::B || Opc == Mips::J || 6360b57cec5SDimitry Andric Opc == Mips::J_MM || Opc == Mips::B_MM || Opc == Mips::BEQZC_MM || 6370b57cec5SDimitry Andric Opc == Mips::BNEZC_MM || Opc == Mips::BEQC || Opc == Mips::BNEC || 6380b57cec5SDimitry Andric Opc == Mips::BLTC || Opc == Mips::BGEC || Opc == Mips::BLTUC || 6390b57cec5SDimitry Andric Opc == Mips::BGEUC || Opc == Mips::BGTZC || Opc == Mips::BLEZC || 6400b57cec5SDimitry Andric Opc == Mips::BGEZC || Opc == Mips::BLTZC || Opc == Mips::BEQZC || 6410b57cec5SDimitry Andric Opc == Mips::BNEZC || Opc == Mips::BEQZC64 || Opc == Mips::BNEZC64 || 6420b57cec5SDimitry Andric Opc == Mips::BEQC64 || Opc == Mips::BNEC64 || Opc == Mips::BGEC64 || 6430b57cec5SDimitry Andric Opc == Mips::BGEUC64 || Opc == Mips::BLTC64 || Opc == Mips::BLTUC64 || 6440b57cec5SDimitry Andric Opc == Mips::BGTZC64 || Opc == Mips::BGEZC64 || 6450b57cec5SDimitry Andric Opc == Mips::BLTZC64 || Opc == Mips::BLEZC64 || Opc == Mips::BC || 6460b57cec5SDimitry Andric Opc == Mips::BBIT0 || Opc == Mips::BBIT1 || Opc == Mips::BBIT032 || 6470b57cec5SDimitry Andric Opc == Mips::BBIT132 || Opc == Mips::BC_MMR6 || 6480b57cec5SDimitry Andric Opc == Mips::BEQC_MMR6 || Opc == Mips::BNEC_MMR6 || 6490b57cec5SDimitry Andric Opc == Mips::BLTC_MMR6 || Opc == Mips::BGEC_MMR6 || 6500b57cec5SDimitry Andric Opc == Mips::BLTUC_MMR6 || Opc == Mips::BGEUC_MMR6 || 6510b57cec5SDimitry Andric Opc == Mips::BGTZC_MMR6 || Opc == Mips::BLEZC_MMR6 || 6520b57cec5SDimitry Andric Opc == Mips::BGEZC_MMR6 || Opc == Mips::BLTZC_MMR6 || 6530b57cec5SDimitry Andric Opc == Mips::BEQZC_MMR6 || Opc == Mips::BNEZC_MMR6) ? Opc : 0; 6540b57cec5SDimitry Andric } 6550b57cec5SDimitry Andric 6560b57cec5SDimitry Andric void MipsSEInstrInfo::expandRetRA(MachineBasicBlock &MBB, 6570b57cec5SDimitry Andric MachineBasicBlock::iterator I) const { 6580b57cec5SDimitry Andric 6590b57cec5SDimitry Andric MachineInstrBuilder MIB; 6600b57cec5SDimitry Andric if (Subtarget.isGP64bit()) 6610b57cec5SDimitry Andric MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn64)) 6620b57cec5SDimitry Andric .addReg(Mips::RA_64, RegState::Undef); 6630b57cec5SDimitry Andric else 6640b57cec5SDimitry Andric MIB = BuildMI(MBB, I, I->getDebugLoc(), get(Mips::PseudoReturn)) 6650b57cec5SDimitry Andric .addReg(Mips::RA, RegState::Undef); 6660b57cec5SDimitry Andric 6670b57cec5SDimitry Andric // Retain any imp-use flags. 6680b57cec5SDimitry Andric for (auto & MO : I->operands()) { 6690b57cec5SDimitry Andric if (MO.isImplicit()) 6700b57cec5SDimitry Andric MIB.add(MO); 6710b57cec5SDimitry Andric } 6720b57cec5SDimitry Andric } 6730b57cec5SDimitry Andric 6740b57cec5SDimitry Andric void MipsSEInstrInfo::expandERet(MachineBasicBlock &MBB, 6750b57cec5SDimitry Andric MachineBasicBlock::iterator I) const { 6760b57cec5SDimitry Andric BuildMI(MBB, I, I->getDebugLoc(), get(Mips::ERET)); 6770b57cec5SDimitry Andric } 6780b57cec5SDimitry Andric 6790b57cec5SDimitry Andric std::pair<bool, bool> 6800b57cec5SDimitry Andric MipsSEInstrInfo::compareOpndSize(unsigned Opc, 6810b57cec5SDimitry Andric const MachineFunction &MF) const { 6820b57cec5SDimitry Andric const MCInstrDesc &Desc = get(Opc); 6830b57cec5SDimitry Andric assert(Desc.NumOperands == 2 && "Unary instruction expected."); 6840b57cec5SDimitry Andric const MipsRegisterInfo *RI = &getRegisterInfo(); 6850b57cec5SDimitry Andric unsigned DstRegSize = RI->getRegSizeInBits(*getRegClass(Desc, 0, RI, MF)); 6860b57cec5SDimitry Andric unsigned SrcRegSize = RI->getRegSizeInBits(*getRegClass(Desc, 1, RI, MF)); 6870b57cec5SDimitry Andric 6880b57cec5SDimitry Andric return std::make_pair(DstRegSize > SrcRegSize, DstRegSize < SrcRegSize); 6890b57cec5SDimitry Andric } 6900b57cec5SDimitry Andric 6910b57cec5SDimitry Andric void MipsSEInstrInfo::expandPseudoMFHiLo(MachineBasicBlock &MBB, 6920b57cec5SDimitry Andric MachineBasicBlock::iterator I, 6930b57cec5SDimitry Andric unsigned NewOpc) const { 6940b57cec5SDimitry Andric BuildMI(MBB, I, I->getDebugLoc(), get(NewOpc), I->getOperand(0).getReg()); 6950b57cec5SDimitry Andric } 6960b57cec5SDimitry Andric 6970b57cec5SDimitry Andric void MipsSEInstrInfo::expandPseudoMTLoHi(MachineBasicBlock &MBB, 6980b57cec5SDimitry Andric MachineBasicBlock::iterator I, 6990b57cec5SDimitry Andric unsigned LoOpc, 7000b57cec5SDimitry Andric unsigned HiOpc, 7010b57cec5SDimitry Andric bool HasExplicitDef) const { 7020b57cec5SDimitry Andric // Expand 7030b57cec5SDimitry Andric // lo_hi pseudomtlohi $gpr0, $gpr1 7040b57cec5SDimitry Andric // to these two instructions: 7050b57cec5SDimitry Andric // mtlo $gpr0 7060b57cec5SDimitry Andric // mthi $gpr1 7070b57cec5SDimitry Andric 7080b57cec5SDimitry Andric DebugLoc DL = I->getDebugLoc(); 7090b57cec5SDimitry Andric const MachineOperand &SrcLo = I->getOperand(1), &SrcHi = I->getOperand(2); 7100b57cec5SDimitry Andric MachineInstrBuilder LoInst = BuildMI(MBB, I, DL, get(LoOpc)); 7110b57cec5SDimitry Andric MachineInstrBuilder HiInst = BuildMI(MBB, I, DL, get(HiOpc)); 7120b57cec5SDimitry Andric 7130b57cec5SDimitry Andric // Add lo/hi registers if the mtlo/hi instructions created have explicit 7140b57cec5SDimitry Andric // def registers. 7150b57cec5SDimitry Andric if (HasExplicitDef) { 7168bcb0991SDimitry Andric Register DstReg = I->getOperand(0).getReg(); 7178bcb0991SDimitry Andric Register DstLo = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo); 7188bcb0991SDimitry Andric Register DstHi = getRegisterInfo().getSubReg(DstReg, Mips::sub_hi); 7190b57cec5SDimitry Andric LoInst.addReg(DstLo, RegState::Define); 7200b57cec5SDimitry Andric HiInst.addReg(DstHi, RegState::Define); 7210b57cec5SDimitry Andric } 7220b57cec5SDimitry Andric 7230b57cec5SDimitry Andric LoInst.addReg(SrcLo.getReg(), getKillRegState(SrcLo.isKill())); 7240b57cec5SDimitry Andric HiInst.addReg(SrcHi.getReg(), getKillRegState(SrcHi.isKill())); 7250b57cec5SDimitry Andric } 7260b57cec5SDimitry Andric 7270b57cec5SDimitry Andric void MipsSEInstrInfo::expandCvtFPInt(MachineBasicBlock &MBB, 7280b57cec5SDimitry Andric MachineBasicBlock::iterator I, 7290b57cec5SDimitry Andric unsigned CvtOpc, unsigned MovOpc, 7300b57cec5SDimitry Andric bool IsI64) const { 7310b57cec5SDimitry Andric const MCInstrDesc &CvtDesc = get(CvtOpc), &MovDesc = get(MovOpc); 7320b57cec5SDimitry Andric const MachineOperand &Dst = I->getOperand(0), &Src = I->getOperand(1); 7330b57cec5SDimitry Andric unsigned DstReg = Dst.getReg(), SrcReg = Src.getReg(), TmpReg = DstReg; 7340b57cec5SDimitry Andric unsigned KillSrc = getKillRegState(Src.isKill()); 7350b57cec5SDimitry Andric DebugLoc DL = I->getDebugLoc(); 7360b57cec5SDimitry Andric bool DstIsLarger, SrcIsLarger; 7370b57cec5SDimitry Andric 7380b57cec5SDimitry Andric std::tie(DstIsLarger, SrcIsLarger) = 7390b57cec5SDimitry Andric compareOpndSize(CvtOpc, *MBB.getParent()); 7400b57cec5SDimitry Andric 7410b57cec5SDimitry Andric if (DstIsLarger) 7420b57cec5SDimitry Andric TmpReg = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo); 7430b57cec5SDimitry Andric 7440b57cec5SDimitry Andric if (SrcIsLarger) 7450b57cec5SDimitry Andric DstReg = getRegisterInfo().getSubReg(DstReg, Mips::sub_lo); 7460b57cec5SDimitry Andric 7470b57cec5SDimitry Andric BuildMI(MBB, I, DL, MovDesc, TmpReg).addReg(SrcReg, KillSrc); 7480b57cec5SDimitry Andric BuildMI(MBB, I, DL, CvtDesc, DstReg).addReg(TmpReg, RegState::Kill); 7490b57cec5SDimitry Andric } 7500b57cec5SDimitry Andric 7510b57cec5SDimitry Andric void MipsSEInstrInfo::expandExtractElementF64(MachineBasicBlock &MBB, 7520b57cec5SDimitry Andric MachineBasicBlock::iterator I, 7530b57cec5SDimitry Andric bool isMicroMips, 7540b57cec5SDimitry Andric bool FP64) const { 7558bcb0991SDimitry Andric Register DstReg = I->getOperand(0).getReg(); 7568bcb0991SDimitry Andric Register SrcReg = I->getOperand(1).getReg(); 7570b57cec5SDimitry Andric unsigned N = I->getOperand(2).getImm(); 7580b57cec5SDimitry Andric DebugLoc dl = I->getDebugLoc(); 7590b57cec5SDimitry Andric 7600b57cec5SDimitry Andric assert(N < 2 && "Invalid immediate"); 7610b57cec5SDimitry Andric unsigned SubIdx = N ? Mips::sub_hi : Mips::sub_lo; 7628bcb0991SDimitry Andric Register SubReg = getRegisterInfo().getSubReg(SrcReg, SubIdx); 7630b57cec5SDimitry Andric 7640b57cec5SDimitry Andric // FPXX on MIPS-II or MIPS32r1 should have been handled with a spill/reload 7650b57cec5SDimitry Andric // in MipsSEFrameLowering.cpp. 7660b57cec5SDimitry Andric assert(!(Subtarget.isABI_FPXX() && !Subtarget.hasMips32r2())); 7670b57cec5SDimitry Andric 7680b57cec5SDimitry Andric // FP64A (FP64 with nooddspreg) should have been handled with a spill/reload 7690b57cec5SDimitry Andric // in MipsSEFrameLowering.cpp. 7700b57cec5SDimitry Andric assert(!(Subtarget.isFP64bit() && !Subtarget.useOddSPReg())); 7710b57cec5SDimitry Andric 7720b57cec5SDimitry Andric if (SubIdx == Mips::sub_hi && Subtarget.hasMTHC1()) { 7730b57cec5SDimitry Andric // FIXME: Strictly speaking MFHC1 only reads the top 32-bits however, we 7740b57cec5SDimitry Andric // claim to read the whole 64-bits as part of a white lie used to 7750b57cec5SDimitry Andric // temporarily work around a widespread bug in the -mfp64 support. 7760b57cec5SDimitry Andric // The problem is that none of the 32-bit fpu ops mention the fact 7770b57cec5SDimitry Andric // that they clobber the upper 32-bits of the 64-bit FPR. Fixing that 7780b57cec5SDimitry Andric // requires a major overhaul of the FPU implementation which can't 7790b57cec5SDimitry Andric // be done right now due to time constraints. 7800b57cec5SDimitry Andric // MFHC1 is one of two instructions that are affected since they are 7810b57cec5SDimitry Andric // the only instructions that don't read the lower 32-bits. 7820b57cec5SDimitry Andric // We therefore pretend that it reads the bottom 32-bits to 7830b57cec5SDimitry Andric // artificially create a dependency and prevent the scheduler 7840b57cec5SDimitry Andric // changing the behaviour of the code. 7850b57cec5SDimitry Andric BuildMI(MBB, I, dl, 7860b57cec5SDimitry Andric get(isMicroMips ? (FP64 ? Mips::MFHC1_D64_MM : Mips::MFHC1_D32_MM) 7870b57cec5SDimitry Andric : (FP64 ? Mips::MFHC1_D64 : Mips::MFHC1_D32)), 7880b57cec5SDimitry Andric DstReg) 7890b57cec5SDimitry Andric .addReg(SrcReg); 7900b57cec5SDimitry Andric } else 7910b57cec5SDimitry Andric BuildMI(MBB, I, dl, get(Mips::MFC1), DstReg).addReg(SubReg); 7920b57cec5SDimitry Andric } 7930b57cec5SDimitry Andric 7940b57cec5SDimitry Andric void MipsSEInstrInfo::expandBuildPairF64(MachineBasicBlock &MBB, 7950b57cec5SDimitry Andric MachineBasicBlock::iterator I, 7960b57cec5SDimitry Andric bool isMicroMips, bool FP64) const { 7978bcb0991SDimitry Andric Register DstReg = I->getOperand(0).getReg(); 7980b57cec5SDimitry Andric unsigned LoReg = I->getOperand(1).getReg(), HiReg = I->getOperand(2).getReg(); 7990b57cec5SDimitry Andric const MCInstrDesc& Mtc1Tdd = get(Mips::MTC1); 8000b57cec5SDimitry Andric DebugLoc dl = I->getDebugLoc(); 8010b57cec5SDimitry Andric const TargetRegisterInfo &TRI = getRegisterInfo(); 8020b57cec5SDimitry Andric 8030b57cec5SDimitry Andric // When mthc1 is available, use: 8040b57cec5SDimitry Andric // mtc1 Lo, $fp 8050b57cec5SDimitry Andric // mthc1 Hi, $fp 8060b57cec5SDimitry Andric // 8070b57cec5SDimitry Andric // Otherwise, for O32 FPXX ABI: 8080b57cec5SDimitry Andric // spill + reload via ldc1 8090b57cec5SDimitry Andric // This case is handled by the frame lowering code. 8100b57cec5SDimitry Andric // 8110b57cec5SDimitry Andric // Otherwise, for FP32: 8120b57cec5SDimitry Andric // mtc1 Lo, $fp 8130b57cec5SDimitry Andric // mtc1 Hi, $fp + 1 8140b57cec5SDimitry Andric // 8150b57cec5SDimitry Andric // The case where dmtc1 is available doesn't need to be handled here 8160b57cec5SDimitry Andric // because it never creates a BuildPairF64 node. 8170b57cec5SDimitry Andric 8180b57cec5SDimitry Andric // FPXX on MIPS-II or MIPS32r1 should have been handled with a spill/reload 8190b57cec5SDimitry Andric // in MipsSEFrameLowering.cpp. 8200b57cec5SDimitry Andric assert(!(Subtarget.isABI_FPXX() && !Subtarget.hasMips32r2())); 8210b57cec5SDimitry Andric 8220b57cec5SDimitry Andric // FP64A (FP64 with nooddspreg) should have been handled with a spill/reload 8230b57cec5SDimitry Andric // in MipsSEFrameLowering.cpp. 8240b57cec5SDimitry Andric assert(!(Subtarget.isFP64bit() && !Subtarget.useOddSPReg())); 8250b57cec5SDimitry Andric 8260b57cec5SDimitry Andric BuildMI(MBB, I, dl, Mtc1Tdd, TRI.getSubReg(DstReg, Mips::sub_lo)) 8270b57cec5SDimitry Andric .addReg(LoReg); 8280b57cec5SDimitry Andric 8290b57cec5SDimitry Andric if (Subtarget.hasMTHC1()) { 8300b57cec5SDimitry Andric // FIXME: The .addReg(DstReg) is a white lie used to temporarily work 8310b57cec5SDimitry Andric // around a widespread bug in the -mfp64 support. 8320b57cec5SDimitry Andric // The problem is that none of the 32-bit fpu ops mention the fact 8330b57cec5SDimitry Andric // that they clobber the upper 32-bits of the 64-bit FPR. Fixing that 8340b57cec5SDimitry Andric // requires a major overhaul of the FPU implementation which can't 8350b57cec5SDimitry Andric // be done right now due to time constraints. 8360b57cec5SDimitry Andric // MTHC1 is one of two instructions that are affected since they are 8370b57cec5SDimitry Andric // the only instructions that don't read the lower 32-bits. 8380b57cec5SDimitry Andric // We therefore pretend that it reads the bottom 32-bits to 8390b57cec5SDimitry Andric // artificially create a dependency and prevent the scheduler 8400b57cec5SDimitry Andric // changing the behaviour of the code. 8410b57cec5SDimitry Andric BuildMI(MBB, I, dl, 8420b57cec5SDimitry Andric get(isMicroMips ? (FP64 ? Mips::MTHC1_D64_MM : Mips::MTHC1_D32_MM) 8430b57cec5SDimitry Andric : (FP64 ? Mips::MTHC1_D64 : Mips::MTHC1_D32)), 8440b57cec5SDimitry Andric DstReg) 8450b57cec5SDimitry Andric .addReg(DstReg) 8460b57cec5SDimitry Andric .addReg(HiReg); 8470b57cec5SDimitry Andric } else if (Subtarget.isABI_FPXX()) 8480b57cec5SDimitry Andric llvm_unreachable("BuildPairF64 not expanded in frame lowering code!"); 8490b57cec5SDimitry Andric else 8500b57cec5SDimitry Andric BuildMI(MBB, I, dl, Mtc1Tdd, TRI.getSubReg(DstReg, Mips::sub_hi)) 8510b57cec5SDimitry Andric .addReg(HiReg); 8520b57cec5SDimitry Andric } 8530b57cec5SDimitry Andric 8540b57cec5SDimitry Andric void MipsSEInstrInfo::expandEhReturn(MachineBasicBlock &MBB, 8550b57cec5SDimitry Andric MachineBasicBlock::iterator I) const { 8560b57cec5SDimitry Andric // This pseudo instruction is generated as part of the lowering of 8570b57cec5SDimitry Andric // ISD::EH_RETURN. We convert it to a stack increment by OffsetReg, and 8580b57cec5SDimitry Andric // indirect jump to TargetReg 8590b57cec5SDimitry Andric MipsABIInfo ABI = Subtarget.getABI(); 8600b57cec5SDimitry Andric unsigned ADDU = ABI.GetPtrAdduOp(); 8610b57cec5SDimitry Andric unsigned SP = Subtarget.isGP64bit() ? Mips::SP_64 : Mips::SP; 8620b57cec5SDimitry Andric unsigned RA = Subtarget.isGP64bit() ? Mips::RA_64 : Mips::RA; 8630b57cec5SDimitry Andric unsigned T9 = Subtarget.isGP64bit() ? Mips::T9_64 : Mips::T9; 8640b57cec5SDimitry Andric unsigned ZERO = Subtarget.isGP64bit() ? Mips::ZERO_64 : Mips::ZERO; 8658bcb0991SDimitry Andric Register OffsetReg = I->getOperand(0).getReg(); 8668bcb0991SDimitry Andric Register TargetReg = I->getOperand(1).getReg(); 8670b57cec5SDimitry Andric 8680b57cec5SDimitry Andric // addu $ra, $v0, $zero 8690b57cec5SDimitry Andric // addu $sp, $sp, $v1 8700b57cec5SDimitry Andric // jr $ra (via RetRA) 8710b57cec5SDimitry Andric const TargetMachine &TM = MBB.getParent()->getTarget(); 8720b57cec5SDimitry Andric if (TM.isPositionIndependent()) 8730b57cec5SDimitry Andric BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), T9) 8740b57cec5SDimitry Andric .addReg(TargetReg) 8750b57cec5SDimitry Andric .addReg(ZERO); 8760b57cec5SDimitry Andric BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), RA) 8770b57cec5SDimitry Andric .addReg(TargetReg) 8780b57cec5SDimitry Andric .addReg(ZERO); 8790b57cec5SDimitry Andric BuildMI(MBB, I, I->getDebugLoc(), get(ADDU), SP).addReg(SP).addReg(OffsetReg); 8800b57cec5SDimitry Andric expandRetRA(MBB, I); 8810b57cec5SDimitry Andric } 8820b57cec5SDimitry Andric 8830b57cec5SDimitry Andric const MipsInstrInfo *llvm::createMipsSEInstrInfo(const MipsSubtarget &STI) { 8840b57cec5SDimitry Andric return new MipsSEInstrInfo(STI); 8850b57cec5SDimitry Andric } 886