LLVM  14.0.0git
LegalizerInfo.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/GlobalISel/LegalizerInfo.h ------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 /// Interface for Targets to specify which operations they can successfully
10 /// select and how the others should be expanded most efficiently.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
15 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/SmallVector.h"
27 #include <cassert>
28 #include <cstdint>
29 #include <tuple>
30 #include <unordered_map>
31 #include <utility>
32 
33 namespace llvm {
34 
35 extern cl::opt<bool> DisableGISelLegalityCheck;
36 
37 class LegalizerHelper;
38 class MachineInstr;
39 class MachineRegisterInfo;
40 class MCInstrInfo;
41 class GISelChangeObserver;
42 
43 namespace LegalizeActions {
44 enum LegalizeAction : std::uint8_t {
45  /// The operation is expected to be selectable directly by the target, and
46  /// no transformation is necessary.
48 
49  /// The operation should be synthesized from multiple instructions acting on
50  /// a narrower scalar base-type. For example a 64-bit add might be
51  /// implemented in terms of 32-bit add-with-carry.
53 
54  /// The operation should be implemented in terms of a wider scalar
55  /// base-type. For example a <2 x s8> add could be implemented as a <2
56  /// x s32> add (ignoring the high bits).
58 
59  /// The (vector) operation should be implemented by splitting it into
60  /// sub-vectors where the operation is legal. For example a <8 x s64> add
61  /// might be implemented as 4 separate <2 x s64> adds.
63 
64  /// The (vector) operation should be implemented by widening the input
65  /// vector and ignoring the lanes added by doing so. For example <2 x i8> is
66  /// rarely legal, but you might perform an <8 x i8> and then only look at
67  /// the first two results.
69 
70  /// Perform the operation on a different, but equivalently sized type.
72 
73  /// The operation itself must be expressed in terms of simpler actions on
74  /// this target. E.g. a SREM replaced by an SDIV and subtraction.
76 
77  /// The operation should be implemented as a call to some kind of runtime
78  /// support library. For example this usually happens on machines that don't
79  /// support floating-point operations natively.
81 
82  /// The target wants to do something special with this combination of
83  /// operand and type. A callback will be issued when it is needed.
85 
86  /// This operation is completely unsupported on the target. A programming
87  /// error has occurred.
89 
90  /// Sentinel value for when no action was found in the specified table.
92 
93  /// Fall back onto the old rules.
94  /// TODO: Remove this once we've migrated
96 };
97 } // end namespace LegalizeActions
98 raw_ostream &operator<<(raw_ostream &OS, LegalizeActions::LegalizeAction Action);
99 
101 
102 /// The LegalityQuery object bundles together all the information that's needed
103 /// to decide whether a given operation is legal or not.
104 /// For efficiency, it doesn't make a copy of Types so care must be taken not
105 /// to free it before using the query.
107  unsigned Opcode;
109 
110  struct MemDesc {
114 
115  MemDesc() = default;
119  : MemoryTy(MMO.getMemoryType()),
120  AlignInBits(MMO.getAlign().value() * 8),
121  Ordering(MMO.getSuccessOrdering()) {}
122  };
123 
124  /// Operations which require memory can use this to place requirements on the
125  /// memory type for each MMO.
127 
128  constexpr LegalityQuery(unsigned Opcode, const ArrayRef<LLT> Types,
131  constexpr LegalityQuery(unsigned Opcode, const ArrayRef<LLT> Types)
132  : LegalityQuery(Opcode, Types, {}) {}
133 
134  raw_ostream &print(raw_ostream &OS) const;
135 };
136 
137 /// The result of a query. It either indicates a final answer of Legal or
138 /// Unsupported or describes an action that must be taken to make an operation
139 /// more legal.
141  /// The action to take or the final answer.
143  /// If describing an action, the type index to change. Otherwise zero.
144  unsigned TypeIdx;
145  /// If describing an action, the new type for TypeIdx. Otherwise LLT{}.
147 
149  const LLT NewType)
151 
153  : TypeIdx(Step.TypeIdx), NewType(Step.NewType) {
154  switch (Step.Action) {
157  break;
160  break;
163  break;
166  break;
169  break;
172  break;
175  break;
178  break;
181  break;
184  break;
187  break;
188  }
189  }
190 
191  bool operator==(const LegalizeActionStep &RHS) const {
192  return std::tie(Action, TypeIdx, NewType) ==
193  std::tie(RHS.Action, RHS.TypeIdx, RHS.NewType);
194  }
195 };
196 
198 using LegalizeMutation =
199  std::function<std::pair<unsigned, LLT>(const LegalityQuery &)>;
200 
201 namespace LegalityPredicates {
207 
208  bool operator==(const TypePairAndMemDesc &Other) const {
209  return Type0 == Other.Type0 && Type1 == Other.Type1 &&
210  Align == Other.Align && MemTy == Other.MemTy;
211  }
212 
213  /// \returns true if this memory access is legal with for the access described
214  /// by \p Other (The alignment is sufficient for the size and result type).
215  bool isCompatible(const TypePairAndMemDesc &Other) const {
216  return Type0 == Other.Type0 && Type1 == Other.Type1 &&
217  Align >= Other.Align &&
218  // FIXME: This perhaps should be stricter, but the current legality
219  // rules are written only considering the size.
220  MemTy.getSizeInBits() == Other.MemTy.getSizeInBits();
221  }
222 };
223 
224 /// True iff P0 and P1 are true.
225 template<typename Predicate>
227  return [=](const LegalityQuery &Query) {
228  return P0(Query) && P1(Query);
229  };
230 }
231 /// True iff all given predicates are true.
232 template<typename Predicate, typename... Args>
234  return all(all(P0, P1), args...);
235 }
236 
237 /// True iff P0 or P1 are true.
238 template<typename Predicate>
240  return [=](const LegalityQuery &Query) {
241  return P0(Query) || P1(Query);
242  };
243 }
244 /// True iff any given predicates are true.
245 template<typename Predicate, typename... Args>
247  return any(any(P0, P1), args...);
248 }
249 
250 /// True iff the given type index is the specified type.
251 LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit);
252 /// True iff the given type index is one of the specified types.
253 LegalityPredicate typeInSet(unsigned TypeIdx,
254  std::initializer_list<LLT> TypesInit);
255 
256 /// True iff the given type index is not the specified type.
257 inline LegalityPredicate typeIsNot(unsigned TypeIdx, LLT Type) {
258  return [=](const LegalityQuery &Query) {
259  return Query.Types[TypeIdx] != Type;
260  };
261 }
262 
263 /// True iff the given types for the given pair of type indexes is one of the
264 /// specified type pairs.
266 typePairInSet(unsigned TypeIdx0, unsigned TypeIdx1,
267  std::initializer_list<std::pair<LLT, LLT>> TypesInit);
268 /// True iff the given types for the given pair of type indexes is one of the
269 /// specified type pairs.
271  unsigned TypeIdx0, unsigned TypeIdx1, unsigned MMOIdx,
272  std::initializer_list<TypePairAndMemDesc> TypesAndMemDescInit);
273 /// True iff the specified type index is a scalar.
274 LegalityPredicate isScalar(unsigned TypeIdx);
275 /// True iff the specified type index is a vector.
276 LegalityPredicate isVector(unsigned TypeIdx);
277 /// True iff the specified type index is a pointer (with any address space).
278 LegalityPredicate isPointer(unsigned TypeIdx);
279 /// True iff the specified type index is a pointer with the specified address
280 /// space.
281 LegalityPredicate isPointer(unsigned TypeIdx, unsigned AddrSpace);
282 
283 /// True if the type index is a vector with element type \p EltTy
284 LegalityPredicate elementTypeIs(unsigned TypeIdx, LLT EltTy);
285 
286 /// True iff the specified type index is a scalar that's narrower than the given
287 /// size.
288 LegalityPredicate scalarNarrowerThan(unsigned TypeIdx, unsigned Size);
289 
290 /// True iff the specified type index is a scalar that's wider than the given
291 /// size.
292 LegalityPredicate scalarWiderThan(unsigned TypeIdx, unsigned Size);
293 
294 /// True iff the specified type index is a scalar or vector with an element type
295 /// that's narrower than the given size.
296 LegalityPredicate scalarOrEltNarrowerThan(unsigned TypeIdx, unsigned Size);
297 
298 /// True iff the specified type index is a scalar or a vector with an element
299 /// type that's wider than the given size.
300 LegalityPredicate scalarOrEltWiderThan(unsigned TypeIdx, unsigned Size);
301 
302 /// True iff the specified type index is a scalar whose size is not a multiple
303 /// of Size.
304 LegalityPredicate sizeNotMultipleOf(unsigned TypeIdx, unsigned Size);
305 
306 /// True iff the specified type index is a scalar whose size is not a power of
307 /// 2.
308 LegalityPredicate sizeNotPow2(unsigned TypeIdx);
309 
310 /// True iff the specified type index is a scalar or vector whose element size
311 /// is not a power of 2.
312 LegalityPredicate scalarOrEltSizeNotPow2(unsigned TypeIdx);
313 
314 /// True if the total bitwidth of the specified type index is \p Size bits.
315 LegalityPredicate sizeIs(unsigned TypeIdx, unsigned Size);
316 
317 /// True iff the specified type indices are both the same bit size.
318 LegalityPredicate sameSize(unsigned TypeIdx0, unsigned TypeIdx1);
319 
320 /// True iff the first type index has a larger total bit size than second type
321 /// index.
322 LegalityPredicate largerThan(unsigned TypeIdx0, unsigned TypeIdx1);
323 
324 /// True iff the first type index has a smaller total bit size than second type
325 /// index.
326 LegalityPredicate smallerThan(unsigned TypeIdx0, unsigned TypeIdx1);
327 
328 /// True iff the specified MMO index has a size that is not a power of 2
330 /// True iff the specified type index is a vector whose element count is not a
331 /// power of 2.
332 LegalityPredicate numElementsNotPow2(unsigned TypeIdx);
333 /// True iff the specified MMO index has at an atomic ordering of at Ordering or
334 /// stronger.
336  AtomicOrdering Ordering);
337 } // end namespace LegalityPredicates
338 
339 namespace LegalizeMutations {
340 /// Select this specific type for the given type index.
341 LegalizeMutation changeTo(unsigned TypeIdx, LLT Ty);
342 
343 /// Keep the same type as the given type index.
344 LegalizeMutation changeTo(unsigned TypeIdx, unsigned FromTypeIdx);
345 
346 /// Keep the same scalar or element type as the given type index.
347 LegalizeMutation changeElementTo(unsigned TypeIdx, unsigned FromTypeIdx);
348 
349 /// Keep the same scalar or element type as the given type.
350 LegalizeMutation changeElementTo(unsigned TypeIdx, LLT Ty);
351 
352 /// Change the scalar size or element size to have the same scalar size as type
353 /// index \p FromIndex. Unlike changeElementTo, this discards pointer types and
354 /// only changes the size.
355 LegalizeMutation changeElementSizeTo(unsigned TypeIdx, unsigned FromTypeIdx);
356 
357 /// Widen the scalar type or vector element type for the given type index to the
358 /// next power of 2.
359 LegalizeMutation widenScalarOrEltToNextPow2(unsigned TypeIdx, unsigned Min = 0);
360 
361 /// Widen the scalar type or vector element type for the given type index to
362 /// next multiple of \p Size.
364  unsigned Size);
365 
366 /// Add more elements to the type for the given type index to the next power of
367 /// 2.
368 LegalizeMutation moreElementsToNextPow2(unsigned TypeIdx, unsigned Min = 0);
369 /// Break up the vector type for the given type index into the element type.
370 LegalizeMutation scalarize(unsigned TypeIdx);
371 } // end namespace LegalizeMutations
372 
373 /// A single rule in a legalizer info ruleset.
374 /// The specified action is chosen when the predicate is true. Where appropriate
375 /// for the action (e.g. for WidenScalar) the new type is selected using the
376 /// given mutator.
378  LegalityPredicate Predicate;
379  LegalizeAction Action;
380  LegalizeMutation Mutation;
381 
382 public:
384  LegalizeMutation Mutation = nullptr)
385  : Predicate(Predicate), Action(Action), Mutation(Mutation) {}
386 
387  /// Test whether the LegalityQuery matches.
388  bool match(const LegalityQuery &Query) const {
389  return Predicate(Query);
390  }
391 
392  LegalizeAction getAction() const { return Action; }
393 
394  /// Determine the change to make.
395  std::pair<unsigned, LLT> determineMutation(const LegalityQuery &Query) const {
396  if (Mutation)
397  return Mutation(Query);
398  return std::make_pair(0, LLT{});
399  }
400 };
401 
403  /// When non-zero, the opcode we are an alias of
404  unsigned AliasOf;
405  /// If true, there is another opcode that aliases this one
406  bool IsAliasedByAnother;
408 
409 #ifndef NDEBUG
410  /// If bit I is set, this rule set contains a rule that may handle (predicate
411  /// or perform an action upon (or both)) the type index I. The uncertainty
412  /// comes from free-form rules executing user-provided lambda functions. We
413  /// conservatively assume such rules do the right thing and cover all type
414  /// indices. The bitset is intentionally 1 bit wider than it absolutely needs
415  /// to be to distinguish such cases from the cases where all type indices are
416  /// individually handled.
421 #endif
422 
423  unsigned typeIdx(unsigned TypeIdx) {
424  assert(TypeIdx <=
426  "Type Index is out of bounds");
427 #ifndef NDEBUG
428  TypeIdxsCovered.set(TypeIdx);
429 #endif
430  return TypeIdx;
431  }
432 
433  unsigned immIdx(unsigned ImmIdx) {
436  "Imm Index is out of bounds");
437 #ifndef NDEBUG
438  ImmIdxsCovered.set(ImmIdx);
439 #endif
440  return ImmIdx;
441  }
442 
443  void markAllIdxsAsCovered() {
444 #ifndef NDEBUG
445  TypeIdxsCovered.set();
446  ImmIdxsCovered.set();
447 #endif
448  }
449 
450  void add(const LegalizeRule &Rule) {
451  assert(AliasOf == 0 &&
452  "RuleSet is aliased, change the representative opcode instead");
453  Rules.push_back(Rule);
454  }
455 
456  static bool always(const LegalityQuery &) { return true; }
457 
458  /// Use the given action when the predicate is true.
459  /// Action should not be an action that requires mutation.
460  LegalizeRuleSet &actionIf(LegalizeAction Action,
462  add({Predicate, Action});
463  return *this;
464  }
465  /// Use the given action when the predicate is true.
466  /// Action should be an action that requires mutation.
469  add({Predicate, Action, Mutation});
470  return *this;
471  }
472  /// Use the given action when type index 0 is any type in the given list.
473  /// Action should not be an action that requires mutation.
474  LegalizeRuleSet &actionFor(LegalizeAction Action,
475  std::initializer_list<LLT> Types) {
476  using namespace LegalityPredicates;
477  return actionIf(Action, typeInSet(typeIdx(0), Types));
478  }
479  /// Use the given action when type index 0 is any type in the given list.
480  /// Action should be an action that requires mutation.
481  LegalizeRuleSet &actionFor(LegalizeAction Action,
482  std::initializer_list<LLT> Types,
484  using namespace LegalityPredicates;
485  return actionIf(Action, typeInSet(typeIdx(0), Types), Mutation);
486  }
487  /// Use the given action when type indexes 0 and 1 is any type pair in the
488  /// given list.
489  /// Action should not be an action that requires mutation.
490  LegalizeRuleSet &actionFor(LegalizeAction Action,
491  std::initializer_list<std::pair<LLT, LLT>> Types) {
492  using namespace LegalityPredicates;
493  return actionIf(Action, typePairInSet(typeIdx(0), typeIdx(1), Types));
494  }
495  /// Use the given action when type indexes 0 and 1 is any type pair in the
496  /// given list.
497  /// Action should be an action that requires mutation.
498  LegalizeRuleSet &actionFor(LegalizeAction Action,
499  std::initializer_list<std::pair<LLT, LLT>> Types,
501  using namespace LegalityPredicates;
502  return actionIf(Action, typePairInSet(typeIdx(0), typeIdx(1), Types),
503  Mutation);
504  }
505  /// Use the given action when type index 0 is any type in the given list and
506  /// imm index 0 is anything. Action should not be an action that requires
507  /// mutation.
508  LegalizeRuleSet &actionForTypeWithAnyImm(LegalizeAction Action,
509  std::initializer_list<LLT> Types) {
510  using namespace LegalityPredicates;
511  immIdx(0); // Inform verifier imm idx 0 is handled.
512  return actionIf(Action, typeInSet(typeIdx(0), Types));
513  }
514 
515  LegalizeRuleSet &actionForTypeWithAnyImm(
516  LegalizeAction Action, std::initializer_list<std::pair<LLT, LLT>> Types) {
517  using namespace LegalityPredicates;
518  immIdx(0); // Inform verifier imm idx 0 is handled.
519  return actionIf(Action, typePairInSet(typeIdx(0), typeIdx(1), Types));
520  }
521 
522  /// Use the given action when type indexes 0 and 1 are both in the given list.
523  /// That is, the type pair is in the cartesian product of the list.
524  /// Action should not be an action that requires mutation.
525  LegalizeRuleSet &actionForCartesianProduct(LegalizeAction Action,
526  std::initializer_list<LLT> Types) {
527  using namespace LegalityPredicates;
528  return actionIf(Action, all(typeInSet(typeIdx(0), Types),
529  typeInSet(typeIdx(1), Types)));
530  }
531  /// Use the given action when type indexes 0 and 1 are both in their
532  /// respective lists.
533  /// That is, the type pair is in the cartesian product of the lists
534  /// Action should not be an action that requires mutation.
536  actionForCartesianProduct(LegalizeAction Action,
537  std::initializer_list<LLT> Types0,
538  std::initializer_list<LLT> Types1) {
539  using namespace LegalityPredicates;
540  return actionIf(Action, all(typeInSet(typeIdx(0), Types0),
541  typeInSet(typeIdx(1), Types1)));
542  }
543  /// Use the given action when type indexes 0, 1, and 2 are all in their
544  /// respective lists.
545  /// That is, the type triple is in the cartesian product of the lists
546  /// Action should not be an action that requires mutation.
547  LegalizeRuleSet &actionForCartesianProduct(
548  LegalizeAction Action, std::initializer_list<LLT> Types0,
549  std::initializer_list<LLT> Types1, std::initializer_list<LLT> Types2) {
550  using namespace LegalityPredicates;
551  return actionIf(Action, all(typeInSet(typeIdx(0), Types0),
552  all(typeInSet(typeIdx(1), Types1),
553  typeInSet(typeIdx(2), Types2))));
554  }
555 
556 public:
557  LegalizeRuleSet() : AliasOf(0), IsAliasedByAnother(false), Rules() {}
558 
559  bool isAliasedByAnother() { return IsAliasedByAnother; }
560  void setIsAliasedByAnother() { IsAliasedByAnother = true; }
561  void aliasTo(unsigned Opcode) {
562  assert((AliasOf == 0 || AliasOf == Opcode) &&
563  "Opcode is already aliased to another opcode");
564  assert(Rules.empty() && "Aliasing will discard rules");
565  AliasOf = Opcode;
566  }
567  unsigned getAlias() const { return AliasOf; }
568 
569  /// The instruction is legal if predicate is true.
571  // We have no choice but conservatively assume that the free-form
572  // user-provided Predicate properly handles all type indices:
573  markAllIdxsAsCovered();
574  return actionIf(LegalizeAction::Legal, Predicate);
575  }
576  /// The instruction is legal when type index 0 is any type in the given list.
577  LegalizeRuleSet &legalFor(std::initializer_list<LLT> Types) {
578  return actionFor(LegalizeAction::Legal, Types);
579  }
580  /// The instruction is legal when type indexes 0 and 1 is any type pair in the
581  /// given list.
582  LegalizeRuleSet &legalFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
583  return actionFor(LegalizeAction::Legal, Types);
584  }
585  /// The instruction is legal when type index 0 is any type in the given list
586  /// and imm index 0 is anything.
587  LegalizeRuleSet &legalForTypeWithAnyImm(std::initializer_list<LLT> Types) {
588  markAllIdxsAsCovered();
589  return actionForTypeWithAnyImm(LegalizeAction::Legal, Types);
590  }
591 
593  std::initializer_list<std::pair<LLT, LLT>> Types) {
594  markAllIdxsAsCovered();
595  return actionForTypeWithAnyImm(LegalizeAction::Legal, Types);
596  }
597 
598  /// The instruction is legal when type indexes 0 and 1 along with the memory
599  /// size and minimum alignment is any type and size tuple in the given list.
601  std::initializer_list<LegalityPredicates::TypePairAndMemDesc>
602  TypesAndMemDesc) {
603  return actionIf(LegalizeAction::Legal,
605  typeIdx(0), typeIdx(1), /*MMOIdx*/ 0, TypesAndMemDesc));
606  }
607  /// The instruction is legal when type indexes 0 and 1 are both in the given
608  /// list. That is, the type pair is in the cartesian product of the list.
609  LegalizeRuleSet &legalForCartesianProduct(std::initializer_list<LLT> Types) {
610  return actionForCartesianProduct(LegalizeAction::Legal, Types);
611  }
612  /// The instruction is legal when type indexes 0 and 1 are both their
613  /// respective lists.
614  LegalizeRuleSet &legalForCartesianProduct(std::initializer_list<LLT> Types0,
615  std::initializer_list<LLT> Types1) {
616  return actionForCartesianProduct(LegalizeAction::Legal, Types0, Types1);
617  }
618  /// The instruction is legal when type indexes 0, 1, and 2 are both their
619  /// respective lists.
620  LegalizeRuleSet &legalForCartesianProduct(std::initializer_list<LLT> Types0,
621  std::initializer_list<LLT> Types1,
622  std::initializer_list<LLT> Types2) {
623  return actionForCartesianProduct(LegalizeAction::Legal, Types0, Types1,
624  Types2);
625  }
626 
628  using namespace LegalizeMutations;
629  markAllIdxsAsCovered();
630  return actionIf(LegalizeAction::Legal, always);
631  }
632 
633  /// The specified type index is coerced if predicate is true.
636  // We have no choice but conservatively assume that lowering with a
637  // free-form user provided Predicate properly handles all type indices:
638  markAllIdxsAsCovered();
639  return actionIf(LegalizeAction::Bitcast, Predicate, Mutation);
640  }
641 
642  /// The instruction is lowered.
644  using namespace LegalizeMutations;
645  // We have no choice but conservatively assume that predicate-less lowering
646  // properly handles all type indices by design:
647  markAllIdxsAsCovered();
648  return actionIf(LegalizeAction::Lower, always);
649  }
650  /// The instruction is lowered if predicate is true. Keep type index 0 as the
651  /// same type.
653  using namespace LegalizeMutations;
654  // We have no choice but conservatively assume that lowering with a
655  // free-form user provided Predicate properly handles all type indices:
656  markAllIdxsAsCovered();
657  return actionIf(LegalizeAction::Lower, Predicate);
658  }
659  /// The instruction is lowered if predicate is true.
662  // We have no choice but conservatively assume that lowering with a
663  // free-form user provided Predicate properly handles all type indices:
664  markAllIdxsAsCovered();
665  return actionIf(LegalizeAction::Lower, Predicate, Mutation);
666  }
667  /// The instruction is lowered when type index 0 is any type in the given
668  /// list. Keep type index 0 as the same type.
669  LegalizeRuleSet &lowerFor(std::initializer_list<LLT> Types) {
670  return actionFor(LegalizeAction::Lower, Types);
671  }
672  /// The instruction is lowered when type index 0 is any type in the given
673  /// list.
674  LegalizeRuleSet &lowerFor(std::initializer_list<LLT> Types,
676  return actionFor(LegalizeAction::Lower, Types, Mutation);
677  }
678  /// The instruction is lowered when type indexes 0 and 1 is any type pair in
679  /// the given list. Keep type index 0 as the same type.
680  LegalizeRuleSet &lowerFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
681  return actionFor(LegalizeAction::Lower, Types);
682  }
683  /// The instruction is lowered when type indexes 0 and 1 is any type pair in
684  /// the given list.
685  LegalizeRuleSet &lowerFor(std::initializer_list<std::pair<LLT, LLT>> Types,
687  return actionFor(LegalizeAction::Lower, Types, Mutation);
688  }
689  /// The instruction is lowered when type indexes 0 and 1 are both in their
690  /// respective lists.
691  LegalizeRuleSet &lowerForCartesianProduct(std::initializer_list<LLT> Types0,
692  std::initializer_list<LLT> Types1) {
693  using namespace LegalityPredicates;
694  return actionForCartesianProduct(LegalizeAction::Lower, Types0, Types1);
695  }
696  /// The instruction is lowered when when type indexes 0, 1, and 2 are all in
697  /// their respective lists.
698  LegalizeRuleSet &lowerForCartesianProduct(std::initializer_list<LLT> Types0,
699  std::initializer_list<LLT> Types1,
700  std::initializer_list<LLT> Types2) {
701  using namespace LegalityPredicates;
702  return actionForCartesianProduct(LegalizeAction::Lower, Types0, Types1,
703  Types2);
704  }
705 
706  /// The instruction is emitted as a library call.
708  using namespace LegalizeMutations;
709  // We have no choice but conservatively assume that predicate-less lowering
710  // properly handles all type indices by design:
711  markAllIdxsAsCovered();
712  return actionIf(LegalizeAction::Libcall, always);
713  }
714 
715  /// Like legalIf, but for the Libcall action.
717  // We have no choice but conservatively assume that a libcall with a
718  // free-form user provided Predicate properly handles all type indices:
719  markAllIdxsAsCovered();
720  return actionIf(LegalizeAction::Libcall, Predicate);
721  }
722  LegalizeRuleSet &libcallFor(std::initializer_list<LLT> Types) {
723  return actionFor(LegalizeAction::Libcall, Types);
724  }
726  libcallFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
727  return actionFor(LegalizeAction::Libcall, Types);
728  }
730  libcallForCartesianProduct(std::initializer_list<LLT> Types) {
731  return actionForCartesianProduct(LegalizeAction::Libcall, Types);
732  }
734  libcallForCartesianProduct(std::initializer_list<LLT> Types0,
735  std::initializer_list<LLT> Types1) {
736  return actionForCartesianProduct(LegalizeAction::Libcall, Types0, Types1);
737  }
738 
739  /// Widen the scalar to the one selected by the mutation if the predicate is
740  /// true.
743  // We have no choice but conservatively assume that an action with a
744  // free-form user provided Predicate properly handles all type indices:
745  markAllIdxsAsCovered();
747  }
748  /// Narrow the scalar to the one selected by the mutation if the predicate is
749  /// true.
752  // We have no choice but conservatively assume that an action with a
753  // free-form user provided Predicate properly handles all type indices:
754  markAllIdxsAsCovered();
756  }
757  /// Narrow the scalar, specified in mutation, when type indexes 0 and 1 is any
758  /// type pair in the given list.
760  narrowScalarFor(std::initializer_list<std::pair<LLT, LLT>> Types,
762  return actionFor(LegalizeAction::NarrowScalar, Types, Mutation);
763  }
764 
765  /// Add more elements to reach the type selected by the mutation if the
766  /// predicate is true.
769  // We have no choice but conservatively assume that an action with a
770  // free-form user provided Predicate properly handles all type indices:
771  markAllIdxsAsCovered();
773  }
774  /// Remove elements to reach the type selected by the mutation if the
775  /// predicate is true.
778  // We have no choice but conservatively assume that an action with a
779  // free-form user provided Predicate properly handles all type indices:
780  markAllIdxsAsCovered();
782  }
783 
784  /// The instruction is unsupported.
786  markAllIdxsAsCovered();
787  return actionIf(LegalizeAction::Unsupported, always);
788  }
790  return actionIf(LegalizeAction::Unsupported, Predicate);
791  }
792 
793  LegalizeRuleSet &unsupportedFor(std::initializer_list<LLT> Types) {
794  return actionFor(LegalizeAction::Unsupported, Types);
795  }
796 
798  return actionIf(LegalizeAction::Unsupported,
800  }
802  return actionIf(LegalizeAction::Lower,
804  }
805 
807  // We have no choice but conservatively assume that a custom action with a
808  // free-form user provided Predicate properly handles all type indices:
809  markAllIdxsAsCovered();
810  return actionIf(LegalizeAction::Custom, Predicate);
811  }
812  LegalizeRuleSet &customFor(std::initializer_list<LLT> Types) {
813  return actionFor(LegalizeAction::Custom, Types);
814  }
815 
816  /// The instruction is custom when type indexes 0 and 1 is any type pair in the
817  /// given list.
818  LegalizeRuleSet &customFor(std::initializer_list<std::pair<LLT, LLT>> Types) {
819  return actionFor(LegalizeAction::Custom, Types);
820  }
821 
822  LegalizeRuleSet &customForCartesianProduct(std::initializer_list<LLT> Types) {
823  return actionForCartesianProduct(LegalizeAction::Custom, Types);
824  }
826  customForCartesianProduct(std::initializer_list<LLT> Types0,
827  std::initializer_list<LLT> Types1) {
828  return actionForCartesianProduct(LegalizeAction::Custom, Types0, Types1);
829  }
830 
831  /// Unconditionally custom lower.
833  return customIf(always);
834  }
835 
836  /// Widen the scalar to the next power of two that is at least MinSize.
837  /// No effect if the type is not a scalar or is a power of two.
839  unsigned MinSize = 0) {
840  using namespace LegalityPredicates;
841  return actionIf(
842  LegalizeAction::WidenScalar, sizeNotPow2(typeIdx(TypeIdx)),
844  }
845 
846  /// Widen the scalar to the next multiple of Size. No effect if the
847  /// type is not a scalar or is a multiple of Size.
849  unsigned Size) {
850  using namespace LegalityPredicates;
851  return actionIf(
854  }
855 
856  /// Widen the scalar or vector element type to the next power of two that is
857  /// at least MinSize. No effect if the scalar size is a power of two.
859  unsigned MinSize = 0) {
860  using namespace LegalityPredicates;
861  return actionIf(
864  }
865 
867  using namespace LegalityPredicates;
868  return actionIf(LegalizeAction::NarrowScalar, isScalar(typeIdx(TypeIdx)),
869  Mutation);
870  }
871 
872  LegalizeRuleSet &scalarize(unsigned TypeIdx) {
873  using namespace LegalityPredicates;
874  return actionIf(LegalizeAction::FewerElements, isVector(typeIdx(TypeIdx)),
876  }
877 
879  using namespace LegalityPredicates;
880  return actionIf(LegalizeAction::FewerElements,
881  all(Predicate, isVector(typeIdx(TypeIdx))),
883  }
884 
885  /// Ensure the scalar or element is at least as wide as Ty.
886  LegalizeRuleSet &minScalarOrElt(unsigned TypeIdx, const LLT Ty) {
887  using namespace LegalityPredicates;
888  using namespace LegalizeMutations;
889  return actionIf(LegalizeAction::WidenScalar,
891  changeElementTo(typeIdx(TypeIdx), Ty));
892  }
893 
894  /// Ensure the scalar or element is at least as wide as Ty.
896  unsigned TypeIdx, const LLT Ty) {
897  using namespace LegalityPredicates;
898  using namespace LegalizeMutations;
899  return actionIf(LegalizeAction::WidenScalar,
901  TypeIdx, Ty.getScalarSizeInBits())),
902  changeElementTo(typeIdx(TypeIdx), Ty));
903  }
904 
905  /// Ensure the scalar is at least as wide as Ty.
906  LegalizeRuleSet &minScalar(unsigned TypeIdx, const LLT Ty) {
907  using namespace LegalityPredicates;
908  using namespace LegalizeMutations;
909  return actionIf(LegalizeAction::WidenScalar,
910  scalarNarrowerThan(TypeIdx, Ty.getSizeInBits()),
911  changeTo(typeIdx(TypeIdx), Ty));
912  }
913 
914  /// Ensure the scalar is at most as wide as Ty.
915  LegalizeRuleSet &maxScalarOrElt(unsigned TypeIdx, const LLT Ty) {
916  using namespace LegalityPredicates;
917  using namespace LegalizeMutations;
918  return actionIf(LegalizeAction::NarrowScalar,
920  changeElementTo(typeIdx(TypeIdx), Ty));
921  }
922 
923  /// Ensure the scalar is at most as wide as Ty.
924  LegalizeRuleSet &maxScalar(unsigned TypeIdx, const LLT Ty) {
925  using namespace LegalityPredicates;
926  using namespace LegalizeMutations;
927  return actionIf(LegalizeAction::NarrowScalar,
928  scalarWiderThan(TypeIdx, Ty.getSizeInBits()),
929  changeTo(typeIdx(TypeIdx), Ty));
930  }
931 
932  /// Conditionally limit the maximum size of the scalar.
933  /// For example, when the maximum size of one type depends on the size of
934  /// another such as extracting N bits from an M bit container.
936  const LLT Ty) {
937  using namespace LegalityPredicates;
938  using namespace LegalizeMutations;
939  return actionIf(
941  [=](const LegalityQuery &Query) {
942  const LLT QueryTy = Query.Types[TypeIdx];
943  return QueryTy.isScalar() &&
944  QueryTy.getSizeInBits() > Ty.getSizeInBits() &&
945  Predicate(Query);
946  },
947  changeElementTo(typeIdx(TypeIdx), Ty));
948  }
949 
950  /// Limit the range of scalar sizes to MinTy and MaxTy.
951  LegalizeRuleSet &clampScalar(unsigned TypeIdx, const LLT MinTy,
952  const LLT MaxTy) {
953  assert(MinTy.isScalar() && MaxTy.isScalar() && "Expected scalar types");
954  return minScalar(TypeIdx, MinTy).maxScalar(TypeIdx, MaxTy);
955  }
956 
957  /// Limit the range of scalar sizes to MinTy and MaxTy.
958  LegalizeRuleSet &clampScalarOrElt(unsigned TypeIdx, const LLT MinTy,
959  const LLT MaxTy) {
960  return minScalarOrElt(TypeIdx, MinTy).maxScalarOrElt(TypeIdx, MaxTy);
961  }
962 
963  /// Widen the scalar to match the size of another.
964  LegalizeRuleSet &minScalarSameAs(unsigned TypeIdx, unsigned LargeTypeIdx) {
965  typeIdx(TypeIdx);
966  return widenScalarIf(
967  [=](const LegalityQuery &Query) {
968  return Query.Types[LargeTypeIdx].getScalarSizeInBits() >
969  Query.Types[TypeIdx].getSizeInBits();
970  },
971  LegalizeMutations::changeElementSizeTo(TypeIdx, LargeTypeIdx));
972  }
973 
974  /// Narrow the scalar to match the size of another.
975  LegalizeRuleSet &maxScalarSameAs(unsigned TypeIdx, unsigned NarrowTypeIdx) {
976  typeIdx(TypeIdx);
977  return narrowScalarIf(
978  [=](const LegalityQuery &Query) {
979  return Query.Types[NarrowTypeIdx].getScalarSizeInBits() <
980  Query.Types[TypeIdx].getSizeInBits();
981  },
982  LegalizeMutations::changeElementSizeTo(TypeIdx, NarrowTypeIdx));
983  }
984 
985  /// Change the type \p TypeIdx to have the same scalar size as type \p
986  /// SameSizeIdx.
987  LegalizeRuleSet &scalarSameSizeAs(unsigned TypeIdx, unsigned SameSizeIdx) {
988  return minScalarSameAs(TypeIdx, SameSizeIdx)
989  .maxScalarSameAs(TypeIdx, SameSizeIdx);
990  }
991 
992  /// Conditionally widen the scalar or elt to match the size of another.
994  unsigned TypeIdx, unsigned LargeTypeIdx) {
995  typeIdx(TypeIdx);
996  return widenScalarIf(
997  [=](const LegalityQuery &Query) {
998  return Query.Types[LargeTypeIdx].getScalarSizeInBits() >
999  Query.Types[TypeIdx].getScalarSizeInBits() &&
1000  Predicate(Query);
1001  },
1002  [=](const LegalityQuery &Query) {
1003  LLT T = Query.Types[LargeTypeIdx];
1004  return std::make_pair(TypeIdx, T);
1005  });
1006  }
1007 
1008  /// Conditionally narrow the scalar or elt to match the size of another.
1010  unsigned TypeIdx,
1011  unsigned SmallTypeIdx) {
1012  typeIdx(TypeIdx);
1013  return narrowScalarIf(
1014  [=](const LegalityQuery &Query) {
1015  return Query.Types[SmallTypeIdx].getScalarSizeInBits() <
1016  Query.Types[TypeIdx].getScalarSizeInBits() &&
1017  Predicate(Query);
1018  },
1019  [=](const LegalityQuery &Query) {
1020  LLT T = Query.Types[SmallTypeIdx];
1021  return std::make_pair(TypeIdx, T);
1022  });
1023  }
1024 
1025  /// Add more elements to the vector to reach the next power of two.
1026  /// No effect if the type is not a vector or the element count is a power of
1027  /// two.
1029  using namespace LegalityPredicates;
1030  return actionIf(LegalizeAction::MoreElements,
1031  numElementsNotPow2(typeIdx(TypeIdx)),
1033  }
1034 
1035  /// Limit the number of elements in EltTy vectors to at least MinElements.
1036  LegalizeRuleSet &clampMinNumElements(unsigned TypeIdx, const LLT EltTy,
1037  unsigned MinElements) {
1038  // Mark the type index as covered:
1039  typeIdx(TypeIdx);
1040  return actionIf(
1042  [=](const LegalityQuery &Query) {
1043  LLT VecTy = Query.Types[TypeIdx];
1044  return VecTy.isVector() && VecTy.getElementType() == EltTy &&
1045  VecTy.getNumElements() < MinElements;
1046  },
1047  [=](const LegalityQuery &Query) {
1048  LLT VecTy = Query.Types[TypeIdx];
1049  return std::make_pair(
1050  TypeIdx, LLT::fixed_vector(MinElements, VecTy.getElementType()));
1051  });
1052  }
1053  /// Limit the number of elements in EltTy vectors to at most MaxElements.
1054  LegalizeRuleSet &clampMaxNumElements(unsigned TypeIdx, const LLT EltTy,
1055  unsigned MaxElements) {
1056  // Mark the type index as covered:
1057  typeIdx(TypeIdx);
1058  return actionIf(
1060  [=](const LegalityQuery &Query) {
1061  LLT VecTy = Query.Types[TypeIdx];
1062  return VecTy.isVector() && VecTy.getElementType() == EltTy &&
1063  VecTy.getNumElements() > MaxElements;
1064  },
1065  [=](const LegalityQuery &Query) {
1066  LLT VecTy = Query.Types[TypeIdx];
1067  LLT NewTy = LLT::scalarOrVector(ElementCount::getFixed(MaxElements),
1068  VecTy.getElementType());
1069  return std::make_pair(TypeIdx, NewTy);
1070  });
1071  }
1072  /// Limit the number of elements for the given vectors to at least MinTy's
1073  /// number of elements and at most MaxTy's number of elements.
1074  ///
1075  /// No effect if the type is not a vector or does not have the same element
1076  /// type as the constraints.
1077  /// The element type of MinTy and MaxTy must match.
1078  LegalizeRuleSet &clampNumElements(unsigned TypeIdx, const LLT MinTy,
1079  const LLT MaxTy) {
1080  assert(MinTy.getElementType() == MaxTy.getElementType() &&
1081  "Expected element types to agree");
1082 
1083  const LLT EltTy = MinTy.getElementType();
1084  return clampMinNumElements(TypeIdx, EltTy, MinTy.getNumElements())
1085  .clampMaxNumElements(TypeIdx, EltTy, MaxTy.getNumElements());
1086  }
1087 
1088  /// Fallback on the previous implementation. This should only be used while
1089  /// porting a rule.
1092  return *this;
1093  }
1094 
1095  /// Check if there is no type index which is obviously not handled by the
1096  /// LegalizeRuleSet in any way at all.
1097  /// \pre Type indices of the opcode form a dense [0, \p NumTypeIdxs) set.
1098  bool verifyTypeIdxsCoverage(unsigned NumTypeIdxs) const;
1099  /// Check if there is no imm index which is obviously not handled by the
1100  /// LegalizeRuleSet in any way at all.
1101  /// \pre Type indices of the opcode form a dense [0, \p NumTypeIdxs) set.
1102  bool verifyImmIdxsCoverage(unsigned NumImmIdxs) const;
1103 
1104  /// Apply the ruleset to the given LegalityQuery.
1105  LegalizeActionStep apply(const LegalityQuery &Query) const;
1106 };
1107 
1109 public:
1110  virtual ~LegalizerInfo() = default;
1111 
1113  return LegacyInfo;
1114  }
1116 
1117  unsigned getOpcodeIdxForOpcode(unsigned Opcode) const;
1118  unsigned getActionDefinitionsIdx(unsigned Opcode) const;
1119 
1120  /// Perform simple self-diagnostic and assert if there is anything obviously
1121  /// wrong with the actions set up.
1122  void verify(const MCInstrInfo &MII) const;
1123 
1124  /// Get the action definitions for the given opcode. Use this to run a
1125  /// LegalityQuery through the definitions.
1126  const LegalizeRuleSet &getActionDefinitions(unsigned Opcode) const;
1127 
1128  /// Get the action definition builder for the given opcode. Use this to define
1129  /// the action definitions.
1130  ///
1131  /// It is an error to request an opcode that has already been requested by the
1132  /// multiple-opcode variant.
1133  LegalizeRuleSet &getActionDefinitionsBuilder(unsigned Opcode);
1134 
1135  /// Get the action definition builder for the given set of opcodes. Use this
1136  /// to define the action definitions for multiple opcodes at once. The first
1137  /// opcode given will be considered the representative opcode and will hold
1138  /// the definitions whereas the other opcodes will be configured to refer to
1139  /// the representative opcode. This lowers memory requirements and very
1140  /// slightly improves performance.
1141  ///
1142  /// It would be very easy to introduce unexpected side-effects as a result of
1143  /// this aliasing if it were permitted to request different but intersecting
1144  /// sets of opcodes but that is difficult to keep track of. It is therefore an
1145  /// error to request the same opcode twice using this API, to request an
1146  /// opcode that already has definitions, or to use the single-opcode API on an
1147  /// opcode that has already been requested by this API.
1148  LegalizeRuleSet &
1149  getActionDefinitionsBuilder(std::initializer_list<unsigned> Opcodes);
1150  void aliasActionDefinitions(unsigned OpcodeTo, unsigned OpcodeFrom);
1151 
1152  /// Determine what action should be taken to legalize the described
1153  /// instruction. Requires computeTables to have been called.
1154  ///
1155  /// \returns a description of the next legalization step to perform.
1156  LegalizeActionStep getAction(const LegalityQuery &Query) const;
1157 
1158  /// Determine what action should be taken to legalize the given generic
1159  /// instruction.
1160  ///
1161  /// \returns a description of the next legalization step to perform.
1162  LegalizeActionStep getAction(const MachineInstr &MI,
1163  const MachineRegisterInfo &MRI) const;
1164 
1165  bool isLegal(const LegalityQuery &Query) const {
1166  return getAction(Query).Action == LegalizeAction::Legal;
1167  }
1168 
1169  bool isLegalOrCustom(const LegalityQuery &Query) const {
1170  auto Action = getAction(Query).Action;
1171  return Action == LegalizeAction::Legal || Action == LegalizeAction::Custom;
1172  }
1173 
1174  bool isLegal(const MachineInstr &MI, const MachineRegisterInfo &MRI) const;
1175  bool isLegalOrCustom(const MachineInstr &MI,
1176  const MachineRegisterInfo &MRI) const;
1177 
1178  /// Called for instructions with the Custom LegalizationAction.
1179  virtual bool legalizeCustom(LegalizerHelper &Helper,
1180  MachineInstr &MI) const {
1181  llvm_unreachable("must implement this if custom action is used");
1182  }
1183 
1184  /// \returns true if MI is either legal or has been legalized and false if not
1185  /// legal.
1186  /// Return true if MI is either legal or has been legalized and false
1187  /// if not legal.
1188  virtual bool legalizeIntrinsic(LegalizerHelper &Helper,
1189  MachineInstr &MI) const {
1190  return true;
1191  }
1192 
1193  /// Return the opcode (SEXT/ZEXT/ANYEXT) that should be performed while
1194  /// widening a constant of type SmallTy which targets can override.
1195  /// For eg, the DAG does (SmallTy.isByteSized() ? G_SEXT : G_ZEXT) which
1196  /// will be the default.
1197  virtual unsigned getExtOpcodeForWideningConstant(LLT SmallTy) const;
1198 
1199 private:
1200  static const int FirstOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_START;
1201  static const int LastOp = TargetOpcode::PRE_ISEL_GENERIC_OPCODE_END;
1202 
1203  LegalizeRuleSet RulesForOpcode[LastOp - FirstOp + 1];
1204  LegacyLegalizerInfo LegacyInfo;
1205 };
1206 
1207 #ifndef NDEBUG
1208 /// Checks that MIR is fully legal, returns an illegal instruction if it's not,
1209 /// nullptr otherwise
1210 const MachineInstr *machineFunctionIsIllegal(const MachineFunction &MF);
1211 #endif
1212 
1213 } // end namespace llvm.
1214 
1215 #endif // LLVM_CODEGEN_GLOBALISEL_LEGALIZERINFO_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::LegalizeRuleSet::maxScalarOrElt
LegalizeRuleSet & maxScalarOrElt(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at most as wide as Ty.
Definition: LegalizerInfo.h:915
llvm::LegalizeRuleSet::unsupported
LegalizeRuleSet & unsupported()
The instruction is unsupported.
Definition: LegalizerInfo.h:785
llvm::SmallBitVector::set
SmallBitVector & set()
Definition: SmallBitVector.h:365
llvm::LegalizeRuleSet::widenScalarToNextPow2
LegalizeRuleSet & widenScalarToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar to the next power of two that is at least MinSize.
Definition: LegalizerInfo.h:838
llvm::LegalizeRuleSet::bitcastIf
LegalizeRuleSet & bitcastIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
The specified type index is coerced if predicate is true.
Definition: LegalizerInfo.h:634
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
llvm::LegalizeRule::match
bool match(const LegalityQuery &Query) const
Test whether the LegalityQuery matches.
Definition: LegalizerInfo.h:388
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::LegalityPredicates::scalarOrEltWiderThan
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 ...
Definition: LegalityPredicates.cpp:141
llvm::MCOI::OPERAND_FIRST_GENERIC_IMM
@ OPERAND_FIRST_GENERIC_IMM
Definition: MCInstrDesc.h:72
llvm::LLT::getScalarSizeInBits
unsigned getScalarSizeInBits() const
Definition: LowLevelTypeImpl.h:213
llvm::LegalityQuery::MemDesc::MemDesc
MemDesc(LLT MemoryTy, uint64_t AlignInBits, AtomicOrdering Ordering)
Definition: LegalizerInfo.h:116
llvm::LegalizeRuleSet::unsupportedIfMemSizeNotPow2
LegalizeRuleSet & unsupportedIfMemSizeNotPow2()
Definition: LegalizerInfo.h:797
llvm::LegacyLegalizeActions::Custom
@ Custom
The target wants to do something special with this combination of operand and type.
Definition: LegacyLegalizerInfo.h:67
llvm::LegalizeActions::MoreElements
@ MoreElements
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
Definition: LegalizerInfo.h:68
llvm::LegalizeRuleSet::maxScalarSameAs
LegalizeRuleSet & maxScalarSameAs(unsigned TypeIdx, unsigned NarrowTypeIdx)
Narrow the scalar to match the size of another.
Definition: LegalizerInfo.h:975
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
T
llvm::LegalizeActionStep::Action
LegalizeAction Action
The action to take or the final answer.
Definition: LegalizerInfo.h:142
llvm::LegalizeRuleSet::customFor
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.
Definition: LegalizerInfo.h:818
llvm::LegalizeRuleSet::minScalarEltSameAsIf
LegalizeRuleSet & minScalarEltSameAsIf(LegalityPredicate Predicate, unsigned TypeIdx, unsigned LargeTypeIdx)
Conditionally widen the scalar or elt to match the size of another.
Definition: LegalizerInfo.h:993
llvm::LegalizeRuleSet::maxScalarIf
LegalizeRuleSet & maxScalarIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT Ty)
Conditionally limit the maximum size of the scalar.
Definition: LegalizerInfo.h:935
llvm::LegacyLegalizeActions::MoreElements
@ MoreElements
The (vector) operation should be implemented by widening the input vector and ignoring the lanes adde...
Definition: LegacyLegalizerInfo.h:51
llvm::LegacyLegalizeActions::FewerElements
@ FewerElements
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
Definition: LegacyLegalizerInfo.h:45
llvm::LegalizeActionStep
The result of a query.
Definition: LegalizerInfo.h:140
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::LegalizeRuleSet::customFor
LegalizeRuleSet & customFor(std::initializer_list< LLT > Types)
Definition: LegalizerInfo.h:812
llvm::LegalizeRuleSet::libcall
LegalizeRuleSet & libcall()
The instruction is emitted as a library call.
Definition: LegalizerInfo.h:707
llvm::LegalizeRule::determineMutation
std::pair< unsigned, LLT > determineMutation(const LegalityQuery &Query) const
Determine the change to make.
Definition: LegalizerInfo.h:395
llvm::LegacyLegalizeActions::Bitcast
@ Bitcast
Perform the operation on a different, but equivalently sized type.
Definition: LegacyLegalizerInfo.h:54
llvm::LegalizeRuleSet::clampNumElements
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...
Definition: LegalizerInfo.h:1078
llvm::LegalizeActions::NarrowScalar
@ NarrowScalar
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type.
Definition: LegalizerInfo.h:52
llvm::LegalizeRuleSet::lowerFor
LegalizeRuleSet & lowerFor(std::initializer_list< LLT > Types, LegalizeMutation Mutation)
The instruction is lowered when type index 0 is any type in the given list.
Definition: LegalizerInfo.h:674
llvm::LegacyLegalizeActions::WidenScalar
@ WidenScalar
The operation should be implemented in terms of a wider scalar base-type.
Definition: LegacyLegalizerInfo.h:40
llvm::LegalityPredicates::typeIsNot
LegalityPredicate typeIsNot(unsigned TypeIdx, LLT Type)
True iff the given type index is not the specified type.
Definition: LegalizerInfo.h:257
llvm::LegalizeRuleSet::minScalarOrEltIf
LegalizeRuleSet & minScalarOrEltIf(LegalityPredicate Predicate, unsigned TypeIdx, const LLT Ty)
Ensure the scalar or element is at least as wide as Ty.
Definition: LegalizerInfo.h:895
llvm::DisableGISelLegalityCheck
cl::opt< bool > DisableGISelLegalityCheck
llvm::LegalityQuery::MemDesc::MemDesc
MemDesc(const MachineMemOperand &MMO)
Definition: LegalizerInfo.h:118
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DenseMap.h
llvm::LegalityPredicates::largerThan
LegalityPredicate largerThan(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the first type index has a larger total bit size than second type index.
Definition: LegalityPredicates.cpp:125
llvm::LegalityQuery::MemDesc
Definition: LegalizerInfo.h:110
LegacyLegalizerInfo.h
llvm::LegalityPredicates::scalarNarrowerThan
LegalityPredicate scalarNarrowerThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's narrower than the given size.
Definition: LegalityPredicates.cpp:101
llvm::MachineMemOperand
A description of a memory reference used in the backend.
Definition: MachineMemOperand.h:128
llvm::LegalityPredicates::elementTypeIs
LegalityPredicate elementTypeIs(unsigned TypeIdx, LLT EltTy)
True if the type index is a vector with element type EltTy.
Definition: LegalityPredicates.cpp:93
llvm::LegalizeRuleSet::maxScalar
LegalizeRuleSet & maxScalar(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at most as wide as Ty.
Definition: LegalizerInfo.h:924
llvm::LegalizeActions::WidenScalar
@ WidenScalar
The operation should be implemented in terms of a wider scalar base-type.
Definition: LegalizerInfo.h:57
llvm::LegalizeMutations::widenScalarOrEltToNextMultipleOf
LegalizeMutation widenScalarOrEltToNextMultipleOf(unsigned TypeIdx, unsigned Size)
Widen the scalar type or vector element type for the given type index to next multiple of Size.
Definition: LegalizeMutations.cpp:67
llvm::LegalityPredicates::TypePairAndMemDesc::operator==
bool operator==(const TypePairAndMemDesc &Other) const
Definition: LegalizerInfo.h:208
llvm::LegalizeActions::UseLegacyRules
@ UseLegacyRules
Fall back onto the old rules.
Definition: LegalizerInfo.h:95
llvm::LegalizeRuleSet::widenScalarIf
LegalizeRuleSet & widenScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Widen the scalar to the one selected by the mutation if the predicate is true.
Definition: LegalizerInfo.h:741
llvm::LegalityQuery::LegalityQuery
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types, const ArrayRef< MemDesc > MMODescrs)
Definition: LegalizerInfo.h:128
llvm::LegalizeRuleSet::scalarizeIf
LegalizeRuleSet & scalarizeIf(LegalityPredicate Predicate, unsigned TypeIdx)
Definition: LegalizerInfo.h:878
STLExtras.h
llvm::LegalityPredicates::sizeNotMultipleOf
LegalityPredicate sizeNotMultipleOf(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar whose size is not a multiple of Size.
Definition: LegalityPredicates.cpp:156
llvm::LegalizeRuleSet::narrowScalar
LegalizeRuleSet & narrowScalar(unsigned TypeIdx, LegalizeMutation Mutation)
Definition: LegalizerInfo.h:866
llvm::LegalizeRuleSet::minScalarOrElt
LegalizeRuleSet & minScalarOrElt(unsigned TypeIdx, const LLT Ty)
Ensure the scalar or element is at least as wide as Ty.
Definition: LegalizerInfo.h:886
llvm::LegalizeRuleSet::scalarize
LegalizeRuleSet & scalarize(unsigned TypeIdx)
Definition: LegalizerInfo.h:872
llvm::LegalizeRuleSet::lower
LegalizeRuleSet & lower()
The instruction is lowered.
Definition: LegalizerInfo.h:643
llvm::LegalizerHelper
Definition: LegalizerHelper.h:39
llvm::LegalizeMutations::changeTo
LegalizeMutation changeTo(unsigned TypeIdx, LLT Ty)
Select this specific type for the given type index.
Definition: LegalizeMutations.cpp:17
llvm::LegalityPredicates::isPointer
LegalityPredicate isPointer(unsigned TypeIdx)
True iff the specified type index is a pointer (with any address space).
Definition: LegalityPredicates.cpp:79
llvm::MCOI::OPERAND_LAST_GENERIC_IMM
@ OPERAND_LAST_GENERIC_IMM
Definition: MCInstrDesc.h:74
llvm::LegalityPredicates::any
Predicate any(Predicate P0, Predicate P1)
True iff P0 or P1 are true.
Definition: LegalizerInfo.h:239
llvm::LegalityPredicates::atomicOrderingAtLeastOrStrongerThan
LegalityPredicate atomicOrderingAtLeastOrStrongerThan(unsigned MMOIdx, AtomicOrdering Ordering)
True iff the specified MMO index has at an atomic ordering of at Ordering or stronger.
Definition: LegalityPredicates.cpp:198
llvm::MCOI::OPERAND_LAST_GENERIC
@ OPERAND_LAST_GENERIC
Definition: MCInstrDesc.h:70
llvm::LegalizeRuleSet::libcallIf
LegalizeRuleSet & libcallIf(LegalityPredicate Predicate)
Like legalIf, but for the Libcall action.
Definition: LegalizerInfo.h:716
llvm::LegalizeRuleSet::legalIf
LegalizeRuleSet & legalIf(LegalityPredicate Predicate)
The instruction is legal if predicate is true.
Definition: LegalizerInfo.h:570
llvm::LegalizeRuleSet::legalFor
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.
Definition: LegalizerInfo.h:582
llvm::LegalizeRuleSet::minScalar
LegalizeRuleSet & minScalar(unsigned TypeIdx, const LLT Ty)
Ensure the scalar is at least as wide as Ty.
Definition: LegalizerInfo.h:906
always
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
Definition: README.txt:1412
llvm::LegalizeRuleSet::apply
LegalizeActionStep apply(const LegalityQuery &Query) const
Apply the ruleset to the given LegalityQuery.
Definition: LegalizerInfo.cpp:185
llvm::SmallBitVector
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
Definition: SmallBitVector.h:34
llvm::LLT::fixed_vector
static LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
Definition: LowLevelTypeImpl.h:75
llvm::LegacyLegalizeActionStep::Action
LegacyLegalizeActions::LegacyLegalizeAction Action
The action to take or the final answer.
Definition: LegacyLegalizerInfo.h:102
CommandLine.h
llvm::LegalizeRuleSet::LegalizeRuleSet
LegalizeRuleSet()
Definition: LegalizerInfo.h:557
llvm::LegalizeRuleSet::widenScalarOrEltToNextPow2
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.
Definition: LegalizerInfo.h:858
llvm::LegalizeRuleSet::clampMinNumElements
LegalizeRuleSet & clampMinNumElements(unsigned TypeIdx, const LLT EltTy, unsigned MinElements)
Limit the number of elements in EltTy vectors to at least MinElements.
Definition: LegalizerInfo.h:1036
llvm::LegalizeRuleSet::customIf
LegalizeRuleSet & customIf(LegalityPredicate Predicate)
Definition: LegalizerInfo.h:806
llvm::LegalityPredicates::typeIs
LegalityPredicate typeIs(unsigned TypeIdx, LLT TypesInit)
True iff the given type index is the specified type.
Definition: LegalityPredicates.cpp:28
llvm::MCOI::OPERAND_FIRST_GENERIC
@ OPERAND_FIRST_GENERIC
Definition: MCInstrDesc.h:63
llvm::LegalizeRuleSet::lowerIf
LegalizeRuleSet & lowerIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
The instruction is lowered if predicate is true.
Definition: LegalizerInfo.h:660
llvm::LegalizeRule
A single rule in a legalizer info ruleset.
Definition: LegalizerInfo.h:377
llvm::LegalizeRuleSet::aliasTo
void aliasTo(unsigned Opcode)
Definition: LegalizerInfo.h:561
llvm::LegalizeActions::NotFound
@ NotFound
Sentinel value for when no action was found in the specified table.
Definition: LegalizerInfo.h:91
llvm::LegalityPredicates::smallerThan
LegalityPredicate smallerThan(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the first type index has a smaller total bit size than second type index.
Definition: LegalityPredicates.cpp:117
llvm::LegalizeRuleSet::moreElementsIf
LegalizeRuleSet & moreElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Add more elements to reach the type selected by the mutation if the predicate is true.
Definition: LegalizerInfo.h:767
llvm::LegalityQuery::MemDesc::AlignInBits
uint64_t AlignInBits
Definition: LegalizerInfo.h:112
llvm::LLT::getSizeInBits
TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
Definition: LowLevelTypeImpl.h:153
llvm::LegalityPredicates::scalarOrEltSizeNotPow2
LegalityPredicate scalarOrEltSizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar or vector whose element size is not a power of 2.
Definition: LegalityPredicates.cpp:149
llvm::LegalizeRuleSet::legalForCartesianProduct
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.
Definition: LegalizerInfo.h:620
llvm::LegalizeRuleSet::libcallForCartesianProduct
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
Definition: LegalizerInfo.h:734
llvm::LegalizeRuleSet::lowerIfMemSizeNotPow2
LegalizeRuleSet & lowerIfMemSizeNotPow2()
Definition: LegalizerInfo.h:801
llvm::LegalizeRuleSet::fewerElementsIf
LegalizeRuleSet & fewerElementsIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Remove elements to reach the type selected by the mutation if the predicate is true.
Definition: LegalizerInfo.h:776
false
Definition: StackSlotColoring.cpp:142
TargetOpcodes.h
llvm::LegalizeRuleSet::legalForTypeWithAnyImm
LegalizeRuleSet & legalForTypeWithAnyImm(std::initializer_list< std::pair< LLT, LLT >> Types)
Definition: LegalizerInfo.h:592
llvm::LegalizeRuleSet
Definition: LegalizerInfo.h:402
llvm::machineFunctionIsIllegal
const MachineInstr * machineFunctionIsIllegal(const MachineFunction &MF)
Checks that MIR is fully legal, returns an illegal instruction if it's not, nullptr otherwise.
Definition: LegalizerInfo.cpp:426
llvm::LegalizerInfo::getLegacyLegalizerInfo
LegacyLegalizerInfo & getLegacyLegalizerInfo()
Definition: LegalizerInfo.h:1115
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::LegalizeActions::Libcall
@ Libcall
The operation should be implemented as a call to some kind of runtime support library.
Definition: LegalizerInfo.h:80
llvm::LegalizeRuleSet::clampMaxNumElements
LegalizeRuleSet & clampMaxNumElements(unsigned TypeIdx, const LLT EltTy, unsigned MaxElements)
Limit the number of elements in EltTy vectors to at most MaxElements.
Definition: LegalizerInfo.h:1054
llvm::LegalizeActions::Custom
@ Custom
The target wants to do something special with this combination of operand and type.
Definition: LegalizerInfo.h:84
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::LegalizeRuleSet::maxScalarEltSameAsIf
LegalizeRuleSet & maxScalarEltSameAsIf(LegalityPredicate Predicate, unsigned TypeIdx, unsigned SmallTypeIdx)
Conditionally narrow the scalar or elt to match the size of another.
Definition: LegalizerInfo.h:1009
llvm::LegalizeActions::Legal
@ Legal
The operation is expected to be selectable directly by the target, and no transformation is necessary...
Definition: LegalizerInfo.h:47
llvm::LinearPolySize< ElementCount >::getFixed
static ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:284
llvm::LegalizeRuleSet::libcallForCartesianProduct
LegalizeRuleSet & libcallForCartesianProduct(std::initializer_list< LLT > Types)
Definition: LegalizerInfo.h:730
LowLevelTypeImpl.h
llvm::LegalizeRule::LegalizeRule
LegalizeRule(LegalityPredicate Predicate, LegalizeAction Action, LegalizeMutation Mutation=nullptr)
Definition: LegalizerInfo.h:383
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition: AtomicOrdering.h:56
llvm::LegacyLegalizeActions::Lower
@ Lower
The operation itself must be expressed in terms of simpler actions on this target.
Definition: LegacyLegalizerInfo.h:58
llvm::LegalizeRuleSet::getAlias
unsigned getAlias() const
Definition: LegalizerInfo.h:567
llvm::LegalityQuery::MemDesc::MemDesc
MemDesc()=default
llvm::PPC::Predicate
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
Definition: PPCPredicates.h:26
llvm::LegalizerInfo::legalizeIntrinsic
virtual bool legalizeIntrinsic(LegalizerHelper &Helper, MachineInstr &MI) const
Definition: LegalizerInfo.h:1188
llvm::LegalityQuery::MemDesc::Ordering
AtomicOrdering Ordering
Definition: LegalizerInfo.h:113
llvm::LegalizeMutations::scalarize
LegalizeMutation scalarize(unsigned TypeIdx)
Break up the vector type for the given type index into the element type.
Definition: LegalizeMutations.cpp:87
llvm::LegalizeRuleSet::lowerIf
LegalizeRuleSet & lowerIf(LegalityPredicate Predicate)
The instruction is lowered if predicate is true.
Definition: LegalizerInfo.h:652
llvm::LegalizeMutations::changeElementTo
LegalizeMutation changeElementTo(unsigned TypeIdx, LLT Ty)
Keep the same scalar or element type as the given type.
Definition: LegalizeMutations.cpp:38
llvm::LegalizeRuleSet::legalFor
LegalizeRuleSet & legalFor(std::initializer_list< LLT > Types)
The instruction is legal when type index 0 is any type in the given list.
Definition: LegalizerInfo.h:577
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::LegalityPredicates::TypePairAndMemDesc::isCompatible
bool isCompatible(const TypePairAndMemDesc &Other) const
Definition: LegalizerInfo.h:215
uint64_t
llvm::LegacyLegalizeActions::NarrowScalar
@ NarrowScalar
The operation should be synthesized from multiple instructions acting on a narrower scalar base-type.
Definition: LegacyLegalizerInfo.h:35
llvm::LegalityPredicates::all
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
Definition: LegalizerInfo.h:226
llvm::LegalizeMutations::changeElementSizeTo
LegalizeMutation changeElementSizeTo(unsigned TypeIdx, unsigned FromTypeIdx)
Change the scalar size or element size to have the same scalar size as type index FromIndex.
Definition: LegalizeMutations.cpp:46
llvm::LegalizeActions::Bitcast
@ Bitcast
Perform the operation on a different, but equivalently sized type.
Definition: LegalizerInfo.h:71
llvm::LegalizeRuleSet::setIsAliasedByAnother
void setIsAliasedByAnother()
Definition: LegalizerInfo.h:560
llvm::LegalizeMutations::changeTo
LegalizeMutation changeTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same type as the given type index.
Definition: LegalizeMutations.cpp:22
llvm::LLT::isVector
bool isVector() const
Definition: LowLevelTypeImpl.h:123
llvm::LegalizeRuleSet::clampScalar
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
Definition: LegalizerInfo.h:951
llvm::LLT::getNumElements
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
Definition: LowLevelTypeImpl.h:127
llvm::LegalizeRuleSet::lowerFor
LegalizeRuleSet & lowerFor(std::initializer_list< LLT > Types)
The instruction is lowered when type index 0 is any type in the given list.
Definition: LegalizerInfo.h:669
llvm::LegalizeRuleSet::verifyImmIdxsCoverage
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...
Definition: LegalizerInfo.cpp:232
llvm::LegalityPredicates::all
Predicate all(Predicate P0, Predicate P1, Args... args)
True iff all given predicates are true.
Definition: LegalizerInfo.h:233
llvm::LegalizeRuleSet::legalForCartesianProduct
LegalizeRuleSet & legalForCartesianProduct(std::initializer_list< LLT > Types)
The instruction is legal when type indexes 0 and 1 are both in the given list.
Definition: LegalizerInfo.h:609
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::LegalityPredicate
std::function< bool(const LegalityQuery &)> LegalityPredicate
Definition: LegalizerInfo.h:197
llvm::LegalityPredicates::typeInSet
LegalityPredicate typeInSet(unsigned TypeIdx, std::initializer_list< LLT > TypesInit)
True iff the given type index is one of the specified types.
Definition: LegalityPredicates.cpp:34
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::LegalizeActions::LegalizeAction
LegalizeAction
Definition: LegalizerInfo.h:44
llvm::LegacyLegalizeActions::Legal
@ Legal
The operation is expected to be selectable directly by the target, and no transformation is necessary...
Definition: LegacyLegalizerInfo.h:30
llvm::LLT::isScalar
bool isScalar() const
Definition: LowLevelTypeImpl.h:119
llvm::LegalityPredicates::TypePairAndMemDesc::Align
uint64_t Align
Definition: LegalizerInfo.h:206
llvm::LegalizeRuleSet::lowerFor
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.
Definition: LegalizerInfo.h:680
llvm::LegalityQuery::Opcode
unsigned Opcode
Definition: LegalizerInfo.h:107
llvm::LegalizeRuleSet::narrowScalarFor
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...
Definition: LegalizerInfo.h:760
llvm::LegalityQuery
The LegalityQuery object bundles together all the information that's needed to decide whether a given...
Definition: LegalizerInfo.h:106
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::LegalizeRuleSet::legalForTypeWithAnyImm
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.
Definition: LegalizerInfo.h:587
llvm::LegalizeRuleSet::customForCartesianProduct
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types)
Definition: LegalizerInfo.h:822
llvm::LegalizeRuleSet::clampScalarOrElt
LegalizeRuleSet & clampScalarOrElt(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
Definition: LegalizerInfo.h:958
llvm::LegalizeMutations::changeElementTo
LegalizeMutation changeElementTo(unsigned TypeIdx, unsigned FromTypeIdx)
Keep the same scalar or element type as the given type index.
Definition: LegalizeMutations.cpp:29
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
verify
ppc ctr loops verify
Definition: PPCCTRLoops.cpp:76
llvm::LegalityPredicates::typePairInSet
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.
Definition: LegalityPredicates.cpp:42
llvm::LegalizeRuleSet::libcallFor
LegalizeRuleSet & libcallFor(std::initializer_list< std::pair< LLT, LLT >> Types)
Definition: LegalizerInfo.h:726
Mutation
PowerPC VSX FMA Mutation
Definition: PPCVSXFMAMutate.cpp:391
llvm::LegalityPredicates::sizeNotPow2
LegalityPredicate sizeNotPow2(unsigned TypeIdx)
True iff the specified type index is a scalar whose size is not a power of.
Definition: LegalityPredicates.cpp:164
llvm::LegalizeMutations::widenScalarOrEltToNextPow2
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.
Definition: LegalizeMutations.cpp:56
llvm::LegalizeActionStep::LegalizeActionStep
LegalizeActionStep(LegacyLegalizeActionStep Step)
Definition: LegalizerInfo.h:152
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::LegalityPredicates::isScalar
LegalityPredicate isScalar(unsigned TypeIdx)
True iff the specified type index is a scalar.
Definition: LegalityPredicates.cpp:67
llvm::LegacyLegalizeActions::Libcall
@ Libcall
The operation should be implemented as a call to some kind of runtime support library.
Definition: LegacyLegalizerInfo.h:63
llvm::LegalizeActionStep::NewType
LLT NewType
If describing an action, the new type for TypeIdx. Otherwise LLT{}.
Definition: LegalizerInfo.h:146
llvm::LegalizerInfo::getLegacyLegalizerInfo
const LegacyLegalizerInfo & getLegacyLegalizerInfo() const
Definition: LegalizerInfo.h:1112
llvm::LegalizeActionStep::LegalizeActionStep
LegalizeActionStep(LegalizeAction Action, unsigned TypeIdx, const LLT NewType)
Definition: LegalizerInfo.h:148
llvm::LegalityPredicates::scalarOrEltNarrowerThan
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...
Definition: LegalityPredicates.cpp:133
llvm::LegalizeRuleSet::narrowScalarIf
LegalizeRuleSet & narrowScalarIf(LegalityPredicate Predicate, LegalizeMutation Mutation)
Narrow the scalar to the one selected by the mutation if the predicate is true.
Definition: LegalizerInfo.h:750
llvm::LegalizeRuleSet::lowerFor
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.
Definition: LegalizerInfo.h:685
llvm::LegalityPredicates::TypePairAndMemDesc::Type0
LLT Type0
Definition: LegalizerInfo.h:203
llvm::LegalityPredicates::sizeIs
LegalityPredicate sizeIs(unsigned TypeIdx, unsigned Size)
True if the total bitwidth of the specified type index is Size bits.
Definition: LegalityPredicates.cpp:171
llvm::LegalizeRuleSet::isAliasedByAnother
bool isAliasedByAnother()
Definition: LegalizerInfo.h:559
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::LegalizeRuleSet::alwaysLegal
LegalizeRuleSet & alwaysLegal()
Definition: LegalizerInfo.h:627
llvm::LegalizeRule::getAction
LegalizeAction getAction() const
Definition: LegalizerInfo.h:392
llvm::LegalityPredicates::memSizeInBytesNotPow2
LegalityPredicate memSizeInBytesNotPow2(unsigned MMOIdx)
True iff the specified MMO index has a size that is not a power of 2.
Definition: LegalityPredicates.cpp:185
llvm::LegalizeRuleSet::verifyTypeIdxsCoverage
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...
Definition: LegalizerInfo.cpp:209
llvm::LegalityPredicates::scalarWiderThan
LegalityPredicate scalarWiderThan(unsigned TypeIdx, unsigned Size)
True iff the specified type index is a scalar that's wider than the given size.
Definition: LegalityPredicates.cpp:109
llvm::LegalityQuery::MMODescrs
ArrayRef< MemDesc > MMODescrs
Operations which require memory can use this to place requirements on the memory type for each MMO.
Definition: LegalizerInfo.h:126
llvm::LegalizeRuleSet::unsupportedIf
LegalizeRuleSet & unsupportedIf(LegalityPredicate Predicate)
Definition: LegalizerInfo.h:789
llvm::LegalityPredicates::TypePairAndMemDesc
Definition: LegalizerInfo.h:202
llvm::LegalizeActions::FewerElements
@ FewerElements
The (vector) operation should be implemented by splitting it into sub-vectors where the operation is ...
Definition: LegalizerInfo.h:62
llvm::LegacyLegalizeActionStep
The result of a query.
Definition: LegacyLegalizerInfo.h:100
llvm::LegalizeRuleSet::legalForCartesianProduct
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.
Definition: LegalizerInfo.h:614
llvm::LegalizeRuleSet::minScalarSameAs
LegalizeRuleSet & minScalarSameAs(unsigned TypeIdx, unsigned LargeTypeIdx)
Widen the scalar to match the size of another.
Definition: LegalizerInfo.h:964
llvm::LegacyLegalizerInfo
Definition: LegacyLegalizerInfo.h:119
llvm::LegacyLegalizeActions::Unsupported
@ Unsupported
This operation is completely unsupported on the target.
Definition: LegacyLegalizerInfo.h:71
llvm::getAlign
bool getAlign(const Function &F, unsigned index, unsigned &align)
Definition: NVPTXUtilities.cpp:284
llvm::LegalizeRuleSet::lowerForCartesianProduct
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.
Definition: LegalizerInfo.h:691
llvm::LegalityQuery::print
raw_ostream & print(raw_ostream &OS) const
Definition: LegalizerInfo.cpp:82
llvm::LegalityPredicates::numElementsNotPow2
LegalityPredicate numElementsNotPow2(unsigned TypeIdx)
True iff the specified type index is a vector whose element count is not a power of 2.
Definition: LegalityPredicates.cpp:191
llvm::LegalityPredicates::isVector
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
Definition: LegalityPredicates.cpp:73
llvm::LegalizeActionStep::operator==
bool operator==(const LegalizeActionStep &RHS) const
Definition: LegalizerInfo.h:191
llvm::LegalizeActionStep::TypeIdx
unsigned TypeIdx
If describing an action, the type index to change. Otherwise zero.
Definition: LegalizerInfo.h:144
llvm::LegalityPredicates::typePairAndMemDescInSet
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.
Definition: LegalityPredicates.cpp:52
SmallVector.h
llvm::LegalityQuery::Types
ArrayRef< LLT > Types
Definition: LegalizerInfo.h:108
llvm::LegalizeRuleSet::fallback
LegalizeRuleSet & fallback()
Fallback on the previous implementation.
Definition: LegalizerInfo.h:1090
llvm::LegalizeRuleSet::moreElementsToNextPow2
LegalizeRuleSet & moreElementsToNextPow2(unsigned TypeIdx)
Add more elements to the vector to reach the next power of two.
Definition: LegalizerInfo.h:1028
llvm::LegalizerInfo::isLegalOrCustom
bool isLegalOrCustom(const LegalityQuery &Query) const
Definition: LegalizerInfo.h:1169
SmallBitVector.h
llvm::LLT::scalarOrVector
static LLT scalarOrVector(ElementCount EC, LLT ScalarTy)
Definition: LowLevelTypeImpl.h:98
llvm::LegalizeRuleSet::custom
LegalizeRuleSet & custom()
Unconditionally custom lower.
Definition: LegalizerInfo.h:832
llvm::LegalizeActions::Unsupported
@ Unsupported
This operation is completely unsupported on the target.
Definition: LegalizerInfo.h:88
llvm::LegalizeRuleSet::unsupportedFor
LegalizeRuleSet & unsupportedFor(std::initializer_list< LLT > Types)
Definition: LegalizerInfo.h:793
llvm::LegalizeMutation
std::function< std::pair< unsigned, LLT >(const LegalityQuery &)> LegalizeMutation
Definition: LegalizerInfo.h:199
llvm::LegalizeMutations::moreElementsToNextPow2
LegalizeMutation moreElementsToNextPow2(unsigned TypeIdx, unsigned Min=0)
Add more elements to the type for the given type index to the next power of.
Definition: LegalizeMutations.cpp:76
llvm::LegalityPredicates::TypePairAndMemDesc::MemTy
LLT MemTy
Definition: LegalizerInfo.h:205
llvm::LegalizerInfo
Definition: LegalizerInfo.h:1108
llvm::LegalizeRuleSet::lowerForCartesianProduct
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.
Definition: LegalizerInfo.h:698
llvm::LegalizeRuleSet::scalarSameSizeAs
LegalizeRuleSet & scalarSameSizeAs(unsigned TypeIdx, unsigned SameSizeIdx)
Change the type TypeIdx to have the same scalar size as type SameSizeIdx.
Definition: LegalizerInfo.h:987
llvm::LegalizerInfo::legalizeCustom
virtual bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const
Called for instructions with the Custom LegalizationAction.
Definition: LegalizerInfo.h:1179
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::LLT::getElementType
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
Definition: LowLevelTypeImpl.h:237
raw_ostream.h
llvm::LegalizeRuleSet::libcallFor
LegalizeRuleSet & libcallFor(std::initializer_list< LLT > Types)
Definition: LegalizerInfo.h:722
llvm::LegalityPredicates::TypePairAndMemDesc::Type1
LLT Type1
Definition: LegalizerInfo.h:204
MachineFunction.h
llvm::LegalizeActions::Lower
@ Lower
The operation itself must be expressed in terms of simpler actions on this target.
Definition: LegalizerInfo.h:75
llvm::LegalizeRuleSet::customForCartesianProduct
LegalizeRuleSet & customForCartesianProduct(std::initializer_list< LLT > Types0, std::initializer_list< LLT > Types1)
Definition: LegalizerInfo.h:826
llvm::LegalityPredicates::sameSize
LegalityPredicate sameSize(unsigned TypeIdx0, unsigned TypeIdx1)
True iff the specified type indices are both the same bit size.
Definition: LegalityPredicates.cpp:177
llvm::LegalityQuery::LegalityQuery
constexpr LegalityQuery(unsigned Opcode, const ArrayRef< LLT > Types)
Definition: LegalizerInfo.h:131
llvm::LegalizerInfo::isLegal
bool isLegal(const LegalityQuery &Query) const
Definition: LegalizerInfo.h:1165
llvm::LegacyLegalizeActions::NotFound
@ NotFound
Sentinel value for when no action was found in the specified table.
Definition: LegacyLegalizerInfo.h:74
llvm::LegalizeRuleSet::legalForTypesWithMemDesc
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...
Definition: LegalizerInfo.h:600
llvm::LegalizeRuleSet::widenScalarToNextMultipleOf
LegalizeRuleSet & widenScalarToNextMultipleOf(unsigned TypeIdx, unsigned Size)
Widen the scalar to the next multiple of Size.
Definition: LegalizerInfo.h:848
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184
llvm::LegalityQuery::MemDesc::MemoryTy
LLT MemoryTy
Definition: LegalizerInfo.h:111
llvm::LLT
Definition: LowLevelTypeImpl.h:40