xref: /aosp_15_r20/external/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- MipsSEISelDAGToDAG.h - A Dag to Dag Inst Selector for MipsSE -----===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // Subclass of MipsDAGToDAGISel specialized for mips32/64.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "MipsISelDAGToDAG.h"
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker namespace llvm {
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker class MipsSEDAGToDAGISel : public MipsDAGToDAGISel {
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker public:
MipsSEDAGToDAGISel(MipsTargetMachine & TM,CodeGenOpt::Level OL)24*9880d681SAndroid Build Coastguard Worker   explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM, CodeGenOpt::Level OL)
25*9880d681SAndroid Build Coastguard Worker       : MipsDAGToDAGISel(TM, OL) {}
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker private:
28*9880d681SAndroid Build Coastguard Worker 
29*9880d681SAndroid Build Coastguard Worker   bool runOnMachineFunction(MachineFunction &MF) override;
30*9880d681SAndroid Build Coastguard Worker 
31*9880d681SAndroid Build Coastguard Worker   void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
32*9880d681SAndroid Build Coastguard Worker                              MachineFunction &MF);
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker   unsigned getMSACtrlReg(const SDValue RegIdx) const;
35*9880d681SAndroid Build Coastguard Worker 
36*9880d681SAndroid Build Coastguard Worker   bool replaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&);
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker   std::pair<SDNode *, SDNode *> selectMULT(SDNode *N, unsigned Opc,
39*9880d681SAndroid Build Coastguard Worker                                            const SDLoc &dl, EVT Ty, bool HasLo,
40*9880d681SAndroid Build Coastguard Worker                                            bool HasHi);
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker   void selectAddESubE(unsigned MOp, SDValue InFlag, SDValue CmpLHS,
43*9880d681SAndroid Build Coastguard Worker                       const SDLoc &DL, SDNode *Node) const;
44*9880d681SAndroid Build Coastguard Worker 
45*9880d681SAndroid Build Coastguard Worker   bool selectAddrFrameIndex(SDValue Addr, SDValue &Base, SDValue &Offset) const;
46*9880d681SAndroid Build Coastguard Worker   bool selectAddrFrameIndexOffset(SDValue Addr, SDValue &Base, SDValue &Offset,
47*9880d681SAndroid Build Coastguard Worker                                   unsigned OffsetBits) const;
48*9880d681SAndroid Build Coastguard Worker 
49*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm(SDValue Addr, SDValue &Base,
50*9880d681SAndroid Build Coastguard Worker                         SDValue &Offset) const override;
51*9880d681SAndroid Build Coastguard Worker 
52*9880d681SAndroid Build Coastguard Worker   bool selectAddrDefault(SDValue Addr, SDValue &Base,
53*9880d681SAndroid Build Coastguard Worker                          SDValue &Offset) const override;
54*9880d681SAndroid Build Coastguard Worker 
55*9880d681SAndroid Build Coastguard Worker   bool selectIntAddr(SDValue Addr, SDValue &Base,
56*9880d681SAndroid Build Coastguard Worker                      SDValue &Offset) const override;
57*9880d681SAndroid Build Coastguard Worker 
58*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm9(SDValue Addr, SDValue &Base,
59*9880d681SAndroid Build Coastguard Worker                          SDValue &Offset) const;
60*9880d681SAndroid Build Coastguard Worker 
61*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm10(SDValue Addr, SDValue &Base,
62*9880d681SAndroid Build Coastguard Worker                           SDValue &Offset) const;
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm11(SDValue Addr, SDValue &Base,
65*9880d681SAndroid Build Coastguard Worker                           SDValue &Offset) const;
66*9880d681SAndroid Build Coastguard Worker 
67*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm12(SDValue Addr, SDValue &Base,
68*9880d681SAndroid Build Coastguard Worker                           SDValue &Offset) const;
69*9880d681SAndroid Build Coastguard Worker 
70*9880d681SAndroid Build Coastguard Worker   bool selectAddrRegImm16(SDValue Addr, SDValue &Base,
71*9880d681SAndroid Build Coastguard Worker                           SDValue &Offset) const;
72*9880d681SAndroid Build Coastguard Worker 
73*9880d681SAndroid Build Coastguard Worker   bool selectIntAddr11MM(SDValue Addr, SDValue &Base,
74*9880d681SAndroid Build Coastguard Worker                          SDValue &Offset) const override;
75*9880d681SAndroid Build Coastguard Worker 
76*9880d681SAndroid Build Coastguard Worker   bool selectIntAddr12MM(SDValue Addr, SDValue &Base,
77*9880d681SAndroid Build Coastguard Worker                          SDValue &Offset) const override;
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker   bool selectIntAddr16MM(SDValue Addr, SDValue &Base,
80*9880d681SAndroid Build Coastguard Worker                          SDValue &Offset) const override;
81*9880d681SAndroid Build Coastguard Worker 
82*9880d681SAndroid Build Coastguard Worker   bool selectIntAddrLSL2MM(SDValue Addr, SDValue &Base,
83*9880d681SAndroid Build Coastguard Worker                            SDValue &Offset) const override;
84*9880d681SAndroid Build Coastguard Worker 
85*9880d681SAndroid Build Coastguard Worker   bool selectIntAddrMSA(SDValue Addr, SDValue &Base,
86*9880d681SAndroid Build Coastguard Worker                         SDValue &Offset) const override;
87*9880d681SAndroid Build Coastguard Worker 
88*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats.
89*9880d681SAndroid Build Coastguard Worker   bool selectVSplat(SDNode *N, APInt &Imm,
90*9880d681SAndroid Build Coastguard Worker                     unsigned MinSizeInBits) const override;
91*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a given integer.
92*9880d681SAndroid Build Coastguard Worker   bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed,
93*9880d681SAndroid Build Coastguard Worker                                   unsigned ImmBitSize) const;
94*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm1.
95*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm1(SDValue N, SDValue &Imm) const override;
96*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm2.
97*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm2(SDValue N, SDValue &Imm) const override;
98*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm3.
99*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm3(SDValue N, SDValue &Imm) const override;
100*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm4.
101*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm4(SDValue N, SDValue &Imm) const override;
102*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm5.
103*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm5(SDValue N, SDValue &Imm) const override;
104*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm6.
105*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm6(SDValue N, SDValue &Imm) const override;
106*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a uimm8.
107*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimm8(SDValue N, SDValue &Imm) const override;
108*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value fits in a simm5.
109*9880d681SAndroid Build Coastguard Worker   bool selectVSplatSimm5(SDValue N, SDValue &Imm) const override;
110*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value is a power of 2.
111*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const override;
112*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value is the inverse of a
113*9880d681SAndroid Build Coastguard Worker   /// power of 2.
114*9880d681SAndroid Build Coastguard Worker   bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const override;
115*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value is a run of set bits
116*9880d681SAndroid Build Coastguard Worker   /// ending at the most significant bit
117*9880d681SAndroid Build Coastguard Worker   bool selectVSplatMaskL(SDValue N, SDValue &Imm) const override;
118*9880d681SAndroid Build Coastguard Worker   /// \brief Select constant vector splats whose value is a run of set bits
119*9880d681SAndroid Build Coastguard Worker   /// starting at bit zero.
120*9880d681SAndroid Build Coastguard Worker   bool selectVSplatMaskR(SDValue N, SDValue &Imm) const override;
121*9880d681SAndroid Build Coastguard Worker 
122*9880d681SAndroid Build Coastguard Worker   bool trySelect(SDNode *Node) override;
123*9880d681SAndroid Build Coastguard Worker 
124*9880d681SAndroid Build Coastguard Worker   void processFunctionAfterISel(MachineFunction &MF) override;
125*9880d681SAndroid Build Coastguard Worker 
126*9880d681SAndroid Build Coastguard Worker   // Insert instructions to initialize the global base register in the
127*9880d681SAndroid Build Coastguard Worker   // first MBB of the function.
128*9880d681SAndroid Build Coastguard Worker   void initGlobalBaseReg(MachineFunction &MF);
129*9880d681SAndroid Build Coastguard Worker 
130*9880d681SAndroid Build Coastguard Worker   bool SelectInlineAsmMemoryOperand(const SDValue &Op,
131*9880d681SAndroid Build Coastguard Worker                                     unsigned ConstraintID,
132*9880d681SAndroid Build Coastguard Worker                                     std::vector<SDValue> &OutOps) override;
133*9880d681SAndroid Build Coastguard Worker };
134*9880d681SAndroid Build Coastguard Worker 
135*9880d681SAndroid Build Coastguard Worker FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM,
136*9880d681SAndroid Build Coastguard Worker                                   CodeGenOpt::Level OptLevel);
137*9880d681SAndroid Build Coastguard Worker }
138*9880d681SAndroid Build Coastguard Worker 
139*9880d681SAndroid Build Coastguard Worker #endif
140