30 using namespace TargetOpcode;
50 getActionDefinitionsBuilder(G_IMPLICIT_DEF)
51 .legalFor({p0, s1, s8, s16, s32, s64})
52 .clampScalar(0, s1, s64)
53 .widenScalarToNextPow2(0, 8);
55 getActionDefinitionsBuilder(G_PHI)
56 .legalFor({p0, s16, s32, s64})
57 .clampScalar(0, s16, s64)
58 .widenScalarToNextPow2(0);
60 getActionDefinitionsBuilder(G_BSWAP)
62 .clampScalar(0, s16, s64)
63 .widenScalarToNextPow2(0);
65 getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR, G_SHL})
66 .legalFor({s32, s64, v2s32, v4s32, v2s64})
67 .clampScalar(0, s32, s64)
68 .widenScalarToNextPow2(0)
69 .clampNumElements(0, v2s32, v4s32)
70 .clampNumElements(0, v2s64, v2s64)
71 .moreElementsToNextPow2(0);
73 getActionDefinitionsBuilder(G_GEP)
74 .legalFor({{p0, s64}})
75 .clampScalar(1, s64, s64);
77 getActionDefinitionsBuilder(G_PTR_MASK).legalFor({p0});
79 getActionDefinitionsBuilder({G_LSHR, G_ASHR, G_SDIV, G_UDIV})
81 .clampScalar(0, s32, s64)
82 .widenScalarToNextPow2(0);
84 getActionDefinitionsBuilder({G_SREM, G_UREM})
85 .lowerFor({s1, s8, s16, s32, s64});
87 getActionDefinitionsBuilder({G_SMULO, G_UMULO})
88 .lowerFor({{s64, s1}});
90 getActionDefinitionsBuilder({G_SMULH, G_UMULH}).legalFor({s32, s64});
92 getActionDefinitionsBuilder({G_UADDE, G_USUBE, G_SADDO, G_SSUBO})
93 .legalFor({{s32, s1}, {s64, s1}});
95 getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMA, G_FMUL, G_FDIV})
96 .legalFor({s32, s64});
98 getActionDefinitionsBuilder({G_FREM, G_FPOW}).libcallFor({s32, s64});
100 getActionDefinitionsBuilder(G_INSERT)
102 return Query.
Types[0].getSizeInBits() <= Query.
Types[1].getSizeInBits();
107 if (Ty0 != s32 && Ty0 != s64 && Ty0 != p0)
112 .clampScalar(0, s32, s64)
113 .widenScalarToNextPow2(0)
114 .maxScalarIf(
typeInSet(0, {s32}), 1, s16)
115 .maxScalarIf(
typeInSet(0, {s64}), 1, s32)
116 .widenScalarToNextPow2(1);
118 getActionDefinitionsBuilder(G_EXTRACT)
120 return Query.
Types[0].getSizeInBits() >= Query.
Types[1].getSizeInBits();
125 if (Ty1 != s32 && Ty1 != s64)
132 .clampScalar(1, s32, s64)
133 .widenScalarToNextPow2(1)
134 .maxScalarIf(
typeInSet(1, {s32}), 0, s16)
135 .maxScalarIf(
typeInSet(1, {s64}), 0, s32)
136 .widenScalarToNextPow2(0);
138 getActionDefinitionsBuilder({G_SEXTLOAD, G_ZEXTLOAD})
139 .legalForTypesWithMemSize({{s32, p0, 8},
145 .clampScalar(0, s32, s64)
146 .widenScalarToNextPow2(0)
149 .unsupportedIfMemSizeNotPow2()
153 getActionDefinitionsBuilder(G_LOAD)
154 .legalForTypesWithMemSize({{s8, p0, 8},
161 .legalForTypesWithMemSize({{s32, p0, 8},
163 .clampScalar(0, s8, s64)
164 .widenScalarToNextPow2(0)
167 .unsupportedIfMemSizeNotPow2()
170 return Query.
Types[0].getSizeInBits() != Query.
MMODescrs[0].Size * 8;
172 .clampNumElements(0, v2s32, v2s32);
174 getActionDefinitionsBuilder(G_STORE)
175 .legalForTypesWithMemSize({{s8, p0, 8},
181 .clampScalar(0, s8, s64)
182 .widenScalarToNextPow2(0)
185 .unsupportedIfMemSizeNotPow2()
187 return Query.
Types[0].isScalar() &&
190 .clampNumElements(0, v2s32, v2s32);
193 getActionDefinitionsBuilder(G_CONSTANT)
194 .legalFor({p0, s32, s64})
195 .clampScalar(0, s32, s64)
196 .widenScalarToNextPow2(0);
197 getActionDefinitionsBuilder(G_FCONSTANT)
198 .legalFor({s32, s64})
199 .clampScalar(0, s32, s64);
201 getActionDefinitionsBuilder(G_ICMP)
202 .legalFor({{s32, s32}, {s32, s64}, {s32, p0}})
203 .clampScalar(0, s32, s32)
204 .clampScalar(1, s32, s64)
205 .widenScalarToNextPow2(1);
207 getActionDefinitionsBuilder(G_FCMP)
208 .legalFor({{s32, s32}, {s32, s64}})
209 .clampScalar(0, s32, s32)
210 .clampScalar(1, s32, s64)
211 .widenScalarToNextPow2(1);
214 getActionDefinitionsBuilder({G_ZEXT, G_SEXT, G_ANYEXT})
215 .legalForCartesianProduct({s8, s16, s32, s64}, {s1, s8, s16, s32});
218 getActionDefinitionsBuilder(G_FPTRUNC).legalFor(
219 {{s16, s32}, {s16, s64}, {s32, s64}});
220 getActionDefinitionsBuilder(G_FPEXT).legalFor(
221 {{s32, s16}, {s64, s16}, {s64, s32}});
224 getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
225 .legalForCartesianProduct({s32, s64})
226 .clampScalar(0, s32, s64)
227 .widenScalarToNextPow2(0)
228 .clampScalar(1, s32, s64)
229 .widenScalarToNextPow2(1);
231 getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
232 .legalForCartesianProduct({s32, s64})
233 .clampScalar(1, s32, s64)
234 .widenScalarToNextPow2(1)
235 .clampScalar(0, s32, s64)
236 .widenScalarToNextPow2(0);
239 getActionDefinitionsBuilder(G_BRCOND).legalFor({s1, s8, s16, s32});
240 getActionDefinitionsBuilder(G_BRINDIRECT).legalFor({p0});
243 getActionDefinitionsBuilder(G_SELECT)
244 .legalFor({{s32, s1}, {s64, s1}, {p0, s1}})
245 .clampScalar(0, s32, s64)
246 .widenScalarToNextPow2(0);
249 getActionDefinitionsBuilder(G_FRAME_INDEX).legalFor({p0});
250 getActionDefinitionsBuilder(G_GLOBAL_VALUE).legalFor({p0});
252 getActionDefinitionsBuilder(G_PTRTOINT)
253 .legalForCartesianProduct({s1, s8, s16, s32, s64}, {p0})
255 .widenScalarToNextPow2(0, 8);
257 getActionDefinitionsBuilder(G_INTTOPTR)
259 return Query.
Types[0].getSizeInBits() != Query.
Types[1].getSizeInBits();
261 .legalFor({{p0, s64}});
265 getActionDefinitionsBuilder(G_BITCAST)
269 .legalForCartesianProduct({s1, s8, s16, s32, s64, s128, v16s8, v8s8, v4s8,
270 v8s16, v4s16, v2s16, v4s32, v2s32, v2s64});
272 getActionDefinitionsBuilder(G_VASTART).legalFor({p0});
276 getActionDefinitionsBuilder(G_VAARG)
277 .customForCartesianProduct({s8, s16, s32, s64, p0}, {p0})
278 .clampScalar(0, s8, s64)
279 .widenScalarToNextPow2(0, 8);
282 getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG_WITH_SUCCESS)
287 getActionDefinitionsBuilder(
288 {G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD, G_ATOMICRMW_SUB, G_ATOMICRMW_AND,
289 G_ATOMICRMW_OR, G_ATOMICRMW_XOR, G_ATOMICRMW_MIN, G_ATOMICRMW_MAX,
290 G_ATOMICRMW_UMIN, G_ATOMICRMW_UMAX, G_ATOMIC_CMPXCHG})
296 getActionDefinitionsBuilder(G_BLOCK_ADDR).legalFor({p0});
299 for (
unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
300 unsigned BigTyIdx =
Op == G_MERGE_VALUES ? 0 : 1;
301 unsigned LitTyIdx =
Op == G_MERGE_VALUES ? 1 : 0;
304 const LLT &Ty = Query.
Types[TypeIdx];
316 const LLT &Ty = Query.
Types[TypeIdx];
328 getActionDefinitionsBuilder(
Op)
331 [=](
const LegalityQuery &Query) {
return notValidElt(Query, 0); },
334 [=](
const LegalityQuery &Query) {
return notValidElt(Query, 1); },
338 .clampScalar(BigTyIdx, s8, s512)
341 const LLT &Ty = Query.
Types[BigTyIdx];
348 const LLT &Ty = Query.
Types[BigTyIdx];
349 unsigned NewSizeInBits = 1
351 if (NewSizeInBits >= 256) {
353 if (RoundedTo < NewSizeInBits)
354 NewSizeInBits = RoundedTo;
356 return std::make_pair(BigTyIdx,
LLT::scalar(NewSizeInBits));
361 .clampScalar(LitTyIdx, s8, s256)
362 .widenScalarToNextPow2(LitTyIdx, 8)
367 const LLT &BigTy = Query.
Types[BigTyIdx];
368 const LLT &LitTy = Query.
Types[LitTyIdx];
376 .fewerElementsIf([](
const LegalityQuery &Query) {
return true; },
378 return std::make_pair(
379 0, Query.
Types[0].getElementType());
381 .fewerElementsIf([](
const LegalityQuery &Query) {
return true; },
383 return std::make_pair(
384 1, Query.
Types[1].getElementType());
399 case TargetOpcode::G_VAARG:
400 return legalizeVaArg(MI, MRI, MIRBuilder);
426 if (Align > PtrSize) {
428 auto AlignMinus1 = MIRBuilder.
buildConstant(IntPtrTy, Align - 1);
431 MIRBuilder.
buildGEP(ListTmp, List, AlignMinus1->getOperand(0).getReg());
442 ValSize,
std::max(Align, PtrSize)));
448 MIRBuilder.
buildGEP(NewList, DstPtr, SizeReg);
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Compute iterated dominance frontiers using a linear time algorithm.
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res = G_GEP Op0, Op1.
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
unsigned getReg() const
getReg - Returns the register number.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit)
True iff the given type index is the specified types.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
LegalityPredicate atomicOrderingAtLeastOrStrongerThan(unsigned MMOIdx, AtomicOrdering Ordering)
True iff the specified MMO index has at an atomic ordering of at Ordering or stronger.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
MachineInstrBuilder buildPtrMask(unsigned Res, unsigned Op0, uint32_t NumBits)
Build and insert Res = G_PTR_MASK Op0, NumBits.
This file declares the targeting of the Machinelegalizer class for AArch64.
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
unsigned const MachineRegisterInfo * MRI
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
AArch64LegalizerInfo(const AArch64Subtarget &ST)
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
This class contains a discriminated union of information about pointers in memory operands...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
The memory access writes data.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, MachineIRBuilder &MIRBuilder) const override
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
This file declares the MachineIRBuilder class.
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
Representation of each machine instruction.
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
LegalityPredicate typeInSet(unsigned TypeIdx, std::initializer_list< LLT > TypesInit)
True iff the given type index is one of the specified types.
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
MachineFunction & getMF()
Getter for the function we currently build.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
const AArch64InstrInfo * getInstrInfo() const override
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
ArrayRef< MemDesc > MMODescrs
Operations which require memory can use this to place requirements on the memory type for each MMO...
const MachineOperand & getOperand(unsigned i) const
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.