Files
clang-p2996/llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
Daniel Sanders 1cc575666f [globalisel][legalizer] Change identity() to changeTo() to clarify that it changes things. NFC
Prior to committing r323681, we decided to change pick() to identity() since
it wasn't clear from the name what pick() did. However, identity() isn't a very
good name either since it implies that no changes are made. For some reason,
naming it changeTo() didn't occur to me until just after the commit. This
should resolve the lack of clarity that pick() had while still implying that
it changes the MIR.

llvm-svn: 323689
2018-01-29 20:46:16 +00:00

45 lines
1.6 KiB
C++

//===- lib/CodeGen/GlobalISel/LegalizerMutations.cpp - Mutations ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// A library of mutation factories to use for LegalityMutation.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
using namespace llvm;
LegalizeMutation LegalizeMutations::changeTo(unsigned TypeIdx, LLT Ty) {
return
[=](const LegalityQuery &Query) { return std::make_pair(TypeIdx, Ty); };
}
LegalizeMutation LegalizeMutations::widenScalarToNextPow2(unsigned TypeIdx,
unsigned Min) {
return [=](const LegalityQuery &Query) {
unsigned NewSizeInBits =
1 << Log2_32_Ceil(Query.Types[TypeIdx].getSizeInBits());
if (NewSizeInBits < Min)
NewSizeInBits = Min;
return std::make_pair(TypeIdx, LLT::scalar(NewSizeInBits));
};
}
LegalizeMutation LegalizeMutations::moreElementsToNextPow2(unsigned TypeIdx,
unsigned Min) {
return [=](const LegalityQuery &Query) {
const LLT &VecTy = Query.Types[TypeIdx];
unsigned NewNumElements = 1 << Log2_32_Ceil(VecTy.getNumElements());
if (NewNumElements < Min)
NewNumElements = Min;
return std::make_pair(
TypeIdx, LLT::vector(NewNumElements, VecTy.getScalarSizeInBits()));
};
}