10b57cec5SDimitry Andric //===-- MipsSEISelDAGToDAG.h - A Dag to Dag Inst Selector for MipsSE -----===// 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 // Subclass of MipsDAGToDAGISel specialized for mips32/64. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "MipsISelDAGToDAG.h" 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric namespace llvm { 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric class MipsSEDAGToDAGISel : public MipsDAGToDAGISel { 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric public: MipsSEDAGToDAGISel(MipsTargetMachine & TM,CodeGenOptLevel OL)235f757f3fSDimitry Andric explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM, CodeGenOptLevel OL) 240b57cec5SDimitry Andric : MipsDAGToDAGISel(TM, OL) {} 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric private: 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric bool runOnMachineFunction(MachineFunction &MF) override; 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI, 310b57cec5SDimitry Andric MachineFunction &MF); 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric unsigned getMSACtrlReg(const SDValue RegIdx) const; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric bool replaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&); 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric std::pair<SDNode *, SDNode *> selectMULT(SDNode *N, unsigned Opc, 380b57cec5SDimitry Andric const SDLoc &dl, EVT Ty, bool HasLo, 390b57cec5SDimitry Andric bool HasHi); 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric void selectAddE(SDNode *Node, const SDLoc &DL) const; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric bool selectAddrFrameIndex(SDValue Addr, SDValue &Base, SDValue &Offset) const; 440b57cec5SDimitry Andric bool selectAddrFrameIndexOffset(SDValue Addr, SDValue &Base, SDValue &Offset, 450b57cec5SDimitry Andric unsigned OffsetBits, 460b57cec5SDimitry Andric unsigned ShiftAmount) const; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric bool selectAddrRegImm(SDValue Addr, SDValue &Base, 490b57cec5SDimitry Andric SDValue &Offset) const override; 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric bool selectAddrDefault(SDValue Addr, SDValue &Base, 520b57cec5SDimitry Andric SDValue &Offset) const override; 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric bool selectIntAddr(SDValue Addr, SDValue &Base, 550b57cec5SDimitry Andric SDValue &Offset) const override; 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric bool selectAddrRegImm9(SDValue Addr, SDValue &Base, 580b57cec5SDimitry Andric SDValue &Offset) const; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric bool selectAddrRegImm11(SDValue Addr, SDValue &Base, 610b57cec5SDimitry Andric SDValue &Offset) const; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric bool selectAddrRegImm12(SDValue Addr, SDValue &Base, 640b57cec5SDimitry Andric SDValue &Offset) const; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric bool selectAddrRegImm16(SDValue Addr, SDValue &Base, 670b57cec5SDimitry Andric SDValue &Offset) const; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric bool selectIntAddr11MM(SDValue Addr, SDValue &Base, 700b57cec5SDimitry Andric SDValue &Offset) const override; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric bool selectIntAddr12MM(SDValue Addr, SDValue &Base, 730b57cec5SDimitry Andric SDValue &Offset) const override; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric bool selectIntAddr16MM(SDValue Addr, SDValue &Base, 760b57cec5SDimitry Andric SDValue &Offset) const override; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric bool selectIntAddrLSL2MM(SDValue Addr, SDValue &Base, 790b57cec5SDimitry Andric SDValue &Offset) const override; 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric bool selectIntAddrSImm10(SDValue Addr, SDValue &Base, 820b57cec5SDimitry Andric SDValue &Offset) const override; 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric bool selectIntAddrSImm10Lsl1(SDValue Addr, SDValue &Base, 850b57cec5SDimitry Andric SDValue &Offset) const override; 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric bool selectIntAddrSImm10Lsl2(SDValue Addr, SDValue &Base, 880b57cec5SDimitry Andric SDValue &Offset) const override; 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric bool selectIntAddrSImm10Lsl3(SDValue Addr, SDValue &Base, 910b57cec5SDimitry Andric SDValue &Offset) const override; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric /// Select constant vector splats. 940b57cec5SDimitry Andric bool selectVSplat(SDNode *N, APInt &Imm, 950b57cec5SDimitry Andric unsigned MinSizeInBits) const override; 960b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a given integer. 970b57cec5SDimitry Andric bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed, 980b57cec5SDimitry Andric unsigned ImmBitSize) const; 990b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm1. 1000b57cec5SDimitry Andric bool selectVSplatUimm1(SDValue N, SDValue &Imm) const override; 1010b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm2. 1020b57cec5SDimitry Andric bool selectVSplatUimm2(SDValue N, SDValue &Imm) const override; 1030b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm3. 1040b57cec5SDimitry Andric bool selectVSplatUimm3(SDValue N, SDValue &Imm) const override; 1050b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm4. 1060b57cec5SDimitry Andric bool selectVSplatUimm4(SDValue N, SDValue &Imm) const override; 1070b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm5. 1080b57cec5SDimitry Andric bool selectVSplatUimm5(SDValue N, SDValue &Imm) const override; 1090b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm6. 1100b57cec5SDimitry Andric bool selectVSplatUimm6(SDValue N, SDValue &Imm) const override; 1110b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a uimm8. 1120b57cec5SDimitry Andric bool selectVSplatUimm8(SDValue N, SDValue &Imm) const override; 1130b57cec5SDimitry Andric /// Select constant vector splats whose value fits in a simm5. 1140b57cec5SDimitry Andric bool selectVSplatSimm5(SDValue N, SDValue &Imm) const override; 1150b57cec5SDimitry Andric /// Select constant vector splats whose value is a power of 2. 1160b57cec5SDimitry Andric bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const override; 1170b57cec5SDimitry Andric /// Select constant vector splats whose value is the inverse of a 1180b57cec5SDimitry Andric /// power of 2. 1190b57cec5SDimitry Andric bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const override; 1200b57cec5SDimitry Andric /// Select constant vector splats whose value is a run of set bits 1218bcb0991SDimitry Andric /// ending at the most significant bit. 1220b57cec5SDimitry Andric bool selectVSplatMaskL(SDValue N, SDValue &Imm) const override; 1230b57cec5SDimitry Andric /// Select constant vector splats whose value is a run of set bits 1240b57cec5SDimitry Andric /// starting at bit zero. 1250b57cec5SDimitry Andric bool selectVSplatMaskR(SDValue N, SDValue &Imm) const override; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric bool trySelect(SDNode *Node) override; 1280b57cec5SDimitry Andric 1298bcb0991SDimitry Andric // Emits proper ABI for _mcount profiling calls. 1308bcb0991SDimitry Andric void emitMCountABI(MachineInstr &MI, MachineBasicBlock &MBB, 1318bcb0991SDimitry Andric MachineFunction &MF); 1328bcb0991SDimitry Andric 1330b57cec5SDimitry Andric void processFunctionAfterISel(MachineFunction &MF) override; 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric bool SelectInlineAsmMemoryOperand(const SDValue &Op, 1365f757f3fSDimitry Andric InlineAsm::ConstraintCode ConstraintID, 1370b57cec5SDimitry Andric std::vector<SDValue> &OutOps) override; 1380b57cec5SDimitry Andric }; 1390b57cec5SDimitry Andric 140*0fca6ea1SDimitry Andric class MipsSEDAGToDAGISelLegacy : public MipsDAGToDAGISelLegacy { 141*0fca6ea1SDimitry Andric public: 142*0fca6ea1SDimitry Andric explicit MipsSEDAGToDAGISelLegacy(MipsTargetMachine &TM, CodeGenOptLevel OL); 143*0fca6ea1SDimitry Andric void getAnalysisUsage(AnalysisUsage &AU) const override; 144*0fca6ea1SDimitry Andric }; 145*0fca6ea1SDimitry Andric 1460b57cec5SDimitry Andric FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM, 1475f757f3fSDimitry Andric CodeGenOptLevel OptLevel); 1480b57cec5SDimitry Andric } 1490b57cec5SDimitry Andric 1500b57cec5SDimitry Andric #endif 151