[ARM] Better patterns for fp <> predicate vectors
[llvm-complete.git] / lib / Target / AMDGPU / AMDGPUInstructionSelector.h
blob4f489ddfb23db3724f8c88fa37dee80f996ee066
1 //===- AMDGPUInstructionSelector --------------------------------*- C++ -*-==//
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 /// \file
9 /// This file declares the targeting of the InstructionSelector class for
10 /// AMDGPU.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRUCTIONSELECTOR_H
14 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRUCTIONSELECTOR_H
16 #include "AMDGPU.h"
17 #include "AMDGPUArgumentUsageInfo.h"
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/CodeGen/Register.h"
21 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
22 #include "llvm/IR/InstrTypes.h"
24 namespace {
25 #define GET_GLOBALISEL_PREDICATE_BITSET
26 #define AMDGPUSubtarget GCNSubtarget
27 #include "AMDGPUGenGlobalISel.inc"
28 #undef GET_GLOBALISEL_PREDICATE_BITSET
29 #undef AMDGPUSubtarget
32 namespace llvm {
34 class AMDGPUInstrInfo;
35 class AMDGPURegisterBankInfo;
36 class GCNSubtarget;
37 class MachineInstr;
38 class MachineOperand;
39 class MachineRegisterInfo;
40 class SIInstrInfo;
41 class SIMachineFunctionInfo;
42 class SIRegisterInfo;
44 class AMDGPUInstructionSelector : public InstructionSelector {
45 public:
46 AMDGPUInstructionSelector(const GCNSubtarget &STI,
47 const AMDGPURegisterBankInfo &RBI,
48 const AMDGPUTargetMachine &TM);
50 bool select(MachineInstr &I, CodeGenCoverage &CoverageInfo) const override;
51 static const char *getName();
53 private:
54 struct GEPInfo {
55 const MachineInstr &GEP;
56 SmallVector<unsigned, 2> SgprParts;
57 SmallVector<unsigned, 2> VgprParts;
58 int64_t Imm;
59 GEPInfo(const MachineInstr &GEP) : GEP(GEP), Imm(0) { }
62 bool isInstrUniform(const MachineInstr &MI) const;
63 bool isVCC(Register Reg, const MachineRegisterInfo &MRI) const;
65 /// tblgen-erated 'select' implementation.
66 bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
68 MachineOperand getSubOperand64(MachineOperand &MO,
69 const TargetRegisterClass &SubRC,
70 unsigned SubIdx) const;
71 bool selectCOPY(MachineInstr &I) const;
72 bool selectPHI(MachineInstr &I) const;
73 bool selectG_TRUNC(MachineInstr &I) const;
74 bool selectG_SZA_EXT(MachineInstr &I) const;
75 bool selectG_CONSTANT(MachineInstr &I) const;
76 bool selectG_AND_OR_XOR(MachineInstr &I) const;
77 bool selectG_ADD_SUB(MachineInstr &I) const;
78 bool selectG_EXTRACT(MachineInstr &I) const;
79 bool selectG_MERGE_VALUES(MachineInstr &I) const;
80 bool selectG_UNMERGE_VALUES(MachineInstr &I) const;
81 bool selectG_GEP(MachineInstr &I) const;
82 bool selectG_IMPLICIT_DEF(MachineInstr &I) const;
83 bool selectG_INSERT(MachineInstr &I) const;
84 bool selectG_INTRINSIC(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
85 bool selectG_INTRINSIC_W_SIDE_EFFECTS(MachineInstr &I,
86 CodeGenCoverage &CoverageInfo) const;
87 int getS_CMPOpcode(CmpInst::Predicate P, unsigned Size) const;
88 bool selectG_ICMP(MachineInstr &I) const;
89 bool hasVgprParts(ArrayRef<GEPInfo> AddrInfo) const;
90 void getAddrModeInfo(const MachineInstr &Load, const MachineRegisterInfo &MRI,
91 SmallVectorImpl<GEPInfo> &AddrInfo) const;
92 bool selectSMRD(MachineInstr &I, ArrayRef<GEPInfo> AddrInfo) const;
93 bool selectG_LOAD(MachineInstr &I) const;
94 bool selectG_SELECT(MachineInstr &I) const;
95 bool selectG_STORE(MachineInstr &I) const;
96 bool selectG_BRCOND(MachineInstr &I) const;
97 bool selectG_FRAME_INDEX(MachineInstr &I) const;
99 std::pair<Register, unsigned>
100 selectVOP3ModsImpl(Register Src, const MachineRegisterInfo &MRI) const;
102 InstructionSelector::ComplexRendererFns
103 selectVCSRC(MachineOperand &Root) const;
105 InstructionSelector::ComplexRendererFns
106 selectVSRC0(MachineOperand &Root) const;
108 InstructionSelector::ComplexRendererFns
109 selectVOP3Mods0(MachineOperand &Root) const;
110 InstructionSelector::ComplexRendererFns
111 selectVOP3OMods(MachineOperand &Root) const;
112 InstructionSelector::ComplexRendererFns
113 selectVOP3Mods(MachineOperand &Root) const;
115 InstructionSelector::ComplexRendererFns
116 selectSmrdImm(MachineOperand &Root) const;
117 InstructionSelector::ComplexRendererFns
118 selectSmrdImm32(MachineOperand &Root) const;
119 InstructionSelector::ComplexRendererFns
120 selectSmrdSgpr(MachineOperand &Root) const;
122 template <bool Signed>
123 InstructionSelector::ComplexRendererFns
124 selectFlatOffsetImpl(MachineOperand &Root) const;
125 InstructionSelector::ComplexRendererFns
126 selectFlatOffset(MachineOperand &Root) const;
128 InstructionSelector::ComplexRendererFns
129 selectFlatOffsetSigned(MachineOperand &Root) const;
131 InstructionSelector::ComplexRendererFns
132 selectMUBUFScratchOffen(MachineOperand &Root) const;
133 InstructionSelector::ComplexRendererFns
134 selectMUBUFScratchOffset(MachineOperand &Root) const;
136 const SIInstrInfo &TII;
137 const SIRegisterInfo &TRI;
138 const AMDGPURegisterBankInfo &RBI;
139 const AMDGPUTargetMachine &TM;
140 const GCNSubtarget &STI;
141 bool EnableLateStructurizeCFG;
142 #define GET_GLOBALISEL_PREDICATES_DECL
143 #define AMDGPUSubtarget GCNSubtarget
144 #include "AMDGPUGenGlobalISel.inc"
145 #undef GET_GLOBALISEL_PREDICATES_DECL
146 #undef AMDGPUSubtarget
148 #define GET_GLOBALISEL_TEMPORARIES_DECL
149 #include "AMDGPUGenGlobalISel.inc"
150 #undef GET_GLOBALISEL_TEMPORARIES_DECL
153 } // End llvm namespace.
154 #endif