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})
92 case Intrinsic::memcpy:
93 case Intrinsic::memset:
94 case Intrinsic::memmove:
106 void X86LegalizerInfo::setLegalizerInfo32bit() {
116 for (
auto Ty : {p0, s1, s8, s16, s32})
119 for (
auto Ty : {s8, s16, s32, p0})
122 for (
unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
123 for (
auto Ty : {s8, s16, s32})
126 for (
unsigned Op : {G_UADDE}) {
131 for (
unsigned MemOp : {G_LOAD, G_STORE}) {
132 for (
auto Ty : {s8, s16, s32, p0})
155 {G_SDIV, G_SREM, G_UDIV, G_UREM})
156 .legalFor({s8, s16, s32})
157 .clampScalar(0, s8, s32);
160 {G_SHL, G_LSHR, G_ASHR})
161 .legalFor({{s8, s8}, {s16, s8}, {s32, s8}})
162 .clampScalar(0, s8, s32)
170 for (
auto Ty : {s8, s16, s32, p0})
174 for (
auto Ty : {s8, s16, s32}) {
185 for (
auto Ty : {s8, s16, s32, p0})
189 for (
const auto &Ty : {s16, s32, s64}) {
193 for (
const auto &Ty : {s8, s16, s32}) {
199 void X86LegalizerInfo::setLegalizerInfo64bit() {
219 for (
unsigned BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR})
222 for (
unsigned MemOp : {G_LOAD, G_STORE})
237 for (
unsigned extOp : {G_ZEXT, G_SEXT, G_ANYEXT}) {
243 .clampScalar(1, s32, s64)
250 .clampScalar(1, s32, s64)
260 .clampScalar(0, s8, s8)
266 {G_SDIV, G_SREM, G_UDIV, G_UREM})
267 .legalFor({s8, s16, s32, s64})
268 .clampScalar(0, s8, s64);
272 {G_SHL, G_LSHR, G_ASHR})
273 .legalFor({{s8, s8}, {s16, s8}, {s32, s8}, {s64, s8}})
274 .clampScalar(0, s8, s64)
284 void X86LegalizerInfo::setLegalizerInfoSSE1() {
293 for (
unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
294 for (
auto Ty : {s32, v4s32})
297 for (
unsigned MemOp : {G_LOAD, G_STORE})
298 for (
auto Ty : {v4s32, v2s64})
305 for (
const auto &Ty : {v4s32, v2s64}) {
313 void X86LegalizerInfo::setLegalizerInfoSSE2() {
329 for (
unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
330 for (
auto Ty : {s64, v2s64})
333 for (
unsigned BinOp : {G_ADD, G_SUB})
334 for (
auto Ty : {v16s8, v8s16, v4s32, v2s64})
349 for (
const auto &Ty :
350 {v16s8, v32s8, v8s16, v16s16, v4s32, v8s32, v2s64, v4s64}) {
354 for (
const auto &Ty : {v16s8, v8s16, v4s32, v2s64}) {
360 void X86LegalizerInfo::setLegalizerInfoSSE41() {
369 void X86LegalizerInfo::setLegalizerInfoAVX() {
387 for (
unsigned MemOp : {G_LOAD, G_STORE})
388 for (
auto Ty : {v8s32, v4s64})
391 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64}) {
395 for (
auto Ty : {v16s8, v8s16, v4s32, v2s64}) {
400 for (
const auto &Ty :
401 {v32s8, v64s8, v16s16, v32s16, v8s32, v16s32, v4s64, v8s64}) {
405 for (
const auto &Ty :
406 {v16s8, v32s8, v8s16, v16s16, v4s32, v8s32, v2s64, v4s64}) {
412 void X86LegalizerInfo::setLegalizerInfoAVX2() {
426 for (
unsigned BinOp : {G_ADD, G_SUB})
427 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64})
430 for (
auto Ty : {v16s16, v8s32})
434 for (
const auto &Ty : {v64s8, v32s16, v16s32, v8s64}) {
438 for (
const auto &Ty : {v32s8, v16s16, v8s32, v4s64}) {
444 void X86LegalizerInfo::setLegalizerInfoAVX512() {
463 for (
unsigned BinOp : {G_ADD, G_SUB})
464 for (
auto Ty : {v16s32, v8s64})
469 for (
unsigned MemOp : {G_LOAD, G_STORE})
470 for (
auto Ty : {v16s32, v8s64})
473 for (
auto Ty : {v64s8, v32s16, v16s32, v8s64}) {
477 for (
auto Ty : {v32s8, v16s16, v8s32, v4s64, v16s8, v8s16, v4s32, v2s64}) {
486 for (
auto Ty : {v4s32, v8s32})
490 void X86LegalizerInfo::setLegalizerInfoAVX512DQ() {
505 for (
auto Ty : {v2s64, v4s64})
509 void X86LegalizerInfo::setLegalizerInfoAVX512BW() {
516 for (
unsigned BinOp : {G_ADD, G_SUB})
517 for (
auto Ty : {v64s8, v32s16})
529 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)
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
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.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
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".
bool legalizeIntrinsic(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const override
Return true if MI is either legal or has been legalized and false if not legal.
unsigned const MachineRegisterInfo * MRI
Helper class to build MachineInstr.
LegalizerHelper::LegalizeResult createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstr &MI)
Create a libcall to memcpy et al.
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT &MinTy, const LLT &MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
Some kind of error has occurred and we could not legalize this instruction.
LegalizeRuleSet & getActionDefinitionsBuilder(unsigned Opcode)
Get the action definition builder for the given opcode.
static SizeAndActionsVec narrowToSmallerAndWidenToSmallest(const SizeAndActionsVec &v)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
LegalizeRuleSet & legalFor(std::initializer_list< LLT > Types)
The instruction is legal when type index 0 is any type in the given list.
Representation of each machine instruction.
static SizeAndActionsVec widenToLargerTypesAndNarrowToLargest(const SizeAndActionsVec &v)
A SizeChangeStrategy for the common case where legalization for a particular operation consists of wi...
LegalizeRuleSet & lower()
The instruction is lowered.
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())
unsigned getIntrinsicID() const
Returns the Intrinsic::ID for this instruction.
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...