LLVM 21.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"
15
16namespace llvm {
17
18class MachineIRBuilder;
19
20namespace AMDGPU {
21
22// Receives list of RegBankLLTMappingApplyID and applies register banks on all
23// operands. It is user's responsibility to provide RegBankLLTMappingApplyIDs
24// for all register operands, there is no need to specify NonReg for trailing
25// imm operands. This finishes selection of register banks if there is no need
26// to replace instruction. In other case InstApplyMethod will create new
27// instruction(s).
31 const MachineUniformityInfo &MUI;
32 const RegisterBankInfo &RBI;
33 const RegBankLegalizeRules &RBLRules;
34 const RegisterBank *SgprRB;
35 const RegisterBank *VgprRB;
36 const RegisterBank *VccRB;
37
38 static constexpr LLT S1 = LLT::scalar(1);
39 static constexpr LLT S16 = LLT::scalar(16);
40 static constexpr LLT S32 = LLT::scalar(32);
41 static constexpr LLT S64 = LLT::scalar(64);
42 static constexpr LLT S96 = LLT::scalar(96);
43 static constexpr LLT S128 = LLT::scalar(128);
44 static constexpr LLT S256 = LLT::scalar(256);
45
46 static constexpr LLT V2S16 = LLT::fixed_vector(2, 16);
47 static constexpr LLT V4S16 = LLT::fixed_vector(4, 16);
48 static constexpr LLT V6S16 = LLT::fixed_vector(6, 16);
49 static constexpr LLT V8S16 = LLT::fixed_vector(8, 16);
50 static constexpr LLT V16S16 = LLT::fixed_vector(16, 16);
51 static constexpr LLT V32S16 = LLT::fixed_vector(32, 16);
52
53 static constexpr LLT V2S32 = LLT::fixed_vector(2, 32);
54 static constexpr LLT V3S32 = LLT::fixed_vector(3, 32);
55 static constexpr LLT V4S32 = LLT::fixed_vector(4, 32);
56 static constexpr LLT V6S32 = LLT::fixed_vector(6, 32);
57 static constexpr LLT V7S32 = LLT::fixed_vector(7, 32);
58 static constexpr LLT V8S32 = LLT::fixed_vector(8, 32);
59 static constexpr LLT V16S32 = LLT::fixed_vector(16, 32);
60
61 static constexpr LLT V2S64 = LLT::fixed_vector(2, 64);
62 static constexpr LLT V3S64 = LLT::fixed_vector(3, 64);
63 static constexpr LLT V4S64 = LLT::fixed_vector(4, 64);
64 static constexpr LLT V8S64 = LLT::fixed_vector(8, 64);
65 static constexpr LLT V16S64 = LLT::fixed_vector(16, 64);
66
67 static constexpr LLT P1 = LLT::pointer(1, 64);
68 static constexpr LLT P4 = LLT::pointer(4, 64);
69 static constexpr LLT P6 = LLT::pointer(6, 32);
70
71 MachineRegisterInfo::VRegAttrs SgprRB_S32 = {SgprRB, S32};
72 MachineRegisterInfo::VRegAttrs VgprRB_S32 = {VgprRB, S32};
73 MachineRegisterInfo::VRegAttrs VccRB_S1 = {VccRB, S1};
74
75public:
77 const RegisterBankInfo &RBI,
78 const RegBankLegalizeRules &RBLRules);
79
81
82 // Manual apply helpers.
85
86private:
87 bool executeInWaterfallLoop(MachineIRBuilder &B,
89 SmallSet<Register, 4> &SgprOperandRegs);
90
91 LLT getTyFromID(RegBankLLTMappingApplyID ID);
92 LLT getBTyFromID(RegBankLLTMappingApplyID ID, LLT Ty);
93
94 const RegisterBank *getRegBankFromID(RegBankLLTMappingApplyID ID);
95
96 void
97 applyMappingDst(MachineInstr &MI, unsigned &OpIdx,
99
100 void
101 applyMappingSrc(MachineInstr &MI, unsigned &OpIdx,
103 SmallSet<Register, 4> &SgprWaterfallOperandRegs);
104
105 void splitLoad(MachineInstr &MI, ArrayRef<LLT> LLTBreakdown,
106 LLT MergeTy = LLT());
107 void widenLoad(MachineInstr &MI, LLT WideTy, LLT MergeTy = LLT());
108
109 void lower(MachineInstr &MI, const RegBankLLTMapping &Mapping,
110 SmallSet<Register, 4> &SgprWaterfallOperandRegs);
111};
112
113} // end namespace AMDGPU
114} // end namespace llvm
115
116#endif
IRTranslator LLVM IR MI
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SmallSet class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelType.h:42
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
Definition: LowLevelType.h:57
static constexpr LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
Definition: LowLevelType.h:100
Helper class to build MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:71
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.
Definition: RegisterBank.h:28
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:132
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
All attributes(register class or bank and low-level type) a virtual register can have.