29 using namespace TargetOpcode;
31 auto GetAddrSpacePtr = [&
TM](
unsigned AS) {
68 std::initializer_list<LLT> AllS32Vectors =
69 {V2S32, V3S32, V4S32, V5S32, V6S32, V7S32, V8S32,
70 V9S32, V10S32, V11S32, V12S32, V13S32, V14S32, V15S32, V16S32};
71 std::initializer_list<LLT> AllS64Vectors =
72 {V2S64, V3S64, V4S64, V5S64, V6S64, V7S64, V8S64};
80 const LLT CodePtr = FlatPtr;
82 const LLT AddrSpaces[] = {
90 setAction({G_BRCOND, S1},
Legal);
92 setAction({G_ADD, S32},
Legal);
93 setAction({G_ASHR, S32},
Legal);
94 setAction({G_SUB, S32},
Legal);
95 setAction({G_MUL, S32},
Legal);
98 getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
99 .legalFor({S32, S1, S64, V2S32});
101 getActionDefinitionsBuilder({G_UADDO, G_SADDO, G_USUBO, G_SSUBO,
102 G_UADDE, G_SADDE, G_USUBE, G_SSUBE})
103 .legalFor({{S32, S1}});
105 setAction({G_BITCAST, V2S16},
Legal);
106 setAction({G_BITCAST, 1, S32},
Legal);
108 setAction({G_BITCAST, S32},
Legal);
109 setAction({G_BITCAST, 1, V2S16},
Legal);
111 getActionDefinitionsBuilder(G_FCONSTANT)
112 .legalFor({S32, S64});
118 getActionDefinitionsBuilder(G_IMPLICIT_DEF)
120 return Query.
Types[0].getSizeInBits() <= 512;
122 .clampScalar(0, S1, S512);
124 getActionDefinitionsBuilder(G_CONSTANT)
125 .legalFor({S1, S32, S64});
130 setAction({G_CONSTANT, S1},
Legal);
132 setAction({G_FRAME_INDEX, PrivatePtr},
Legal);
134 getActionDefinitionsBuilder(
135 { G_FADD, G_FMUL, G_FNEG, G_FABS, G_FMA})
136 .legalFor({S32, S64});
138 getActionDefinitionsBuilder(G_FPTRUNC)
139 .legalFor({{S32, S64}});
142 setAction({G_FSUB, S32},
Legal);
145 setAction({G_FSUB, S64},
Lower);
147 setAction({G_FCMP, S1},
Legal);
148 setAction({G_FCMP, 1, S32},
Legal);
149 setAction({G_FCMP, 1, S64},
Legal);
151 setAction({G_ZEXT, S64},
Legal);
152 setAction({G_ZEXT, 1, S32},
Legal);
154 setAction({G_SEXT, S64},
Legal);
155 setAction({G_SEXT, 1, S32},
Legal);
157 setAction({G_ANYEXT, S64},
Legal);
158 setAction({G_ANYEXT, 1, S32},
Legal);
160 setAction({G_FPTOSI, S32},
Legal);
161 setAction({G_FPTOSI, 1, S32},
Legal);
163 setAction({G_SITOFP, S32},
Legal);
164 setAction({G_SITOFP, 1, S32},
Legal);
166 setAction({G_UITOFP, S32},
Legal);
167 setAction({G_UITOFP, 1, S32},
Legal);
169 setAction({G_FPTOUI, S32},
Legal);
170 setAction({G_FPTOUI, 1, S32},
Legal);
172 setAction({G_FPOW, S32},
Legal);
173 setAction({G_FEXP2, S32},
Legal);
174 setAction({G_FLOG2, S32},
Legal);
176 getActionDefinitionsBuilder({G_INTRINSIC_TRUNC, G_INTRINSIC_ROUND})
177 .legalFor({S32, S64});
179 for (
LLT PtrTy : AddrSpaces) {
181 setAction({G_GEP, PtrTy},
Legal);
182 setAction({G_GEP, 1, IdxTy},
Legal);
185 setAction({G_BLOCK_ADDR, CodePtr},
Legal);
187 setAction({G_ICMP, S1},
Legal);
188 setAction({G_ICMP, 1, S32},
Legal);
190 setAction({G_CTLZ, S32},
Legal);
191 setAction({G_CTLZ_ZERO_UNDEF, S32},
Legal);
192 setAction({G_CTTZ, S32},
Legal);
193 setAction({G_CTTZ_ZERO_UNDEF, S32},
Legal);
194 setAction({G_BSWAP, S32},
Legal);
195 setAction({G_CTPOP, S32},
Legal);
197 getActionDefinitionsBuilder(G_INTTOPTR)
202 getActionDefinitionsBuilder(G_PTRTOINT)
207 getActionDefinitionsBuilder({G_LOAD, G_STORE})
232 auto &Atomics = getActionDefinitionsBuilder(
233 {G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD, G_ATOMICRMW_SUB,
234 G_ATOMICRMW_AND, G_ATOMICRMW_OR, G_ATOMICRMW_XOR,
235 G_ATOMICRMW_MAX, G_ATOMICRMW_MIN, G_ATOMICRMW_UMAX,
236 G_ATOMICRMW_UMIN, G_ATOMIC_CMPXCHG})
237 .legalFor({{S32, GlobalPtr}, {S32, LocalPtr},
238 {S64, GlobalPtr}, {S64, LocalPtr}});
240 Atomics.legalFor({{S32, FlatPtr}, {S64, FlatPtr}});
243 setAction({G_SELECT, S32},
Legal);
244 setAction({G_SELECT, 1, S1},
Legal);
246 setAction({G_SHL, S32},
Legal);
255 setAction({G_GEP, S64},
Legal);
257 for (
unsigned Op : {G_EXTRACT_VECTOR_ELT, G_INSERT_VECTOR_ELT}) {
258 getActionDefinitionsBuilder(
Op)
269 getActionDefinitionsBuilder({G_EXTRACT, G_INSERT})
277 getActionDefinitionsBuilder(G_BUILD_VECTOR)
278 .legalForCartesianProduct(AllS32Vectors, {S32})
279 .legalForCartesianProduct(AllS64Vectors, {S64})
280 .clampNumElements(0, V16S32, V16S32)
281 .clampNumElements(0, V2S64, V8S64)
282 .minScalarSameAs(1, 0);
285 getActionDefinitionsBuilder(G_CONCAT_VECTORS)
286 .legalFor({{V4S32, V2S32},
295 for (
unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
296 unsigned BigTyIdx =
Op == G_MERGE_VALUES ? 0 : 1;
297 unsigned LitTyIdx =
Op == G_MERGE_VALUES ? 1 : 0;
299 getActionDefinitionsBuilder(
Op)
301 const LLT &BigTy = Query.
Types[BigTyIdx];
302 const LLT &LitTy = Query.
Types[LitTyIdx];
308 .fewerElementsIf([](
const LegalityQuery &Query) {
return true; },
310 return std::make_pair(
311 0, Query.
Types[0].getElementType());
313 .fewerElementsIf([](
const LegalityQuery &Query) {
return true; },
315 return std::make_pair(
316 1, Query.
Types[1].getElementType());
This class represents lattice values for constants.
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
Address space for private memory.
const SIInstrInfo * getInstrInfo() const override
Address space for constant memory (VTX2)
unsigned getPointerSizeInBits(unsigned AS) const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
The operation itself must be expressed in terms of simpler actions on this target.
Address space for flat memory.
Address space for local memory.
Generation getGeneration() const
AMDGPULegalizerInfo(const GCNSubtarget &ST, const GCNTargetMachine &TM)
The AMDGPU TargetMachine interface definition for hw codgen targets.
Address space for global memory (RAT0, VTX0).
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
bool hasFlatAddressSpace() const
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
This file declares the targeting of the Machinelegalizer class for AMDGPU.
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
The operation is expected to be selectable directly by the target, and no transformation is necessary...