23 using namespace TargetOpcode;
38 for (
unsigned i = 0; i < v.size(); ++i) {
39 result.push_back(v[i]);
40 if (i + 1 < v[i].
first && i + 1 < v.size() &&
41 v[i + 1].first != v[i].first + 1)
42 result.push_back({v[i].first + 1, Unsupported});
53 auto Largest = result.back().first;
60 : Subtarget(STI), TM(TM) {
62 setLegalizerInfo32bit();
63 setLegalizerInfo64bit();
64 setLegalizerInfoSSE1();
65 setLegalizerInfoSSE2();
66 setLegalizerInfoSSE41();
67 setLegalizerInfoAVX();
68 setLegalizerInfoAVX2();
69 setLegalizerInfoAVX512();
70 setLegalizerInfoAVX512DQ();
71 setLegalizerInfoAVX512BW();
74 for (
unsigned BinOp : {G_SUB, G_MUL, G_AND, G_OR, G_XOR})
76 for (
unsigned MemOp : {G_LOAD, G_STORE})
88 void X86LegalizerInfo::setLegalizerInfo32bit() {
98 for (
auto Ty : {p0, s1, s8, s16, s32})
101 for (
auto Ty : {s8, s16, s32, p0})
104 for (
unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
105 for (
auto Ty : {s8, s16, s32})
108 for (
unsigned Op : {G_UADDE}) {
113 for (
unsigned MemOp : {G_LOAD, G_STORE}) {
114 for (
auto Ty : {s8, s16, s32, p0})
137 {G_SHL, G_LSHR, G_ASHR, G_SDIV, G_SREM, G_UDIV, G_UREM})
138 .legalFor({s8, s16, s32})
139 .clampScalar(0, s8, s32);
146 for (
auto Ty : {s8, s16, s32, p0})
150 for (
auto Ty : {s8, s16, s32}) {
160 for (
auto Ty : {s8, s16, s32, p0})
164 for (
const auto &Ty : {s16, s32, s64}) {
168 for (
const auto &Ty : {s8, s16, s32}) {
174 void X86LegalizerInfo::setLegalizerInfo64bit() {
194 for (
unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
197 for (
unsigned MemOp : {G_LOAD, G_STORE})
212 for (
unsigned extOp : {G_ZEXT, G_SEXT, G_ANYEXT}) {
218 .clampScalar(1, s32, s64)
225 .clampScalar(1, s32, s64)
235 .clampScalar(0, s8, s8)
241 {G_SHL, G_LSHR, G_ASHR, G_SDIV, G_SREM, G_UDIV, G_UREM})
242 .legalFor({s8, s16, s32, s64})
243 .clampScalar(0, s8, s64);
252 void X86LegalizerInfo::setLegalizerInfoSSE1() {
261 for (
unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
262 for (
auto Ty : {s32, v4s32})
265 for (
unsigned MemOp : {G_LOAD, G_STORE})
266 for (
auto Ty : {v4s32, v2s64})
273 for (
const auto &Ty : {v4s32, v2s64}) {
281 void X86LegalizerInfo::setLegalizerInfoSSE2() {
297 for (
unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
298 for (
auto Ty : {s64, v2s64})
301 for (
unsigned BinOp : {G_ADD, G_SUB})
302 for (
auto Ty : {v16s8, v8s16, v4s32, v2s64})
317 for (
const auto &Ty :
318 {v16s8, v32s8, v8s16, v16s16, v4s32, v8s32, v2s64, v4s64}) {
322 for (
const auto &Ty : {v16s8, v8s16, v4s32, v2s64}) {
328 void X86LegalizerInfo::setLegalizerInfoSSE41() {
337 void X86LegalizerInfo::setLegalizerInfoAVX() {
355 for (
unsigned MemOp : {G_LOAD, G_STORE})
356 for (
auto Ty : {v8s32, v4s64})
359 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64}) {
363 for (
auto Ty : {v16s8, v8s16, v4s32, v2s64}) {
368 for (
const auto &Ty :
369 {v32s8, v64s8, v16s16, v32s16, v8s32, v16s32, v4s64, v8s64}) {
373 for (
const auto &Ty :
374 {v16s8, v32s8, v8s16, v16s16, v4s32, v8s32, v2s64, v4s64}) {
380 void X86LegalizerInfo::setLegalizerInfoAVX2() {
394 for (
unsigned BinOp : {G_ADD, G_SUB})
395 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64})
398 for (
auto Ty : {v16s16, v8s32})
402 for (
const auto &Ty : {v64s8, v32s16, v16s32, v8s64}) {
406 for (
const auto &Ty : {v32s8, v16s16, v8s32, v4s64}) {
412 void X86LegalizerInfo::setLegalizerInfoAVX512() {
431 for (
unsigned BinOp : {G_ADD, G_SUB})
432 for (
auto Ty : {v16s32, v8s64})
437 for (
unsigned MemOp : {G_LOAD, G_STORE})
438 for (
auto Ty : {v16s32, v8s64})
441 for (
auto Ty : {v64s8, v32s16, v16s32, v8s64}) {
445 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64, v16s8, v8s16, v4s32, v2s64}) {
454 for (
auto Ty : {v4s32, v8s32})
458 void X86LegalizerInfo::setLegalizerInfoAVX512DQ() {
473 for (
auto Ty : {v2s64, v4s64})
477 void X86LegalizerInfo::setLegalizerInfoAVX512BW() {
484 for (
unsigned BinOp : {G_ADD, G_SUB})
485 for (
auto Ty : {v64s8, v32s16})
497 for (
auto Ty : {v8s16, v16s16})
static void addAndInterleaveWithUnsupported(LegalizerInfo::SizeAndActionsVec &result, const LegalizerInfo::SizeAndActionsVec &v)
FIXME: The following static functions are SizeChangeStrategy functions that are meant to temporarily ...
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
This class represents lattice values for constants.
The operation should be implemented in terms of a wider scalar base-type.
const X86InstrInfo * getInstrInfo() const override
X86LegalizerInfo(const X86Subtarget &STI, const X86TargetMachine &TM)
std::vector< SizeAndAction > SizeAndActionsVec
static LegalizerInfo::SizeAndActionsVec widen_1(const LegalizerInfo::SizeAndActionsVec &v)
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types)
The instruction is legal when type indexes 0 and 1 are both in the given list.
static SizeAndActionsVec widenToLargerTypesUnsupportedOtherwise(const SizeAndActionsVec &v)
LegalizeRuleSet & widenScalarToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar to the next power of two that is at least MinSize.
This operation is completely unsupported on the target.
void verify(const MCInstrInfo &MII) const
Perform simple self-diagnostic and assert if there is anything obviously wrong with the actions set u...
void computeTables()
Compute any ancillary tables needed to quickly decide how an operation should be handled.
unsigned getPointerSizeInBits(unsigned AS) const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT &MinTy, const LLT &MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
LegalizeRuleSet & getActionDefinitionsBuilder(unsigned Opcode)
Get the action definition builder for the given opcode.
static SizeAndActionsVec narrowToSmallerAndWidenToSmallest(const SizeAndActionsVec &v)
LegalizeRuleSet & legalFor(std::initializer_list< LLT > Types)
The instruction is legal when type index 0 is any type in the given list.
static SizeAndActionsVec widenToLargerTypesAndNarrowToLargest(const SizeAndActionsVec &v)
A SizeChangeStrategy for the common case where legalization for a particular operation consists of wi...
void setLegalizeScalarToDifferentSizeStrategy(const unsigned Opcode, const unsigned TypeIdx, SizeChangeStrategy S)
The setAction calls record the non-size-changing legalization actions to take on specificly-sized typ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
This file declares the targeting of the Machinelegalizer class for X86.
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
void setAction(const InstrAspect &Aspect, LegalizeAction Action)
More friendly way to set an action for common types that have an LLT representation.
The operation is expected to be selectable directly by the target, and no transformation is necessary...