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