1*0b57cec5SDimitry Andric //===-- MipsSEInstrInfo.h - Mips32/64 Instruction Information ---*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file contains the Mips32/64 implementation of the TargetInstrInfo class. 10*0b57cec5SDimitry Andric // 11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H 14*0b57cec5SDimitry Andric #define LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #include "MipsInstrInfo.h" 17*0b57cec5SDimitry Andric #include "MipsSERegisterInfo.h" 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric namespace llvm { 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric class MipsSEInstrInfo : public MipsInstrInfo { 22*0b57cec5SDimitry Andric const MipsSERegisterInfo RI; 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric public: 25*0b57cec5SDimitry Andric explicit MipsSEInstrInfo(const MipsSubtarget &STI); 26*0b57cec5SDimitry Andric 27*0b57cec5SDimitry Andric const MipsRegisterInfo &getRegisterInfo() const override; 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andric /// isLoadFromStackSlot - If the specified machine instruction is a direct 30*0b57cec5SDimitry Andric /// load from a stack slot, return the virtual or physical register number of 31*0b57cec5SDimitry Andric /// the destination along with the FrameIndex of the loaded stack slot. If 32*0b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 33*0b57cec5SDimitry Andric /// any side effects other than loading from the stack slot. 34*0b57cec5SDimitry Andric unsigned isLoadFromStackSlot(const MachineInstr &MI, 35*0b57cec5SDimitry Andric int &FrameIndex) const override; 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric /// isStoreToStackSlot - If the specified machine instruction is a direct 38*0b57cec5SDimitry Andric /// store to a stack slot, return the virtual or physical register number of 39*0b57cec5SDimitry Andric /// the source reg along with the FrameIndex of the loaded stack slot. If 40*0b57cec5SDimitry Andric /// not, return 0. This predicate must return 0 if the instruction has 41*0b57cec5SDimitry Andric /// any side effects other than storing to the stack slot. 42*0b57cec5SDimitry Andric unsigned isStoreToStackSlot(const MachineInstr &MI, 43*0b57cec5SDimitry Andric int &FrameIndex) const override; 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, 46*0b57cec5SDimitry Andric const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, 47*0b57cec5SDimitry Andric bool KillSrc) const override; 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andric void storeRegToStack(MachineBasicBlock &MBB, 50*0b57cec5SDimitry Andric MachineBasicBlock::iterator MI, 51*0b57cec5SDimitry Andric unsigned SrcReg, bool isKill, int FrameIndex, 52*0b57cec5SDimitry Andric const TargetRegisterClass *RC, 53*0b57cec5SDimitry Andric const TargetRegisterInfo *TRI, 54*0b57cec5SDimitry Andric int64_t Offset) const override; 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andric void loadRegFromStack(MachineBasicBlock &MBB, 57*0b57cec5SDimitry Andric MachineBasicBlock::iterator MI, 58*0b57cec5SDimitry Andric unsigned DestReg, int FrameIndex, 59*0b57cec5SDimitry Andric const TargetRegisterClass *RC, 60*0b57cec5SDimitry Andric const TargetRegisterInfo *TRI, 61*0b57cec5SDimitry Andric int64_t Offset) const override; 62*0b57cec5SDimitry Andric 63*0b57cec5SDimitry Andric bool expandPostRAPseudo(MachineInstr &MI) const override; 64*0b57cec5SDimitry Andric 65*0b57cec5SDimitry Andric unsigned getOppositeBranchOpc(unsigned Opc) const override; 66*0b57cec5SDimitry Andric 67*0b57cec5SDimitry Andric /// Adjust SP by Amount bytes. 68*0b57cec5SDimitry Andric void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, 69*0b57cec5SDimitry Andric MachineBasicBlock::iterator I) const override; 70*0b57cec5SDimitry Andric 71*0b57cec5SDimitry Andric /// Emit a series of instructions to load an immediate. If NewImm is a 72*0b57cec5SDimitry Andric /// non-NULL parameter, the last instruction is not emitted, but instead 73*0b57cec5SDimitry Andric /// its immediate operand is returned in NewImm. 74*0b57cec5SDimitry Andric unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB, 75*0b57cec5SDimitry Andric MachineBasicBlock::iterator II, const DebugLoc &DL, 76*0b57cec5SDimitry Andric unsigned *NewImm) const; 77*0b57cec5SDimitry Andric 78*0b57cec5SDimitry Andric protected: 79*0b57cec5SDimitry Andric /// If the specific machine instruction is a instruction that moves/copies 80*0b57cec5SDimitry Andric /// value from one register to another register return true along with 81*0b57cec5SDimitry Andric /// @Source machine operand and @Destination machine operand. 82*0b57cec5SDimitry Andric bool isCopyInstrImpl(const MachineInstr &MI, const MachineOperand *&Source, 83*0b57cec5SDimitry Andric const MachineOperand *&Destination) const override; 84*0b57cec5SDimitry Andric 85*0b57cec5SDimitry Andric private: 86*0b57cec5SDimitry Andric unsigned getAnalyzableBrOpc(unsigned Opc) const override; 87*0b57cec5SDimitry Andric 88*0b57cec5SDimitry Andric void expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; 89*0b57cec5SDimitry Andric 90*0b57cec5SDimitry Andric void expandERet(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; 91*0b57cec5SDimitry Andric 92*0b57cec5SDimitry Andric std::pair<bool, bool> compareOpndSize(unsigned Opc, 93*0b57cec5SDimitry Andric const MachineFunction &MF) const; 94*0b57cec5SDimitry Andric 95*0b57cec5SDimitry Andric void expandPseudoMFHiLo(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 96*0b57cec5SDimitry Andric unsigned NewOpc) const; 97*0b57cec5SDimitry Andric 98*0b57cec5SDimitry Andric void expandPseudoMTLoHi(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 99*0b57cec5SDimitry Andric unsigned LoOpc, unsigned HiOpc, 100*0b57cec5SDimitry Andric bool HasExplicitDef) const; 101*0b57cec5SDimitry Andric 102*0b57cec5SDimitry Andric /// Expand pseudo Int-to-FP conversion instructions. 103*0b57cec5SDimitry Andric /// 104*0b57cec5SDimitry Andric /// For example, the following pseudo instruction 105*0b57cec5SDimitry Andric /// PseudoCVT_D32_W D2, A5 106*0b57cec5SDimitry Andric /// gets expanded into these two instructions: 107*0b57cec5SDimitry Andric /// MTC1 F4, A5 108*0b57cec5SDimitry Andric /// CVT_D32_W D2, F4 109*0b57cec5SDimitry Andric /// 110*0b57cec5SDimitry Andric /// We do this expansion post-RA to avoid inserting a floating point copy 111*0b57cec5SDimitry Andric /// instruction between MTC1 and CVT_D32_W. 112*0b57cec5SDimitry Andric void expandCvtFPInt(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 113*0b57cec5SDimitry Andric unsigned CvtOpc, unsigned MovOpc, bool IsI64) const; 114*0b57cec5SDimitry Andric 115*0b57cec5SDimitry Andric void expandExtractElementF64(MachineBasicBlock &MBB, 116*0b57cec5SDimitry Andric MachineBasicBlock::iterator I, bool isMicroMips, 117*0b57cec5SDimitry Andric bool FP64) const; 118*0b57cec5SDimitry Andric void expandBuildPairF64(MachineBasicBlock &MBB, 119*0b57cec5SDimitry Andric MachineBasicBlock::iterator I, bool isMicroMips, 120*0b57cec5SDimitry Andric bool FP64) const; 121*0b57cec5SDimitry Andric void expandEhReturn(MachineBasicBlock &MBB, 122*0b57cec5SDimitry Andric MachineBasicBlock::iterator I) const; 123*0b57cec5SDimitry Andric }; 124*0b57cec5SDimitry Andric 125*0b57cec5SDimitry Andric } 126*0b57cec5SDimitry Andric 127*0b57cec5SDimitry Andric #endif 128