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 MIPSSEISELDAGTODAG_H
15 #define MIPSSEISELDAGTODAG_H
17 #include "MipsISelDAGToDAG.h"
21 class MipsSEDAGToDAGISel : public MipsDAGToDAGISel {
24 explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM) : MipsDAGToDAGISel(TM) {}
28 virtual bool runOnMachineFunction(MachineFunction &MF);
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 virtual bool selectAddrRegImm(SDValue Addr, SDValue &Base,
48 SDValue &Offset) const;
50 virtual bool selectAddrRegReg(SDValue Addr, SDValue &Base,
51 SDValue &Offset) const;
53 virtual bool selectAddrDefault(SDValue Addr, SDValue &Base,
54 SDValue &Offset) const;
56 virtual bool selectIntAddr(SDValue Addr, SDValue &Base,
57 SDValue &Offset) const;
59 virtual bool selectAddrRegImm10(SDValue Addr, SDValue &Base,
60 SDValue &Offset) const;
62 virtual bool selectAddrRegImm12(SDValue Addr, SDValue &Base,
63 SDValue &Offset) const;
65 virtual bool selectIntAddrMM(SDValue Addr, SDValue &Base,
66 SDValue &Offset) const;
68 virtual bool selectIntAddrMSA(SDValue Addr, SDValue &Base,
69 SDValue &Offset) const;
71 /// \brief Select constant vector splats.
72 virtual bool selectVSplat(SDNode *N, APInt &Imm) const;
73 /// \brief Select constant vector splats whose value fits in a given integer.
74 virtual bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed,
75 unsigned ImmBitSize) const;
76 /// \brief Select constant vector splats whose value fits in a uimm1.
77 virtual bool selectVSplatUimm1(SDValue N, SDValue &Imm) const;
78 /// \brief Select constant vector splats whose value fits in a uimm2.
79 virtual bool selectVSplatUimm2(SDValue N, SDValue &Imm) const;
80 /// \brief Select constant vector splats whose value fits in a uimm3.
81 virtual bool selectVSplatUimm3(SDValue N, SDValue &Imm) const;
82 /// \brief Select constant vector splats whose value fits in a uimm4.
83 virtual bool selectVSplatUimm4(SDValue N, SDValue &Imm) const;
84 /// \brief Select constant vector splats whose value fits in a uimm5.
85 virtual bool selectVSplatUimm5(SDValue N, SDValue &Imm) const;
86 /// \brief Select constant vector splats whose value fits in a uimm6.
87 virtual bool selectVSplatUimm6(SDValue N, SDValue &Imm) const;
88 /// \brief Select constant vector splats whose value fits in a uimm8.
89 virtual bool selectVSplatUimm8(SDValue N, SDValue &Imm) const;
90 /// \brief Select constant vector splats whose value fits in a simm5.
91 virtual bool selectVSplatSimm5(SDValue N, SDValue &Imm) const;
92 /// \brief Select constant vector splats whose value is a power of 2.
93 virtual bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const;
94 /// \brief Select constant vector splats whose value is the inverse of a
96 virtual bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const;
97 /// \brief Select constant vector splats whose value is a run of set bits
98 /// ending at the most significant bit
99 virtual bool selectVSplatMaskL(SDValue N, SDValue &Imm) const;
100 /// \brief Select constant vector splats whose value is a run of set bits
101 /// starting at bit zero.
102 virtual bool selectVSplatMaskR(SDValue N, SDValue &Imm) const;
104 virtual std::pair<bool, SDNode*> selectNode(SDNode *Node);
106 virtual void processFunctionAfterISel(MachineFunction &MF);
108 // Insert instructions to initialize the global base register in the
109 // first MBB of the function.
110 void initGlobalBaseReg(MachineFunction &MF);
113 FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM);