1//===-- MipsSEISelDAGToDAG.h - A Dag to Dag Inst Selector for MipsSE -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Subclass of MipsDAGToDAGISel specialized for mips32/64.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
14#define LLVM_LIB_TARGET_MIPS_MIPSSEISELDAGTODAG_H
15
16#include "MipsISelDAGToDAG.h"
17
18namespace llvm {
19
20class MipsSEDAGToDAGISel : public MipsDAGToDAGISel {
21
22public:
23 explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM, CodeGenOptLevel OL)
24 : MipsDAGToDAGISel(TM, OL) {}
25
26private:
27
28 bool runOnMachineFunction(MachineFunction &MF) override;
29
30 void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
31 MachineFunction &MF);
32
33 MCRegister getMSACtrlReg(const SDValue RegIdx) const;
34
35 bool replaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&);
36
37 void selectAddE(SDNode *Node, const SDLoc &DL) const;
38
39 bool selectAddrFrameIndex(SDValue Addr, SDValue &Base, SDValue &Offset) const;
40 bool selectAddrFrameIndexOffset(SDValue Addr, SDValue &Base, SDValue &Offset,
41 unsigned OffsetBits,
42 unsigned ShiftAmount) const;
43
44 bool selectAddrRegImm(SDValue Addr, SDValue &Base,
45 SDValue &Offset) const override;
46
47 bool selectAddrDefault(SDValue Addr, SDValue &Base,
48 SDValue &Offset) const override;
49
50 bool selectIntAddr(SDValue Addr, SDValue &Base,
51 SDValue &Offset) const override;
52
53 bool selectAddrRegImm9(SDValue Addr, SDValue &Base,
54 SDValue &Offset) const;
55
56 bool selectAddrRegImm11(SDValue Addr, SDValue &Base,
57 SDValue &Offset) const;
58
59 bool selectAddrRegImm12(SDValue Addr, SDValue &Base,
60 SDValue &Offset) const;
61
62 bool selectAddrRegImm16(SDValue Addr, SDValue &Base,
63 SDValue &Offset) const;
64
65 bool selectIntAddr11MM(SDValue Addr, SDValue &Base,
66 SDValue &Offset) const override;
67
68 bool selectIntAddr12MM(SDValue Addr, SDValue &Base,
69 SDValue &Offset) const override;
70
71 bool selectIntAddr16MM(SDValue Addr, SDValue &Base,
72 SDValue &Offset) const override;
73
74 bool selectIntAddrLSL2MM(SDValue Addr, SDValue &Base,
75 SDValue &Offset) const override;
76
77 bool selectIntAddrSImm10(SDValue Addr, SDValue &Base,
78 SDValue &Offset) const override;
79
80 bool selectIntAddrSImm10Lsl1(SDValue Addr, SDValue &Base,
81 SDValue &Offset) const override;
82
83 bool selectIntAddrSImm10Lsl2(SDValue Addr, SDValue &Base,
84 SDValue &Offset) const override;
85
86 bool selectIntAddrSImm10Lsl3(SDValue Addr, SDValue &Base,
87 SDValue &Offset) const override;
88
89 /// Select constant vector splats.
90 bool selectVSplat(SDNode *N, APInt &Imm,
91 unsigned MinSizeInBits) const override;
92 /// Select constant vector splats whose value fits in a given integer.
93 bool selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed,
94 unsigned ImmBitSize) const override;
95 /// Select constant vector splats whose value is a power of 2.
96 bool selectVSplatUimmPow2(SDValue N, SDValue &Imm) const override;
97 /// Select constant vector splats whose value is the inverse of a
98 /// power of 2.
99 bool selectVSplatUimmInvPow2(SDValue N, SDValue &Imm) const override;
100 /// Select constant vector splats whose value is a run of set bits
101 /// ending at the most significant bit.
102 bool selectVSplatMaskL(SDValue N, SDValue &Imm) const override;
103 /// Select constant vector splats whose value is a run of set bits
104 /// starting at bit zero.
105 bool selectVSplatMaskR(SDValue N, SDValue &Imm) const override;
106
107 /// Select constant vector splats whose value is 1.
108 bool selectVSplatImmEq1(SDValue N) const override;
109
110 bool trySelect(SDNode *Node) override;
111
112 // Emits proper ABI for _mcount profiling calls.
113 void emitMCountABI(MachineInstr &MI, MachineBasicBlock &MBB,
114 MachineFunction &MF);
115
116 void processFunctionAfterISel(MachineFunction &MF) override;
117
118 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
119 InlineAsm::ConstraintCode ConstraintID,
120 std::vector<SDValue> &OutOps) override;
121};
122
123class MipsSEDAGToDAGISelLegacy : public MipsDAGToDAGISelLegacy {
124public:
125 explicit MipsSEDAGToDAGISelLegacy(MipsTargetMachine &TM, CodeGenOptLevel OL);
126 void getAnalysisUsage(AnalysisUsage &AU) const override;
127};
128
129FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM,
130 CodeGenOptLevel OptLevel);
131}
132
133#endif
134