14 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H 15 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H 31 #include <unordered_map> 39 class MachineIRBuilder;
40 class MachineRegisterInfo;
42 class GISelChangeObserver;
110 : Opcode(Opcode), Idx(Idx), Type(Type) {}
113 return Opcode == RHS.
Opcode && Idx == RHS.
Idx && Type == RHS.
Type;
137 : Opcode(Opcode), Types(Types), MMODescrs(MMODescrs) {}
139 : LegalityQuery(Opcode, Types, {}) {}
157 : Action(Action), TypeIdx(TypeIdx), NewType(NewType) {}
160 return std::tie(Action, TypeIdx, NewType) ==
177 return Type0 == Other.
Type0 && Type1 == Other.
Type1 &&
178 Align == Other.
Align &&
185 return Type0 == Other.
Type0 && Type1 == Other.
Type1 &&
186 Align >= Other.
Align &&
192 template<
typename Predicate>
195 return P0(Query) && P1(Query);
201 return all(
all(P0, P1), args...);
207 std::initializer_list<LLT> TypesInit);
212 std::initializer_list<std::pair<LLT, LLT>> TypesInit);
216 unsigned TypeIdx0,
unsigned TypeIdx1,
unsigned MMOIdx,
217 std::initializer_list<TypePairAndMemDesc> TypesAndMemDescInit);
301 : Predicate(Predicate), Action(Action), Mutation(Mutation) {}
314 return std::make_pair(0,
LLT{});
322 bool IsAliasedByAnother;
339 unsigned typeIdx(
unsigned TypeIdx) {
342 "Type Index is out of bounds");
344 TypeIdxsCovered.set(TypeIdx);
349 unsigned immIdx(
unsigned ImmIdx) {
351 MCOI::OPERAND_FIRST_GENERIC_IMM) &&
352 "Imm Index is out of bounds");
354 ImmIdxsCovered.set(ImmIdx);
359 void markAllIdxsAsCovered() {
361 TypeIdxsCovered.set();
362 ImmIdxsCovered.set();
368 "RuleSet is aliased, change the representative opcode instead");
391 std::initializer_list<LLT> Types) {
393 return actionIf(Action,
typeInSet(typeIdx(0), Types));
398 std::initializer_list<LLT> Types,
401 return actionIf(Action,
typeInSet(typeIdx(0), Types), Mutation);
407 std::initializer_list<std::pair<LLT, LLT>> Types) {
409 return actionIf(Action,
typePairInSet(typeIdx(0), typeIdx(1), Types));
415 std::initializer_list<std::pair<LLT, LLT>> Types,
418 return actionIf(Action,
typePairInSet(typeIdx(0), typeIdx(1), Types),
425 std::initializer_list<LLT> Types) {
428 return actionIf(Action,
typeInSet(typeIdx(0), Types));
434 std::initializer_list<LLT> Types) {
436 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types),
445 std::initializer_list<LLT> Types0,
446 std::initializer_list<LLT> Types1) {
448 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types0),
457 std::initializer_list<LLT> Types1, std::initializer_list<LLT> Types2) {
459 return actionIf(Action,
all(
typeInSet(typeIdx(0), Types0),
470 assert((AliasOf == 0 || AliasOf == Opcode) &&
471 "Opcode is already aliased to another opcode");
472 assert(Rules.
empty() &&
"Aliasing will discard rules");
481 markAllIdxsAsCovered();
496 markAllIdxsAsCovered();
502 std::initializer_list<LegalityPredicates::TypePairAndMemDesc>
506 typeIdx(0), typeIdx(1), 0, TypesAndMemDesc));
516 std::initializer_list<LLT> Types1) {
522 std::initializer_list<LLT> Types1,
523 std::initializer_list<LLT> Types2) {
530 markAllIdxsAsCovered();
539 markAllIdxsAsCovered();
548 markAllIdxsAsCovered();
556 markAllIdxsAsCovered();
586 std::initializer_list<LLT> Types1) {
593 std::initializer_list<LLT> Types1,
594 std::initializer_list<LLT> Types2) {
604 markAllIdxsAsCovered();
611 libcallFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
620 std::initializer_list<LLT> Types1) {
630 markAllIdxsAsCovered();
639 markAllIdxsAsCovered();
649 markAllIdxsAsCovered();
658 markAllIdxsAsCovered();
664 markAllIdxsAsCovered();
682 markAllIdxsAsCovered();
700 std::initializer_list<LLT> Types1) {
706 return customIf(always);
712 unsigned MinSize = 0) {
722 unsigned MinSize = 0) {
752 unsigned TypeIdx,
const LLT &Ty) {
807 return minScalar(TypeIdx, MinTy).maxScalar(TypeIdx, MaxTy);
813 return minScalarOrElt(TypeIdx, MinTy).
maxScalarOrElt(TypeIdx, MaxTy);
819 return widenScalarIf(
821 return Query.
Types[LargeTypeIdx].getScalarSizeInBits() >
822 Query.
Types[TypeIdx].getSizeInBits();
826 return std::make_pair(TypeIdx,
833 unsigned TypeIdx,
unsigned LargeTypeIdx) {
835 return widenScalarIf(
837 return Query.
Types[LargeTypeIdx].getScalarSizeInBits() >
838 Query.
Types[TypeIdx].getScalarSizeInBits() &&
843 return std::make_pair(TypeIdx, T);
859 unsigned MinElements) {
871 return std::make_pair(
877 unsigned MaxElements) {
890 return std::make_pair(TypeIdx, NewTy);
902 "Expected element types to agree");
905 return clampMinNumElements(TypeIdx, EltTy, MinTy.
getNumElements())
919 bool verifyTypeIdxsCoverage(
unsigned NumTypeIdxs)
const;
923 bool verifyImmIdxsCoverage(
unsigned NumImmIdxs)
const;
934 unsigned getOpcodeIdxForOpcode(
unsigned Opcode)
const;
935 unsigned getActionDefinitionsIdx(
unsigned Opcode)
const;
940 void computeTables();
963 std::function<SizeAndActionsVec(const SizeAndActionsVec &v)>;
970 assert(!needsLegalizingToDifferentSize(Action));
971 TablesInitialized =
false;
972 const unsigned OpcodeIdx = Aspect.
Opcode - FirstOp;
973 if (SpecifiedActions[OpcodeIdx].
size() <= Aspect.
Idx)
974 SpecifiedActions[OpcodeIdx].resize(Aspect.
Idx + 1);
975 SpecifiedActions[OpcodeIdx][Aspect.
Idx][Aspect.
Type] = Action;
995 const unsigned TypeIdx,
997 const unsigned OpcodeIdx = Opcode - FirstOp;
998 if (ScalarSizeChangeStrategies[OpcodeIdx].
size() <= TypeIdx)
999 ScalarSizeChangeStrategies[OpcodeIdx].resize(TypeIdx + 1);
1000 ScalarSizeChangeStrategies[OpcodeIdx][TypeIdx] = S;
1006 const unsigned TypeIdx,
1008 const unsigned OpcodeIdx = Opcode - FirstOp;
1009 if (VectorElementSizeChangeStrategies[OpcodeIdx].
size() <= TypeIdx)
1010 VectorElementSizeChangeStrategies[OpcodeIdx].resize(TypeIdx + 1);
1011 VectorElementSizeChangeStrategies[OpcodeIdx][TypeIdx] = S;
1026 return increaseToLargerTypesAndDecreaseToLargest(v,
Unsupported,
1038 "At least one size that can be legalized towards is needed" 1039 " for this SizeChangeStrategy");
1040 return increaseToLargerTypesAndDecreaseToLargest(v,
WidenScalar,
1047 return increaseToLargerTypesAndDecreaseToLargest(v,
WidenScalar,
1054 return decreaseToSmallerTypesAndIncreaseToSmallest(v,
NarrowScalar,
1062 "At least one size that can be legalized towards is needed" 1063 " for this SizeChangeStrategy");
1064 return decreaseToSmallerTypesAndIncreaseToSmallest(v,
NarrowScalar,
1089 return increaseToLargerTypesAndDecreaseToLargest(v,
MoreElements,
1129 getActionDefinitionsBuilder(std::initializer_list<unsigned> Opcodes);
1130 void aliasActionDefinitions(
unsigned OpcodeTo,
unsigned OpcodeFrom);
1165 virtual unsigned getExtOpcodeForWideningConstant(
LLT SmallTy)
const;
1174 std::pair<LegalizeAction, LLT>
1194 void setScalarAction(
const unsigned Opcode,
const unsigned TypeIndex,
1196 const unsigned OpcodeIdx = Opcode - FirstOp;
1198 setActions(TypeIndex, Actions, SizeAndActions);
1200 void setPointerAction(
const unsigned Opcode,
const unsigned TypeIndex,
1203 const unsigned OpcodeIdx = Opcode - FirstOp;
1204 if (AddrSpace2PointerActions[OpcodeIdx].
find(AddressSpace) ==
1205 AddrSpace2PointerActions[OpcodeIdx].
end())
1206 AddrSpace2PointerActions[OpcodeIdx][
AddressSpace] = {{}};
1208 AddrSpace2PointerActions[OpcodeIdx].find(AddressSpace)->second;
1209 setActions(TypeIndex, Actions, SizeAndActions);
1217 void setScalarInVectorAction(
const unsigned Opcode,
const unsigned TypeIndex,
1219 unsigned OpcodeIdx = Opcode - FirstOp;
1221 ScalarInVectorActions[OpcodeIdx];
1222 setActions(TypeIndex, Actions, SizeAndActions);
1228 void setVectorNumElementAction(
const unsigned Opcode,
1229 const unsigned TypeIndex,
1230 const unsigned ElementSize,
1232 const unsigned OpcodeIdx = Opcode - FirstOp;
1233 if (NumElements2Actions[OpcodeIdx].
find(ElementSize) ==
1234 NumElements2Actions[OpcodeIdx].
end())
1235 NumElements2Actions[OpcodeIdx][ElementSize] = {{}};
1237 NumElements2Actions[OpcodeIdx].find(ElementSize)->second;
1238 setActions(TypeIndex, Actions, SizeAndActions);
1257 int SmallestNarrowIdx = -1;
1258 int LargestWidenIdx = -1;
1259 int SmallestLegalizableToSameSizeIdx = -1;
1260 int LargestLegalizableToSameSizeIdx = -1;
1261 for(
size_t i=0; i<v.size(); ++i) {
1265 if (SmallestNarrowIdx == -1)
1266 SmallestNarrowIdx = i;
1270 LargestWidenIdx = i;
1275 if (SmallestLegalizableToSameSizeIdx == -1)
1276 SmallestLegalizableToSameSizeIdx = i;
1277 LargestLegalizableToSameSizeIdx = i;
1280 if (SmallestNarrowIdx != -1) {
1281 assert(SmallestLegalizableToSameSizeIdx != -1);
1282 assert(SmallestNarrowIdx > SmallestLegalizableToSameSizeIdx);
1284 if (LargestWidenIdx != -1)
1285 assert(LargestWidenIdx < LargestLegalizableToSameSizeIdx);
1296 checkPartialSizeAndActionsVector(v);
1302 void setActions(
unsigned TypeIndex,
1305 checkFullSizeAndActionsVector(SizeAndActions);
1306 if (Actions.
size() <= TypeIndex)
1307 Actions.
resize(TypeIndex + 1);
1308 Actions[TypeIndex] = SizeAndActions;
1325 std::pair<LegalizeAction, LLT>
1326 findScalarLegalAction(
const InstrAspect &Aspect)
const;
1329 std::pair<LegalizeAction, LLT>
1330 findVectorLegalAction(
const InstrAspect &Aspect)
const;
1332 static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
1333 static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
1339 ScalarSizeChangeStrategies[LastOp - FirstOp + 1];
1341 VectorElementSizeChangeStrategies[LastOp - FirstOp + 1];
1342 bool TablesInitialized;
1347 std::unordered_map<uint16_t, SmallVector<SizeAndActionsVec, 1>>
1348 AddrSpace2PointerActions[LastOp - FirstOp + 1];
1349 std::unordered_map<uint16_t, SmallVector<SizeAndActionsVec, 1>>
1350 NumElements2Actions[LastOp - FirstOp + 1];
1363 #endif // LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H InstrAspect(unsigned Opcode, unsigned Idx, LLT Type)
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types)
const_iterator end(StringRef path)
Get end iterator over path.
LegalizeRuleSet & minScalarOrEltIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT &Ty)
Ensure the scalar or element is at least as wide as Ty.
unsigned TypeIdx
If describing an action, the type index to change. Otherwise zero.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
This class represents lattice values for constants.
bool isAliasedByAnother()
unsigned getScalarSizeInBits() const
The operation should be implemented in terms of a wider scalar base-type.
Predicate all(Predicate P0, Predicate P1, Args... args)
True iff all given predicates are true.
std::function< SizeAndActionsVec(const SizeAndActionsVec &v)> SizeChangeStrategy
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...
void push_back(const T &Elt)
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
std::vector< SizeAndAction > SizeAndActionsVec
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
static SizeAndActionsVec narrowToSmallerAndUnsupportedIfTooSmall(const SizeAndActionsVec &v)
unsigned getAlias() const
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 ...
LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit)
True iff the given type index is the specified types.
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types)
LLT NewType
If describing an action, the new type for TypeIdx. Otherwise LLT{}.
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 & scalarize(unsigned TypeIdx)
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types)
The instruction is legal when type indexes 0 and 1 are both in the given list.
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
LegalizeRuleSet & custom()
Unconditionally custom lower.
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types, const ArrayRef< MemDesc > MMODescrs)
static SizeAndActionsVec unsupportedForDifferentSizes(const SizeAndActionsVec &v)
A SizeChangeStrategy for the common case where legalization for a particular operation consists of on...
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type...
static SizeAndActionsVec widenToLargerTypesUnsupportedOtherwise(const SizeAndActionsVec &v)
LegalizeRuleSet & lowerIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
The instruction is lowered if predicate is true.
LegalizeRuleSet & narrowScalar(unsigned TypeIdx, LegalizeMutation Mutation)
LegalizeRuleSet & maxScalarOrElt(unsigned TypeIdx, const LLT &Ty)
Ensure the scalar is at most as wide as Ty.
bool match(const LegalityQuery &Query) const
Test whether the LegalityQuery matches.
LegalizeAction getAction() const
LegalizeRuleSet & minScalarOrElt(unsigned TypeIdx, const LLT &Ty)
Ensure the scalar or element is at least as wide as Ty.
LegalizeRuleSet & widenScalarToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar to the next power of two that is at least MinSize.
LegalizeMutation changeTo(unsigned TypeIdx, LLT Ty)
Select this specific type for the given type index.
void apply(Opt *O, const Mod &M, const Mods &... Ms)
bool operator==(const TypePairAndMemDesc &Other) const
LegalityPredicate atomicOrderingAtLeastOrStrongerThan(unsigned MMOIdx, AtomicOrdering Ordering)
True iff the specified MMO index has at an atomic ordering of at Ordering or stronger.
This operation is completely unsupported on the target.
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
AtomicOrdering
Atomic ordering for LLVM's memory model.
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types)
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
LegalizeRuleSet & libcallIf(LegalityPredicate Predicate)
Like legalIf, but for the Libcall action.
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.
InstrAspect(unsigned Opcode, LLT Type)
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...
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
LegalityPredicate numElementsNotPow2(unsigned TypeIdx)
True iff the specified type index is a vector whose element count is not a power of 2...
LegalizeRuleSet & clampMaxNumElements(unsigned TypeIdx, const LLT &EltTy, unsigned MaxElements)
Limit the number of elements in EltTy vectors to at most MaxElements.
LegalizeRuleSet & clampMinNumElements(unsigned TypeIdx, const LLT &EltTy, unsigned MinElements)
Limit the number of elements in EltTy vectors to at least MinElements.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
bool operator==(const LegalizeActionStep &RHS) const
The operation itself must be expressed in terms of simpler actions on this target.
LegalizeRuleSet & legalIf(LegalityPredicate Predicate)
The instruction is legal if predicate is true.
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 & lowerIf(LegalityPredicate Predicate)
The instruction is lowered if predicate is true.
LegalizeMutation scalarize(unsigned TypeIdx)
Break up the vector type for the given type index into the element type.
LegalizeMutation changeElementTo(unsigned TypeIdx, LLT Ty)
Keep the same scalar or element type as the given type.
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...
Abstract class that contains various methods for clients to notify about changes. ...
unsigned const MachineRegisterInfo * MRI
static LLT scalarOrVector(uint16_t NumElements, LLT ScalarTy)
Sentinel value for when no action was found in the specified table.
LegalityPredicate narrowerThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's narrower than the given size.
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 & lowerFor(std::initializer_list< LLT > Types)
The instruction is lowered when type index 0 is any type in the given list.
LegalizeRuleSet & libcallFor(std::initializer_list< LLT > Types)
Helper class to build MachineInstr.
Interface to description of machine instruction set.
bool isLegal(const LegalityQuery &Query) const
LegalizeRuleSet & lowerIfMemSizeNotPow2()
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...
LegalityPredicate memSizeInBytesNotPow2(unsigned MMOIdx)
True iff the specified MMO index has a size that is not a power of 2.
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 & unsupportedIf(LegalityPredicate Predicate)
LegalizeRuleSet & maxScalar(unsigned TypeIdx, const LLT &Ty)
Ensure the scalar is at most as wide as Ty.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT &MinTy, const LLT &MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
LegalizeRuleSet & customIf(LegalityPredicate Predicate)
std::function< std::pair< unsigned, LLT >(const LegalityQuery &)> LegalizeMutation
Legalization is decided based on an instruction's opcode, which type slot we're considering, and what the existing type is.
LegalizeActionStep(LegalizeAction Action, unsigned TypeIdx, const LLT &NewType)
LegalizeRuleSet & minScalar(unsigned TypeIdx, const LLT &Ty)
Ensure the scalar is at least as wide as Ty.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
cl::opt< bool > DisableGISelLegalityCheck
LegalizeRuleSet & unsupportedIfMemSizeNotPow2()
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
LegalizeRuleSet & customFor(std::initializer_list< LLT > Types)
static SizeAndActionsVec narrowToSmallerAndWidenToSmallest(const SizeAndActionsVec &v)
LegalityPredicate scalarOrEltSizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar or vector whose element size is not a power of 2...
const MachineInstr * machineFunctionIsIllegal(const MachineFunction &MF)
Checks that MIR is fully legal, returns an illegal instruction if it's not, nullptr otherwise...
void setLegalizeVectorElementToDifferentSizeStrategy(const unsigned Opcode, const unsigned TypeIdx, SizeChangeStrategy S)
See also setLegalizeScalarToDifferentSizeStrategy.
LegalizeMutation changeTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same type as the given type index.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
LegalizeRuleSet & libcallFor(std::initializer_list< std::pair< LLT, LLT >> Types)
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LegalizeRuleSet & minScalarSameAs(unsigned TypeIdx, unsigned LargeTypeIdx)
Widen the scalar to match the size of another.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
The operation should be implemented as a call to some kind of runtime support library.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
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 & unsupported()
The instruction is unsupported.
The target wants to do something special with this combination of operand and type.
LegalityPredicate isScalar(unsigned TypeIdx)
True iff the specified type index is a scalar.
LegalizeRuleSet & lowerFor(std::initializer_list< LLT > Types, LegalizeMutation Mutation)
The instruction is lowered when type index 0 is any type in the given list.
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...
LegalizeRule(LegalityPredicate Predicate, LegalizeAction Action, LegalizeMutation Mutation=nullptr)
LegalizeRuleSet & minScalarEltSameAsIf(LegalityPredicate Predicate, unsigned TypeIdx, unsigned LargeTypeIdx)
Conditionally widen the scalar or elt to match the size of another.
LegalizeRuleSet & moreElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Add more elements to reach the type selected by the mutation if the predicate is true.
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...
A single rule in a legalizer info ruleset.
LegalizeRuleSet & fewerElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Remove elements to reach the type selected by the mutation if the predicate is true.
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.
LegalizeAction Action
The action to take or the final answer.
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...
static bool needsLegalizingToDifferentSize(const LegalizeAction Action)
Fall back onto the old rules.
LegalizeRuleSet & fallback()
Fallback on the previous implementation.
static SizeAndActionsVec widenToLargerTypesAndNarrowToLargest(const SizeAndActionsVec &v)
A SizeChangeStrategy for the common case where legalization for a particular operation consists of wi...
static SizeAndActionsVec moreToWiderTypesAndLessToWidest(const SizeAndActionsVec &v)
A SizeChangeStrategy for the common case where legalization for a particular vector operation consist...
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 & lower()
The instruction is lowered.
LLVM_NODISCARD bool empty() const
void aliasTo(unsigned Opcode)
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...
LegalityPredicate typeInSet(unsigned TypeIdx, std::initializer_list< LLT > TypesInit)
True iff the given type index is one of the specified types.
LegalizeRuleSet & alwaysLegal()
LegalizeMutation moreElementsToNextPow2(unsigned TypeIdx, unsigned Min=0)
Add more elements to the type for the given type index to the next power of.
LegalizeRuleSet & widenScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Widen the scalar to the one selected by the mutation if the predicate is true.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isCompatible(const TypePairAndMemDesc &Other) const
LegalizeRuleSet & maxScalarIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT &Ty)
Conditionally limit the maximum size of the scalar.
LegalizeRuleSet & moreElementsToNextPow2(unsigned TypeIdx)
Add more elements to the vector to reach the next power of two.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
bool operator==(const InstrAspect &RHS) const
LegalizeRuleSet & clampScalarOrElt(unsigned TypeIdx, const LLT &MinTy, const LLT &MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
This class implements an extremely fast bulk output stream that can only output to a stream...
std::function< bool(const LegalityQuery &)> LegalityPredicate
void setIsAliasedByAnother()
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...
std::pair< unsigned, LLT > determineMutation(const LegalityQuery &Query) const
Determine the change to make.
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...
LegalityPredicate sizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar whose size is not a power of.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::pair< uint16_t, LegalizeAction > SizeAndAction
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...
LegalityPredicate isPointer(unsigned TypeIdx, unsigned AddrSpace)
True iff the specified type index is a pointer with the specified address space.
LegalityPredicate sameSize(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the specified type indices are both the same bit size.
LegalizeRuleSet & narrowScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Narrow the scalar to the one selected by the mutation if the predicate is true.
LegalityPredicate widerThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's wider than the given size.