LLVM  8.0.1
LegalizeMutations.cpp
Go to the documentation of this file.
1 //===- lib/CodeGen/GlobalISel/LegalizerMutations.cpp - Mutations ----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // A library of mutation factories to use for LegalityMutation.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 
16 using namespace llvm;
17 
19  return
20  [=](const LegalityQuery &Query) { return std::make_pair(TypeIdx, Ty); };
21 }
22 
24  unsigned FromTypeIdx) {
25  return [=](const LegalityQuery &Query) {
26  return std::make_pair(TypeIdx, Query.Types[FromTypeIdx]);
27  };
28 }
29 
31  unsigned Min) {
32  return [=](const LegalityQuery &Query) {
33  unsigned NewSizeInBits =
34  1 << Log2_32_Ceil(Query.Types[TypeIdx].getSizeInBits());
35  if (NewSizeInBits < Min)
36  NewSizeInBits = Min;
37  return std::make_pair(TypeIdx, LLT::scalar(NewSizeInBits));
38  };
39 }
40 
42  unsigned Min) {
43  return [=](const LegalityQuery &Query) {
44  const LLT &VecTy = Query.Types[TypeIdx];
45  unsigned NewNumElements = 1 << Log2_32_Ceil(VecTy.getNumElements());
46  if (NewNumElements < Min)
47  NewNumElements = Min;
48  return std::make_pair(
49  TypeIdx, LLT::vector(NewNumElements, VecTy.getScalarSizeInBits()));
50  };
51 }
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition: MathExtras.h:552
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned getScalarSizeInBits() const
LegalizeMutation widenScalarToNextPow2(unsigned TypeIdx, unsigned Min=0)
Widen the type for the given type index to the next power of 2.
The LegalityQuery object bundles together all the information that&#39;s needed to decide whether a given...
LegalizeMutation changeTo(unsigned TypeIdx, LLT Ty)
Select this specific type for the given type index.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
std::function< std::pair< unsigned, LLT >(const LegalityQuery &)> LegalizeMutation
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
LegalizeMutation moreElementsToNextPow2(unsigned TypeIdx, unsigned Min=0)
Add more elements to the type for the given type index to the next power of.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.