LLVM 23.0.0git
AMDGPURegBankLegalizeHelper.h
Go to the documentation of this file.
1//===- AMDGPURegBankLegalizeHelper ------------------------------*- 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
9#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUREGBANKLEGALIZEHELPER_H
10#define LLVM_LIB_TARGET_AMDGPU_AMDGPUREGBANKLEGALIZEHELPER_H
11
13#include "llvm/ADT/SmallSet.h"
17
18namespace llvm {
19
21
22namespace AMDGPU {
23
24/// Holds waterfall loop information: the set of SGPR operand registers that
25/// need waterfalling, and an instruction range [Start, End) to wrap in the
26/// loop.
32
33// Receives list of RegBankLLTMappingApplyID and applies register banks on all
34// operands. It is user's responsibility to provide RegBankLLTMappingApplyIDs
35// for all register operands, there is no need to specify NonReg for trailing
36// imm operands. This finishes selection of register banks if there is no need
37// to replace instruction. In other case InstApplyMethod will create new
38// instruction(s).
41 const GCNSubtarget &ST;
44 const MachineUniformityInfo &MUI;
45 const RegisterBankInfo &RBI;
47 const RegBankLegalizeRules &RBLRules;
48 const bool IsWave32;
49 const RegisterBank *SgprRB;
50 const RegisterBank *VgprRB;
51 const RegisterBank *VccRB;
52
53 static constexpr LLT S1 = LLT::scalar(1);
54 static constexpr LLT S16 = LLT::scalar(16);
55 static constexpr LLT S32 = LLT::scalar(32);
56 static constexpr LLT S64 = LLT::scalar(64);
57 static constexpr LLT S96 = LLT::scalar(96);
58 static constexpr LLT S128 = LLT::scalar(128);
59 static constexpr LLT S256 = LLT::scalar(256);
60
61 static constexpr LLT V2S16 = LLT::fixed_vector(2, 16);
62 static constexpr LLT V4S16 = LLT::fixed_vector(4, 16);
63 static constexpr LLT V6S16 = LLT::fixed_vector(6, 16);
64 static constexpr LLT V8S16 = LLT::fixed_vector(8, 16);
65 static constexpr LLT V16S16 = LLT::fixed_vector(16, 16);
66 static constexpr LLT V32S16 = LLT::fixed_vector(32, 16);
67
68 static constexpr LLT V2S32 = LLT::fixed_vector(2, 32);
69 static constexpr LLT V3S32 = LLT::fixed_vector(3, 32);
70 static constexpr LLT V4S32 = LLT::fixed_vector(4, 32);
71 static constexpr LLT V6S32 = LLT::fixed_vector(6, 32);
72 static constexpr LLT V7S32 = LLT::fixed_vector(7, 32);
73 static constexpr LLT V8S32 = LLT::fixed_vector(8, 32);
74 static constexpr LLT V16S32 = LLT::fixed_vector(16, 32);
75
76 static constexpr LLT V2S64 = LLT::fixed_vector(2, 64);
77 static constexpr LLT V3S64 = LLT::fixed_vector(3, 64);
78 static constexpr LLT V4S64 = LLT::fixed_vector(4, 64);
79 static constexpr LLT V8S64 = LLT::fixed_vector(8, 64);
80 static constexpr LLT V16S64 = LLT::fixed_vector(16, 64);
81
82 static constexpr LLT P1 = LLT::pointer(1, 64);
83 static constexpr LLT P4 = LLT::pointer(4, 64);
84 static constexpr LLT P6 = LLT::pointer(6, 32);
85
86 MachineRegisterInfo::VRegAttrs SgprRB_S32 = {SgprRB, S32};
87 MachineRegisterInfo::VRegAttrs SgprRB_S16 = {SgprRB, S16};
88 MachineRegisterInfo::VRegAttrs VgprRB_S32 = {VgprRB, S32};
89 MachineRegisterInfo::VRegAttrs VccRB_S1 = {VccRB, S1};
90
91public:
93 const RegisterBankInfo &RBI,
94 const RegBankLegalizeRules &RBLRules);
95
97
98 // Manual apply helpers.
100
101private:
102 bool executeInWaterfallLoop(MachineIRBuilder &B, const WaterfallInfo &WFI);
103
104 LLT getTyFromID(RegBankLLTMappingApplyID ID);
105 LLT getBTyFromID(RegBankLLTMappingApplyID ID, LLT Ty);
106
107 const RegisterBank *getRegBankFromID(RegBankLLTMappingApplyID ID);
108
109 bool
110 applyMappingDst(MachineInstr &MI, unsigned &OpIdx,
112
113 bool
114 applyMappingSrc(MachineInstr &MI, unsigned &OpIdx,
116 WaterfallInfo &WFI);
117
118 bool splitLoad(MachineInstr &MI, ArrayRef<LLT> LLTBreakdown,
119 LLT MergeTy = LLT());
120 bool widenLoad(MachineInstr &MI, LLT WideTy, LLT MergeTy = LLT());
121 bool widenMMOToS32(GAnyLoad &MI) const;
122
123 bool lower(MachineInstr &MI, const RegBankLLTMapping &Mapping,
124 WaterfallInfo &WFI);
125
126 bool lowerVccExtToSel(MachineInstr &MI);
127 std::pair<Register, Register> unpackZExt(Register Reg);
128 std::pair<Register, Register> unpackSExt(Register Reg);
129 std::pair<Register, Register> unpackAExt(Register Reg);
130 std::pair<Register, Register> unpackAExtTruncS16(Register Reg);
131 bool lowerUnpackBitShift(MachineInstr &MI);
132 bool lowerV_BFE(MachineInstr &MI);
133 bool lowerS_BFE(MachineInstr &MI);
134 bool lowerUniMAD64(MachineInstr &MI);
135 bool lowerSplitTo32(MachineInstr &MI);
136 bool lowerSplitTo32Mul(MachineInstr &MI);
137 bool lowerSplitTo16(MachineInstr &MI);
138 bool lowerSplitTo32Select(MachineInstr &MI);
139 bool lowerSplitTo32SExtInReg(MachineInstr &MI);
140 bool lowerUnpackMinMax(MachineInstr &MI);
141 bool lowerUnpackAExt(MachineInstr &MI);
142 bool applyRegisterBanksINTRIN_IMAGE(MachineInstr &MI);
143};
144
145} // end namespace AMDGPU
146} // end namespace llvm
147
148#endif
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
IRTranslator LLVM IR MI
===- MachineOptimizationRemarkEmitter.h - Opt Diagnostics -*- C++ -*-—===//
Register Reg
MachineInstr unsigned OpIdx
This file defines the SmallSet class.
RegBankLegalizeHelper(MachineIRBuilder &B, const MachineUniformityInfo &MUI, const RegisterBankInfo &RBI, const RegBankLegalizeRules &RBLRules)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Represents any generic load, including sign/zero extending variants.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
static constexpr LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
MachineInstrBundleIterator< MachineInstr > iterator
Helper class to build MachineInstr.
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Holds all the information related to register banks.
This class implements the register bank concept.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition SmallSet.h:134
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
GenericUniformityInfo< MachineSSAContext > MachineUniformityInfo
Holds waterfall loop information: the set of SGPR operand registers that need waterfalling,...
MachineBasicBlock::iterator Start
SmallSet< Register, 4 > SgprWaterfallOperandRegs
All attributes(register class or bank and low-level type) a virtual register can have.