Go to the documentation of this file.
14 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
15 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
35 class MachineFunction;
37 class LegalizerHelper;
39 class MachineRegisterInfo;
42 namespace LegalizeActions {
123 Ordering(MMO.getSuccessOrdering()) {}
136 raw_ostream &
print(raw_ostream &OS)
const;
195 std::tie(
RHS.Action,
RHS.TypeIdx,
RHS.NewType);
203 namespace LegalityPredicates {
227 template<
typename Predicate>
230 return P0(Query) && P1(Query);
236 return all(
all(P0, P1), args...);
240 template<
typename Predicate>
243 return P0(Query) || P1(Query);
249 return any(
any(P0, P1), args...);
256 std::initializer_list<LLT> TypesInit);
261 return Query.Types[TypeIdx] !=
Type;
269 std::initializer_list<std::pair<LLT, LLT>> TypesInit);
273 unsigned TypeIdx0,
unsigned TypeIdx1,
unsigned MMOIdx,
274 std::initializer_list<TypePairAndMemDesc> TypesAndMemDescInit);
347 namespace LegalizeMutations {
405 return Predicate(Query);
414 return std::make_pair(0,
LLT{});
420 unsigned AliasOf = 0;
422 bool IsAliasedByAnother =
false;
439 unsigned typeIdx(
unsigned TypeIdx) {
442 "Type Index is out of bounds");
444 TypeIdxsCovered.
set(TypeIdx);
449 void markAllIdxsAsCovered() {
451 TypeIdxsCovered.
set();
452 ImmIdxsCovered.
set();
458 "RuleSet is aliased, change the representative opcode instead");
459 Rules.push_back(Rule);
481 std::initializer_list<LLT> Types) {
482 using namespace LegalityPredicates;
483 return actionIf(Action,
typeInSet(typeIdx(0), Types));
488 std::initializer_list<LLT> Types,
490 using namespace LegalityPredicates;
497 std::initializer_list<std::pair<LLT, LLT>> Types) {
498 using namespace LegalityPredicates;
499 return actionIf(Action,
typePairInSet(typeIdx(0), typeIdx(1), Types));
505 std::initializer_list<std::pair<LLT, LLT>> Types,
507 using namespace LegalityPredicates;
508 return actionIf(Action,
typePairInSet(typeIdx(0), typeIdx(1), Types),
515 std::initializer_list<LLT> Types) {
516 using namespace LegalityPredicates;
518 return actionIf(Action,
typeInSet(typeIdx(0), Types));
522 LegalizeAction Action, std::initializer_list<std::pair<LLT, LLT>> Types) {
523 using namespace LegalityPredicates;
525 return actionIf(Action,
typePairInSet(typeIdx(0), typeIdx(1), Types));
532 std::initializer_list<LLT> Types) {
533 using namespace LegalityPredicates;
534 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types),
543 std::initializer_list<LLT> Types0,
544 std::initializer_list<LLT> Types1) {
545 using namespace LegalityPredicates;
546 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types0),
555 std::initializer_list<LLT> Types1, std::initializer_list<LLT> Types2) {
556 using namespace LegalityPredicates;
557 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types0),
568 assert((AliasOf == 0 || AliasOf == Opcode) &&
569 "Opcode is already aliased to another opcode");
570 assert(Rules.empty() &&
"Aliasing will discard rules");
578 "Imm Index is out of bounds");
580 ImmIdxsCovered.
set(ImmIdx);
589 markAllIdxsAsCovered();
604 markAllIdxsAsCovered();
609 std::initializer_list<std::pair<LLT, LLT>> Types) {
610 markAllIdxsAsCovered();
617 std::initializer_list<LegalityPredicates::TypePairAndMemDesc>
621 typeIdx(0), typeIdx(1), 0, TypesAndMemDesc));
631 std::initializer_list<LLT> Types1) {
637 std::initializer_list<LLT> Types1,
638 std::initializer_list<LLT> Types2) {
644 using namespace LegalizeMutations;
645 markAllIdxsAsCovered();
654 markAllIdxsAsCovered();
660 using namespace LegalizeMutations;
663 markAllIdxsAsCovered();
669 using namespace LegalizeMutations;
672 markAllIdxsAsCovered();
680 markAllIdxsAsCovered();
708 std::initializer_list<LLT> Types1) {
709 using namespace LegalityPredicates;
715 std::initializer_list<LLT> Types1,
716 std::initializer_list<LLT> Types2) {
717 using namespace LegalityPredicates;
724 using namespace LegalizeMutations;
727 markAllIdxsAsCovered();
735 markAllIdxsAsCovered();
742 libcallFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
751 std::initializer_list<LLT> Types1) {
761 markAllIdxsAsCovered();
770 markAllIdxsAsCovered();
787 markAllIdxsAsCovered();
796 markAllIdxsAsCovered();
802 markAllIdxsAsCovered();
837 markAllIdxsAsCovered();
857 std::initializer_list<LLT> Types1) {
864 std::initializer_list<LLT> Types1,
865 std::initializer_list<LLT> Types2) {
878 unsigned MinSize = 0) {
879 using namespace LegalityPredicates;
889 using namespace LegalityPredicates;
898 unsigned MinSize = 0) {
899 using namespace LegalityPredicates;
906 using namespace LegalityPredicates;
912 using namespace LegalityPredicates;
918 using namespace LegalityPredicates;
926 using namespace LegalityPredicates;
927 using namespace LegalizeMutations;
935 unsigned TypeIdx,
const LLT Ty) {
936 using namespace LegalityPredicates;
937 using namespace LegalizeMutations;
946 using namespace LegalityPredicates;
947 using namespace LegalizeMutations;
955 using namespace LegalityPredicates;
956 using namespace LegalizeMutations;
964 using namespace LegalityPredicates;
965 using namespace LegalizeMutations;
976 using namespace LegalityPredicates;
977 using namespace LegalizeMutations;
981 const LLT QueryTy = Query.
Types[TypeIdx];
1007 return Query.
Types[LargeTypeIdx].getScalarSizeInBits() >
1008 Query.
Types[TypeIdx].getSizeInBits();
1018 return Query.
Types[NarrowTypeIdx].getScalarSizeInBits() <
1019 Query.
Types[TypeIdx].getSizeInBits();
1033 unsigned TypeIdx,
unsigned LargeTypeIdx) {
1037 return Query.
Types[LargeTypeIdx].getScalarSizeInBits() >
1038 Query.
Types[TypeIdx].getScalarSizeInBits() &&
1043 return std::make_pair(TypeIdx,
T);
1050 unsigned SmallTypeIdx) {
1054 return Query.
Types[SmallTypeIdx].getScalarSizeInBits() <
1055 Query.
Types[TypeIdx].getScalarSizeInBits() &&
1060 return std::make_pair(TypeIdx,
T);
1068 using namespace LegalityPredicates;
1076 unsigned MinElements) {
1088 return std::make_pair(
1107 return std::make_pair(
1114 unsigned MaxElements) {
1128 return std::make_pair(TypeIdx, NewTy);
1140 "Expected element types to agree");
1189 unsigned getOpcodeIdxForOpcode(
unsigned Opcode)
const;
1190 unsigned getActionDefinitionsIdx(
unsigned Opcode)
const;
1221 getActionDefinitionsBuilder(std::initializer_list<unsigned> Opcodes);
1222 void aliasActionDefinitions(
unsigned OpcodeTo,
unsigned OpcodeFrom);
1242 auto Action = getAction(Query).Action;
1269 virtual unsigned getExtOpcodeForWideningConstant(
LLT SmallTy)
const;
1272 static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
1273 static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
1287 #endif // LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
LegalizeRuleSet & maxScalarOrElt(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at most as wide as Ty.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
LegalizeRuleSet & unsupported()
The instruction is unsupported.
LegalizeRuleSet & widenScalarToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar to the next power of two that is at least MinSize.
LegalizeRuleSet & bitcastIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
The specified type index is coerced if predicate is true.
bool match(const LegalityQuery &Query) const
Test whether the LegalityQuery matches.
This is an optimization pass for GlobalISel generic memory operations.
LegalityPredicate scalarOrEltWiderThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar or a vector with an element type that's wider than the ...
@ OPERAND_FIRST_GENERIC_IMM
unsigned getScalarSizeInBits() const
MemDesc(LLT MemoryTy, uint64_t AlignInBits, AtomicOrdering Ordering)
LegalizeRuleSet & unsupportedIfMemSizeNotPow2()
@ Custom
The target wants to do something special with this combination of operand and type.
@ MoreElements
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
LegalizeRuleSet & maxScalarSameAs(unsigned TypeIdx, unsigned NarrowTypeIdx)
Narrow the scalar to match the size of another.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LegalizeAction Action
The action to take or the final answer.
LegalizeRuleSet & customFor(std::initializer_list< std::pair< LLT, LLT >> Types)
The instruction is custom when type indexes 0 and 1 is any type pair in the given list.
LegalizeRuleSet & minScalarEltSameAsIf(LegalityPredicate Predicate, unsigned TypeIdx, unsigned LargeTypeIdx)
Conditionally widen the scalar or elt to match the size of another.
LegalizeRuleSet & maxScalarIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT Ty)
Conditionally limit the maximum size of the scalar.
@ MoreElements
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
@ FewerElements
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LegalizeRuleSet & customFor(std::initializer_list< LLT > Types)
LegalizeRuleSet & libcall()
The instruction is emitted as a library call.
std::pair< unsigned, LLT > determineMutation(const LegalityQuery &Query) const
Determine the change to make.
@ Bitcast
Perform the operation on a different, but equivalently sized type.
LegalizeRuleSet & clampNumElements(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the number of elements for the given vectors to at least MinTy's number of elements and at most...
@ NarrowScalar
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type.
LegalizeRuleSet & lowerFor(std::initializer_list< LLT > Types, LegalizeMutation Mutation)
The instruction is lowered when type index 0 is any type in the given list.
@ WidenScalar
The operation should be implemented in terms of a wider scalar base-type.
LegalityPredicate typeIsNot(unsigned TypeIdx, LLT Type)
True iff the given type index is not the specified type.
LegalizeRuleSet & minScalarOrEltIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT Ty)
Ensure the scalar or element is at least as wide as Ty.
cl::opt< bool > DisableGISelLegalityCheck
MemDesc(const MachineMemOperand &MMO)
The instances of the Type class are immutable: once they are created, they are never changed.
LegalityPredicate largerThan(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the first type index has a larger total bit size than second type index.
LegalityPredicate scalarNarrowerThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's narrower than the given size.
A description of a memory reference used in the backend.
LegalityPredicate elementTypeIs(unsigned TypeIdx, LLT EltTy)
True if the type index is a vector with element type EltTy.
LegalizeRuleSet & maxScalar(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at most as wide as Ty.
@ WidenScalar
The operation should be implemented in terms of a wider scalar base-type.
LegalizeMutation widenScalarOrEltToNextMultipleOf(unsigned TypeIdx, unsigned Size)
Widen the scalar type or vector element type for the given type index to next multiple of Size.
bool operator==(const TypePairAndMemDesc &Other) const
@ UseLegacyRules
Fall back onto the old rules.
LegalizeRuleSet & widenScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Widen the scalar to the one selected by the mutation if the predicate is true.
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types, const ArrayRef< MemDesc > MMODescrs)
LegalizeRuleSet & scalarizeIf(LegalityPredicate Predicate, unsigned TypeIdx)
LegalityPredicate sizeNotMultipleOf(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar whose size is not a multiple of Size.
LegalizeRuleSet & narrowScalar(unsigned TypeIdx, LegalizeMutation Mutation)
LegalizeRuleSet & minScalarOrElt(unsigned TypeIdx, const LLT Ty)
Ensure the scalar or element is at least as wide as Ty.
LegalizeRuleSet & scalarize(unsigned TypeIdx)
LegalizeRuleSet & clampMaxNumElementsStrict(unsigned TypeIdx, const LLT EltTy, unsigned NumElts)
Express EltTy vectors strictly using vectors with NumElts elements (or scalars when NumElts equals 1)...
LegalizeRuleSet & lower()
The instruction is lowered.
LegalizeMutation changeTo(unsigned TypeIdx, LLT Ty)
Select this specific type for the given type index.
LegalityPredicate isPointer(unsigned TypeIdx)
True iff the specified type index is a pointer (with any address space).
LegalizeRuleSet & alignNumElementsTo(unsigned TypeIdx, const LLT EltTy, unsigned NumElts)
Set number of elements to nearest larger multiple of NumElts.
@ OPERAND_LAST_GENERIC_IMM
Predicate any(Predicate P0, Predicate P1)
True iff P0 or P1 are true.
LegalityPredicate atomicOrderingAtLeastOrStrongerThan(unsigned MMOIdx, AtomicOrdering Ordering)
True iff the specified MMO index has at an atomic ordering of at Ordering or stronger.
LegalizeRuleSet & libcallIf(LegalityPredicate Predicate)
Like legalIf, but for the Libcall action.
LegalizeRuleSet & legalIf(LegalityPredicate Predicate)
The instruction is legal if predicate is true.
LegalizeRuleSet & legalFor(std::initializer_list< std::pair< LLT, LLT >> Types)
The instruction is legal when type indexes 0 and 1 is any type pair in the given list.
LegalizeRuleSet & minScalar(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at least as wide as Ty.
bar al al movzbl eax ret Missed when stored in a memory are stored as single byte objects the value of which is always(false) or 1(true). We are not using this fact
LegalizeActionStep apply(const LegalityQuery &Query) const
Apply the ruleset to the given LegalityQuery.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
static LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
LegacyLegalizeActions::LegacyLegalizeAction Action
The action to take or the final answer.
LegalizeRuleSet & widenScalarOrEltToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar or vector element type to the next power of two that is at least MinSize.
LegalizeRuleSet & clampMinNumElements(unsigned TypeIdx, const LLT EltTy, unsigned MinElements)
Limit the number of elements in EltTy vectors to at least MinElements.
LegalizeRuleSet & customIf(LegalityPredicate Predicate)
LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit)
True iff the given type index is the specified type.
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1, std::initializer_list< LLT > Types2)
The instruction is custom when when type indexes 0, 1, and 2 are all in their respective lists.
LegalizeRuleSet & lowerIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
The instruction is lowered if predicate is true.
A single rule in a legalizer info ruleset.
void aliasTo(unsigned Opcode)
@ NotFound
Sentinel value for when no action was found in the specified table.
LegalityPredicate smallerThan(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the first type index has a smaller total bit size than second type index.
LegalizeRuleSet & moreElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Add more elements to reach the type selected by the mutation if the predicate is true.
TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
LegalityPredicate scalarOrEltSizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar or vector whose element size is not a power of 2.
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1, std::initializer_list< LLT > Types2)
The instruction is legal when type indexes 0, 1, and 2 are both their respective lists.
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
LegalizeRuleSet & lowerIfMemSizeNotPow2()
Lower a memory operation if the memory size, rounded to bytes, is not a power of 2.
LegalizeRuleSet & fewerElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Remove elements to reach the type selected by the mutation if the predicate is true.
LegalizeRuleSet & legalForTypeWithAnyImm(std::initializer_list< std::pair< LLT, LLT >> Types)
const MachineInstr * machineFunctionIsIllegal(const MachineFunction &MF)
Checks that MIR is fully legal, returns an illegal instruction if it's not, nullptr otherwise.
LegacyLegalizerInfo & getLegacyLegalizerInfo()
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
@ Libcall
The operation should be implemented as a call to some kind of runtime support library.
LegalizeRuleSet & clampMaxNumElements(unsigned TypeIdx, const LLT EltTy, unsigned MaxElements)
Limit the number of elements in EltTy vectors to at most MaxElements.
@ Custom
The target wants to do something special with this combination of operand and type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
LegalizeRuleSet & maxScalarEltSameAsIf(LegalityPredicate Predicate, unsigned TypeIdx, unsigned SmallTypeIdx)
Conditionally narrow the scalar or elt to match the size of another.
@ Legal
The operation is expected to be selectable directly by the target, and no transformation is necessary...
static ElementCount getFixed(ScalarTy MinVal)
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types)
LegalizeRule(LegalityPredicate Predicate, LegalizeAction Action, LegalizeMutation Mutation=nullptr)
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Lower
The operation itself must be expressed in terms of simpler actions on this target.
unsigned getAlias() const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
virtual bool legalizeIntrinsic(LegalizerHelper &Helper, MachineInstr &MI) const
LegalizeMutation scalarize(unsigned TypeIdx)
Break up the vector type for the given type index into the element type.
LegalizeRuleSet & lowerIf(LegalityPredicate Predicate)
The instruction is lowered if predicate is true.
LegalizeMutation changeElementTo(unsigned TypeIdx, LLT Ty)
Keep the same scalar or element type as the given type.
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.
bool isCompatible(const TypePairAndMemDesc &Other) const
@ NarrowScalar
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type.
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
LegalizeMutation changeElementSizeTo(unsigned TypeIdx, unsigned FromTypeIdx)
Change the scalar size or element size to have the same scalar size as type index FromIndex.
@ Bitcast
Perform the operation on a different, but equivalently sized type.
void setIsAliasedByAnother()
LegalizeMutation changeElementCountTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same scalar or element type as TypeIdx, but take the number of elements from FromTypeIdx.
LegalizeMutation changeTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same type as the given type index.
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
LegalizeRuleSet & lowerFor(std::initializer_list< LLT > Types)
The instruction is lowered when type index 0 is any type in the given list.
bool verifyImmIdxsCoverage(unsigned NumImmIdxs) const
Check if there is no imm index which is obviously not handled by the LegalizeRuleSet in any way at al...
Predicate all(Predicate P0, Predicate P1, Args... args)
True iff all given predicates are true.
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types)
The instruction is legal when type indexes 0 and 1 are both in the given list.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::function< bool(const LegalityQuery &)> LegalityPredicate
LegalityPredicate typeInSet(unsigned TypeIdx, std::initializer_list< LLT > TypesInit)
True iff the given type index is one of the specified types.
print Print MemDeps of function
LegalizeRuleSet & lowerIfMemSizeNotByteSizePow2()
Lower a memory operation if the memory access size is not a round power of 2 byte size.
@ Legal
The operation is expected to be selectable directly by the target, and no transformation is necessary...
LegalizeRuleSet & lowerFor(std::initializer_list< std::pair< LLT, LLT >> Types)
The instruction is lowered when type indexes 0 and 1 is any type pair in the given list.
LegalizeRuleSet & narrowScalarFor(std::initializer_list< std::pair< LLT, LLT >> Types, LegalizeMutation Mutation)
Narrow the scalar, specified in mutation, when type indexes 0 and 1 is any type pair in the given lis...
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LegalizeRuleSet & legalForTypeWithAnyImm(std::initializer_list< LLT > Types)
The instruction is legal when type index 0 is any type in the given list and imm index 0 is anything.
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types)
LegalizeRuleSet & clampScalarOrElt(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
LegalizeMutation changeElementTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same scalar or element type as the given type index.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LegalityPredicate typePairInSet(unsigned TypeIdx0, unsigned TypeIdx1, std::initializer_list< std::pair< LLT, LLT >> TypesInit)
True iff the given types for the given pair of type indexes is one of the specified type pairs.
LegalizeRuleSet & libcallFor(std::initializer_list< std::pair< LLT, LLT >> Types)
LegalityPredicate sizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar whose size is not a power of.
LegalizeMutation widenScalarOrEltToNextPow2(unsigned TypeIdx, unsigned Min=0)
Widen the scalar type or vector element type for the given type index to the next power of 2.
LegalizeActionStep(LegacyLegalizeActionStep Step)
unsigned const MachineRegisterInfo * MRI
LegalityPredicate isScalar(unsigned TypeIdx)
True iff the specified type index is a scalar.
@ Libcall
The operation should be implemented as a call to some kind of runtime support library.
LLT NewType
If describing an action, the new type for TypeIdx. Otherwise LLT{}.
const LegacyLegalizerInfo & getLegacyLegalizerInfo() const
LegalizeActionStep(LegalizeAction Action, unsigned TypeIdx, const LLT NewType)
LegalityPredicate scalarOrEltNarrowerThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar or vector with an element type that's narrower than the...
LegalizeRuleSet & narrowScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Narrow the scalar to the one selected by the mutation if the predicate is true.
LegalizeRuleSet & lowerFor(std::initializer_list< std::pair< LLT, LLT >> Types, LegalizeMutation Mutation)
The instruction is lowered when type indexes 0 and 1 is any type pair in the given list.
LegalizeRuleSet()=default
LegalityPredicate sizeIs(unsigned TypeIdx, unsigned Size)
True if the total bitwidth of the specified type index is Size bits.
bool isAliasedByAnother()
Interface to description of machine instruction set.
LegalizeRuleSet & alwaysLegal()
unsigned immIdx(unsigned ImmIdx)
LegalizeAction getAction() const
LegalityPredicate memSizeInBytesNotPow2(unsigned MMOIdx)
True iff the specified MMO index has a size (rounded to bytes) that is not a power of 2.
bool verifyTypeIdxsCoverage(unsigned NumTypeIdxs) const
Check if there is no type index which is obviously not handled by the LegalizeRuleSet in any way at a...
LegalityPredicate scalarWiderThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's wider than the given size.
ArrayRef< MemDesc > MMODescrs
Operations which require memory can use this to place requirements on the memory type for each MMO.
LegalizeRuleSet & unsupportedIf(LegalityPredicate Predicate)
@ FewerElements
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
The instruction is legal when type indexes 0 and 1 are both their respective lists.
LegalizeRuleSet & minScalarSameAs(unsigned TypeIdx, unsigned LargeTypeIdx)
Widen the scalar to match the size of another.
@ Unsupported
This operation is completely unsupported on the target.
bool getAlign(const Function &F, unsigned index, unsigned &align)
LegalizeRuleSet & lowerForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
The instruction is lowered when type indexes 0 and 1 are both in their respective lists.
raw_ostream & print(raw_ostream &OS) const
LegalityPredicate memSizeNotByteSizePow2(unsigned MMOIdx)
True iff the specified MMO index has a size that is not an even byte size, or that even byte size is ...
LegalityPredicate numElementsNotPow2(unsigned TypeIdx)
True iff the specified type index is a vector whose element count is not a power of 2.
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
bool operator==(const LegalizeActionStep &RHS) const
unsigned TypeIdx
If describing an action, the type index to change. Otherwise zero.
LegalityPredicate typePairAndMemDescInSet(unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx, std::initializer_list< TypePairAndMemDesc > TypesAndMemDescInit)
True iff the given types for the given pair of type indexes is one of the specified type pairs.
LegalizeRuleSet & fallback()
Fallback on the previous implementation.
LegalizeRuleSet & moreElementsToNextPow2(unsigned TypeIdx)
Add more elements to the vector to reach the next power of two.
bool isLegalOrCustom(const LegalityQuery &Query) const
static LLT scalarOrVector(ElementCount EC, LLT ScalarTy)
LegalizeRuleSet & custom()
Unconditionally custom lower.
@ Unsupported
This operation is completely unsupported on the target.
LegalizeRuleSet & unsupportedFor(std::initializer_list< LLT > Types)
std::function< std::pair< unsigned, LLT >(const LegalityQuery &)> LegalizeMutation
LegalizeMutation moreElementsToNextPow2(unsigned TypeIdx, unsigned Min=0)
Add more elements to the type for the given type index to the next power of.
LegalizeRuleSet & lowerForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1, std::initializer_list< LLT > Types2)
The instruction is lowered when when type indexes 0, 1, and 2 are all in their respective lists.
LegalizeRuleSet & scalarSameSizeAs(unsigned TypeIdx, unsigned SameSizeIdx)
Change the type TypeIdx to have the same scalar size as type SameSizeIdx.
virtual bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const
Called for instructions with the Custom LegalizationAction.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
LegalizeRuleSet & libcallFor(std::initializer_list< LLT > Types)
@ Lower
The operation itself must be expressed in terms of simpler actions on this target.
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
The instruction is custom when type indexes 0 and 1 are both in their respective lists.
LegalityPredicate sameSize(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the specified type indices are both the same bit size.
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types)
bool isLegal(const LegalityQuery &Query) const
@ NotFound
Sentinel value for when no action was found in the specified table.
LegalizeRuleSet & legalForTypesWithMemDesc(std::initializer_list< LegalityPredicates::TypePairAndMemDesc > TypesAndMemDesc)
The instruction is legal when type indexes 0 and 1 along with the memory size and minimum alignment i...
LegalizeRuleSet & widenScalarToNextMultipleOf(unsigned TypeIdx, unsigned Size)
Widen the scalar to the next multiple of Size.
Optional< std::vector< StOtherPiece > > Other