MipsSEISelDAGToDAG.h revision 263508
1//===-- MipsSEISelDAGToDAG.h - A Dag to Dag Inst Selector for MipsSE -----===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Subclass of MipsDAGToDAGISel specialized for mips32/64.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSSEISELDAGTODAG_H
15#define MIPSSEISELDAGTODAG_H
16
17#include "MipsISelDAGToDAG.h"
18
19namespace llvm {
20
21class MipsSEDAGToDAGISel : public MipsDAGToDAGISel {
22
23public:
24  explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM) : MipsDAGToDAGISel(TM) {}
25
26private:
27
28  virtual bool runOnMachineFunction(MachineFunction &MF);
29
30  void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
31                             MachineFunction &MF);
32
33  unsigned getMSACtrlReg(const SDValue RegIdx) const;
34
35  bool replaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&);
36
37  std::pair<SDNode*, SDNode*> selectMULT(SDNode *N, unsigned Opc, SDLoc dl,
38                                         EVT Ty, bool HasLo, bool HasHi);
39
40  SDNode *selectAddESubE(unsigned MOp, SDValue InFlag, SDValue CmpLHS,
41                         SDLoc DL, SDNode *Node) const;
42
43  virtual bool selectAddrRegImm(SDValue Addr, SDValue &Base,
44                                SDValue &Offset) const;
45
46  virtual bool selectAddrRegReg(SDValue Addr, SDValue &Base,
47                                SDValue &Offset) const;
48
49  virtual bool selectAddrDefault(SDValue Addr, SDValue &Base,
50                                 SDValue &Offset) const;
51
52  virtual bool selectIntAddr(SDValue Addr, SDValue &Base,
53                             SDValue &Offset) const;
54
55  virtual bool selectAddrRegImm12(SDValue Addr, SDValue &Base,
56                                  SDValue &Offset) const;
57
58  virtual bool selectIntAddrMM(SDValue Addr, SDValue &Base,
59                               SDValue &Offset) const;
60
61  /// \brief Select constant vector splats.
62  virtual bool selectVSplat(SDNode *N, APInt &Imm) const;
63  /// \brief Select constant vector splats whose value fits in a given integer.
64  virtual bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed,
65                                  unsigned ImmBitSize) const;
66  /// \brief Select constant vector splats whose value fits in a uimm1.
67  virtual bool selectVSplatUimm1(SDValue N, SDValue &Imm) const;
68  /// \brief Select constant vector splats whose value fits in a uimm2.
69  virtual bool selectVSplatUimm2(SDValue N, SDValue &Imm) const;
70  /// \brief Select constant vector splats whose value fits in a uimm3.
71  virtual bool selectVSplatUimm3(SDValue N, SDValue &Imm) const;
72  /// \brief Select constant vector splats whose value fits in a uimm4.
73  virtual bool selectVSplatUimm4(SDValue N, SDValue &Imm) const;
74  /// \brief Select constant vector splats whose value fits in a uimm5.
75  virtual bool selectVSplatUimm5(SDValue N, SDValue &Imm) const;
76  /// \brief Select constant vector splats whose value fits in a uimm6.
77  virtual bool selectVSplatUimm6(SDValue N, SDValue &Imm) const;
78  /// \brief Select constant vector splats whose value fits in a uimm8.
79  virtual bool selectVSplatUimm8(SDValue N, SDValue &Imm) const;
80  /// \brief Select constant vector splats whose value fits in a simm5.
81  virtual bool selectVSplatSimm5(SDValue N, SDValue &Imm) const;
82  /// \brief Select constant vector splats whose value is a power of 2.
83  virtual bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const;
84  /// \brief Select constant vector splats whose value is the inverse of a
85  /// power of 2.
86  virtual bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const;
87  /// \brief Select constant vector splats whose value is a run of set bits
88  /// ending at the most significant bit
89  virtual bool selectVSplatMaskL(SDValue N, SDValue &Imm) const;
90  /// \brief Select constant vector splats whose value is a run of set bits
91  /// starting at bit zero.
92  virtual bool selectVSplatMaskR(SDValue N, SDValue &Imm) const;
93
94  virtual std::pair<bool, SDNode*> selectNode(SDNode *Node);
95
96  virtual void processFunctionAfterISel(MachineFunction &MF);
97
98  // Insert instructions to initialize the global base register in the
99  // first MBB of the function.
100  void initGlobalBaseReg(MachineFunction &MF);
101};
102
103FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM);
104
105}
106
107#endif
108