1 //===-- MipsSEISelDAGToDAG.h - A Dag to Dag Inst Selector for MipsSE -----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Subclass of MipsDAGToDAGISel specialized for mips32/64.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
15 #define LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
17 #include "MipsISelDAGToDAG.h"
21 class MipsSEDAGToDAGISel : public MipsDAGToDAGISel {
24 explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM) : MipsDAGToDAGISel(TM) {}
28 bool runOnMachineFunction(MachineFunction &MF) override;
30 void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
33 unsigned getMSACtrlReg(const SDValue RegIdx) const;
35 bool replaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&);
37 std::pair<SDNode*, SDNode*> selectMULT(SDNode *N, unsigned Opc, SDLoc dl,
38 EVT Ty, bool HasLo, bool HasHi);
40 SDNode *selectAddESubE(unsigned MOp, SDValue InFlag, SDValue CmpLHS,
41 SDLoc DL, SDNode *Node) const;
43 bool selectAddrFrameIndex(SDValue Addr, SDValue &Base, SDValue &Offset) const;
44 bool selectAddrFrameIndexOffset(SDValue Addr, SDValue &Base, SDValue &Offset,
45 unsigned OffsetBits) const;
47 bool selectAddrRegImm(SDValue Addr, SDValue &Base,
48 SDValue &Offset) const override;
50 bool selectAddrRegReg(SDValue Addr, SDValue &Base,
51 SDValue &Offset) const override;
53 bool selectAddrDefault(SDValue Addr, SDValue &Base,
54 SDValue &Offset) const override;
56 bool selectIntAddr(SDValue Addr, SDValue &Base,
57 SDValue &Offset) const override;
59 bool selectAddrRegImm9(SDValue Addr, SDValue &Base,
60 SDValue &Offset) const;
62 bool selectAddrRegImm10(SDValue Addr, SDValue &Base,
63 SDValue &Offset) const;
65 bool selectAddrRegImm12(SDValue Addr, SDValue &Base,
66 SDValue &Offset) const;
68 bool selectAddrRegImm16(SDValue Addr, SDValue &Base,
69 SDValue &Offset) const;
71 bool selectIntAddrMM(SDValue Addr, SDValue &Base,
72 SDValue &Offset) const override;
74 bool selectIntAddrLSL2MM(SDValue Addr, SDValue &Base,
75 SDValue &Offset) const override;
77 bool selectIntAddrMSA(SDValue Addr, SDValue &Base,
78 SDValue &Offset) const override;
80 /// \brief Select constant vector splats.
81 bool selectVSplat(SDNode *N, APInt &Imm) const override;
82 /// \brief Select constant vector splats whose value fits in a given integer.
83 bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed,
84 unsigned ImmBitSize) const;
85 /// \brief Select constant vector splats whose value fits in a uimm1.
86 bool selectVSplatUimm1(SDValue N, SDValue &Imm) const override;
87 /// \brief Select constant vector splats whose value fits in a uimm2.
88 bool selectVSplatUimm2(SDValue N, SDValue &Imm) const override;
89 /// \brief Select constant vector splats whose value fits in a uimm3.
90 bool selectVSplatUimm3(SDValue N, SDValue &Imm) const override;
91 /// \brief Select constant vector splats whose value fits in a uimm4.
92 bool selectVSplatUimm4(SDValue N, SDValue &Imm) const override;
93 /// \brief Select constant vector splats whose value fits in a uimm5.
94 bool selectVSplatUimm5(SDValue N, SDValue &Imm) const override;
95 /// \brief Select constant vector splats whose value fits in a uimm6.
96 bool selectVSplatUimm6(SDValue N, SDValue &Imm) const override;
97 /// \brief Select constant vector splats whose value fits in a uimm8.
98 bool selectVSplatUimm8(SDValue N, SDValue &Imm) const override;
99 /// \brief Select constant vector splats whose value fits in a simm5.
100 bool selectVSplatSimm5(SDValue N, SDValue &Imm) const override;
101 /// \brief Select constant vector splats whose value is a power of 2.
102 bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const override;
103 /// \brief Select constant vector splats whose value is the inverse of a
105 bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const override;
106 /// \brief Select constant vector splats whose value is a run of set bits
107 /// ending at the most significant bit
108 bool selectVSplatMaskL(SDValue N, SDValue &Imm) const override;
109 /// \brief Select constant vector splats whose value is a run of set bits
110 /// starting at bit zero.
111 bool selectVSplatMaskR(SDValue N, SDValue &Imm) const override;
113 std::pair<bool, SDNode*> selectNode(SDNode *Node) override;
115 void processFunctionAfterISel(MachineFunction &MF) override;
117 // Insert instructions to initialize the global base register in the
118 // first MBB of the function.
119 void initGlobalBaseReg(MachineFunction &MF);
121 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
122 unsigned ConstraintID,
123 std::vector<SDValue> &OutOps) override;
126 FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM);