forked from OSchip/llvm-project
[LV] Use IRBuilderBase in VPlan.h, remove IRBuilder.h include (NFC).
By using IRBuilderBase instead of IRBuilder<> a forward declaration can be used instead of including IRBuilder.h
This commit is contained in:
parent
677182fe98
commit
5a72357697
|
@ -525,7 +525,7 @@ public:
|
||||||
/// Set the debug location in the builder \p Ptr using the debug location in
|
/// Set the debug location in the builder \p Ptr using the debug location in
|
||||||
/// \p V. If \p Ptr is None then it uses the class member's Builder.
|
/// \p V. If \p Ptr is None then it uses the class member's Builder.
|
||||||
void setDebugLocFromInst(const Value *V,
|
void setDebugLocFromInst(const Value *V,
|
||||||
Optional<IRBuilder<> *> CustomBuilder = None);
|
Optional<IRBuilderBase *> CustomBuilder = None);
|
||||||
|
|
||||||
/// Fix the non-induction PHIs in the OrigPHIsToFix vector.
|
/// Fix the non-induction PHIs in the OrigPHIsToFix vector.
|
||||||
void fixNonInductionPHIs(VPTransformState &State);
|
void fixNonInductionPHIs(VPTransformState &State);
|
||||||
|
@ -658,8 +658,8 @@ protected:
|
||||||
/// For pointer induction, returns StartValue[Index * StepValue].
|
/// For pointer induction, returns StartValue[Index * StepValue].
|
||||||
/// FIXME: The newly created binary instructions should contain nsw/nuw
|
/// FIXME: The newly created binary instructions should contain nsw/nuw
|
||||||
/// flags, which can be found from the original scalar operations.
|
/// flags, which can be found from the original scalar operations.
|
||||||
Value *emitTransformedIndex(IRBuilder<> &B, Value *Index, ScalarEvolution *SE,
|
Value *emitTransformedIndex(IRBuilderBase &B, Value *Index,
|
||||||
const DataLayout &DL,
|
ScalarEvolution *SE, const DataLayout &DL,
|
||||||
const InductionDescriptor &ID,
|
const InductionDescriptor &ID,
|
||||||
BasicBlock *VectorHeader) const;
|
BasicBlock *VectorHeader) const;
|
||||||
|
|
||||||
|
@ -989,8 +989,8 @@ static Instruction *getDebugLocFromInstOrOperands(Instruction *I) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerLoopVectorizer::setDebugLocFromInst(
|
void InnerLoopVectorizer::setDebugLocFromInst(
|
||||||
const Value *V, Optional<IRBuilder<> *> CustomBuilder) {
|
const Value *V, Optional<IRBuilderBase *> CustomBuilder) {
|
||||||
IRBuilder<> *B = (CustomBuilder == None) ? &Builder : *CustomBuilder;
|
IRBuilderBase *B = (CustomBuilder == None) ? &Builder : *CustomBuilder;
|
||||||
if (const Instruction *Inst = dyn_cast_or_null<Instruction>(V)) {
|
if (const Instruction *Inst = dyn_cast_or_null<Instruction>(V)) {
|
||||||
const DILocation *DIL = Inst->getDebugLoc();
|
const DILocation *DIL = Inst->getDebugLoc();
|
||||||
|
|
||||||
|
@ -1054,7 +1054,7 @@ static OptimizationRemarkAnalysis createLVAnalysis(const char *PassName,
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// Return a value for Step multiplied by VF.
|
/// Return a value for Step multiplied by VF.
|
||||||
Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF,
|
Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
|
||||||
int64_t Step) {
|
int64_t Step) {
|
||||||
assert(Ty->isIntegerTy() && "Expected an integer step");
|
assert(Ty->isIntegerTy() && "Expected an integer step");
|
||||||
Constant *StepVal = ConstantInt::get(Ty, Step * VF.getKnownMinValue());
|
Constant *StepVal = ConstantInt::get(Ty, Step * VF.getKnownMinValue());
|
||||||
|
@ -1062,12 +1062,13 @@ Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the runtime value for VF.
|
/// Return the runtime value for VF.
|
||||||
Value *getRuntimeVF(IRBuilder<> &B, Type *Ty, ElementCount VF) {
|
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF) {
|
||||||
Constant *EC = ConstantInt::get(Ty, VF.getKnownMinValue());
|
Constant *EC = ConstantInt::get(Ty, VF.getKnownMinValue());
|
||||||
return VF.isScalable() ? B.CreateVScale(EC) : EC;
|
return VF.isScalable() ? B.CreateVScale(EC) : EC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value *getRuntimeVFAsFloat(IRBuilder<> &B, Type *FTy, ElementCount VF) {
|
static Value *getRuntimeVFAsFloat(IRBuilderBase &B, Type *FTy,
|
||||||
|
ElementCount VF) {
|
||||||
assert(FTy->isFloatingPointTy() && "Expected floating point type!");
|
assert(FTy->isFloatingPointTy() && "Expected floating point type!");
|
||||||
Type *IntTy = IntegerType::get(FTy->getContext(), FTy->getScalarSizeInBits());
|
Type *IntTy = IntegerType::get(FTy->getContext(), FTy->getScalarSizeInBits());
|
||||||
Value *RuntimeVF = getRuntimeVF(B, IntTy, VF);
|
Value *RuntimeVF = getRuntimeVF(B, IntTy, VF);
|
||||||
|
@ -2337,7 +2338,7 @@ Value *InnerLoopVectorizer::getBroadcastInstrs(Value *V) {
|
||||||
/// \p Opcode is relevant for FP induction variable.
|
/// \p Opcode is relevant for FP induction variable.
|
||||||
static Value *getStepVector(Value *Val, Value *StartIdx, Value *Step,
|
static Value *getStepVector(Value *Val, Value *StartIdx, Value *Step,
|
||||||
Instruction::BinaryOps BinOp, ElementCount VF,
|
Instruction::BinaryOps BinOp, ElementCount VF,
|
||||||
IRBuilder<> &Builder) {
|
IRBuilderBase &Builder) {
|
||||||
assert(VF.isVector() && "only vector VFs are supported");
|
assert(VF.isVector() && "only vector VFs are supported");
|
||||||
|
|
||||||
// Create and check the types.
|
// Create and check the types.
|
||||||
|
@ -2388,7 +2389,7 @@ static Value *getStepVector(Value *Val, Value *StartIdx, Value *Step,
|
||||||
void InnerLoopVectorizer::createVectorIntOrFpInductionPHI(
|
void InnerLoopVectorizer::createVectorIntOrFpInductionPHI(
|
||||||
const InductionDescriptor &II, Value *Step, Value *Start,
|
const InductionDescriptor &II, Value *Step, Value *Start,
|
||||||
Instruction *EntryVal, VPValue *Def, VPTransformState &State) {
|
Instruction *EntryVal, VPValue *Def, VPTransformState &State) {
|
||||||
IRBuilder<> &Builder = State.Builder;
|
IRBuilderBase &Builder = State.Builder;
|
||||||
assert((isa<PHINode>(EntryVal) || isa<TruncInst>(EntryVal)) &&
|
assert((isa<PHINode>(EntryVal) || isa<TruncInst>(EntryVal)) &&
|
||||||
"Expected either an induction phi-node or a truncate of it!");
|
"Expected either an induction phi-node or a truncate of it!");
|
||||||
|
|
||||||
|
@ -2474,7 +2475,7 @@ void InnerLoopVectorizer::widenIntOrFpInduction(
|
||||||
Value *Start = Def->getStartValue()->getLiveInIRValue();
|
Value *Start = Def->getStartValue()->getLiveInIRValue();
|
||||||
const InductionDescriptor &ID = Def->getInductionDescriptor();
|
const InductionDescriptor &ID = Def->getInductionDescriptor();
|
||||||
TruncInst *Trunc = Def->getTruncInst();
|
TruncInst *Trunc = Def->getTruncInst();
|
||||||
IRBuilder<> &Builder = State.Builder;
|
IRBuilderBase &Builder = State.Builder;
|
||||||
assert(IV->getType() == ID.getStartValue()->getType() && "Types must match");
|
assert(IV->getType() == ID.getStartValue()->getType() && "Types must match");
|
||||||
assert(!State.VF.isZero() && "VF must be non-zero");
|
assert(!State.VF.isZero() && "VF must be non-zero");
|
||||||
|
|
||||||
|
@ -2577,7 +2578,7 @@ void InnerLoopVectorizer::buildScalarSteps(Value *ScalarIV, Value *Step,
|
||||||
const InductionDescriptor &ID,
|
const InductionDescriptor &ID,
|
||||||
VPValue *Def,
|
VPValue *Def,
|
||||||
VPTransformState &State) {
|
VPTransformState &State) {
|
||||||
IRBuilder<> &Builder = State.Builder;
|
IRBuilderBase &Builder = State.Builder;
|
||||||
// We shouldn't have to build scalar steps if we aren't vectorizing.
|
// We shouldn't have to build scalar steps if we aren't vectorizing.
|
||||||
assert(State.VF.isVector() && "VF should be greater than one");
|
assert(State.VF.isVector() && "VF should be greater than one");
|
||||||
// Get the value type and ensure it and the step have the same integer type.
|
// Get the value type and ensure it and the step have the same integer type.
|
||||||
|
@ -3217,7 +3218,7 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L,
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *InnerLoopVectorizer::emitTransformedIndex(
|
Value *InnerLoopVectorizer::emitTransformedIndex(
|
||||||
IRBuilder<> &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL,
|
IRBuilderBase &B, Value *Index, ScalarEvolution *SE, const DataLayout &DL,
|
||||||
const InductionDescriptor &ID, BasicBlock *VectorHeader) const {
|
const InductionDescriptor &ID, BasicBlock *VectorHeader) const {
|
||||||
|
|
||||||
SCEVExpander Exp(*SE, DL, "induction");
|
SCEVExpander Exp(*SE, DL, "induction");
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
#include "llvm/IR/CFG.h"
|
#include "llvm/IR/CFG.h"
|
||||||
|
#include "llvm/IR/IRBuilder.h"
|
||||||
#include "llvm/IR/InstrTypes.h"
|
#include "llvm/IR/InstrTypes.h"
|
||||||
#include "llvm/IR/Instruction.h"
|
#include "llvm/IR/Instruction.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
|
@ -60,7 +61,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const VPValue &V) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Value *VPLane::getAsRuntimeExpr(IRBuilder<> &Builder,
|
Value *VPLane::getAsRuntimeExpr(IRBuilderBase &Builder,
|
||||||
const ElementCount &VF) const {
|
const ElementCount &VF) const {
|
||||||
switch (LaneKind) {
|
switch (LaneKind) {
|
||||||
case VPLane::Kind::ScalableLast:
|
case VPLane::Kind::ScalableLast:
|
||||||
|
@ -640,7 +641,7 @@ void VPRecipeBase::moveBefore(VPBasicBlock &BB,
|
||||||
|
|
||||||
void VPInstruction::generateInstruction(VPTransformState &State,
|
void VPInstruction::generateInstruction(VPTransformState &State,
|
||||||
unsigned Part) {
|
unsigned Part) {
|
||||||
IRBuilder<> &Builder = State.Builder;
|
IRBuilderBase &Builder = State.Builder;
|
||||||
Builder.SetCurrentDebugLocation(DL);
|
Builder.SetCurrentDebugLocation(DL);
|
||||||
|
|
||||||
if (Instruction::isBinaryOp(getOpcode())) {
|
if (Instruction::isBinaryOp(getOpcode())) {
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "llvm/ADT/ilist_node.h"
|
#include "llvm/ADT/ilist_node.h"
|
||||||
#include "llvm/Analysis/VectorUtils.h"
|
#include "llvm/Analysis/VectorUtils.h"
|
||||||
#include "llvm/IR/DebugLoc.h"
|
#include "llvm/IR/DebugLoc.h"
|
||||||
#include "llvm/IR/IRBuilder.h"
|
|
||||||
#include "llvm/Support/InstructionCost.h"
|
#include "llvm/Support/InstructionCost.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -54,6 +53,7 @@ class BasicBlock;
|
||||||
class DominatorTree;
|
class DominatorTree;
|
||||||
class InductionDescriptor;
|
class InductionDescriptor;
|
||||||
class InnerLoopVectorizer;
|
class InnerLoopVectorizer;
|
||||||
|
class IRBuilderBase;
|
||||||
class LoopInfo;
|
class LoopInfo;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class RecurrenceDescriptor;
|
class RecurrenceDescriptor;
|
||||||
|
@ -67,10 +67,11 @@ class VPlanSlp;
|
||||||
/// Returns a calculation for the total number of elements for a given \p VF.
|
/// Returns a calculation for the total number of elements for a given \p VF.
|
||||||
/// For fixed width vectors this value is a constant, whereas for scalable
|
/// For fixed width vectors this value is a constant, whereas for scalable
|
||||||
/// vectors it is an expression determined at runtime.
|
/// vectors it is an expression determined at runtime.
|
||||||
Value *getRuntimeVF(IRBuilder<> &B, Type *Ty, ElementCount VF);
|
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF);
|
||||||
|
|
||||||
/// Return a value for Step multiplied by VF.
|
/// Return a value for Step multiplied by VF.
|
||||||
Value *createStepForVF(IRBuilder<> &B, Type *Ty, ElementCount VF, int64_t Step);
|
Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
|
||||||
|
int64_t Step);
|
||||||
|
|
||||||
/// A range of powers-of-2 vectorization factors with fixed start and
|
/// A range of powers-of-2 vectorization factors with fixed start and
|
||||||
/// adjustable end. The range includes start and excludes end, e.g.,:
|
/// adjustable end. The range includes start and excludes end, e.g.,:
|
||||||
|
@ -151,7 +152,7 @@ public:
|
||||||
|
|
||||||
/// Returns an expression describing the lane index that can be used at
|
/// Returns an expression describing the lane index that can be used at
|
||||||
/// runtime.
|
/// runtime.
|
||||||
Value *getAsRuntimeExpr(IRBuilder<> &Builder, const ElementCount &VF) const;
|
Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
|
||||||
|
|
||||||
/// Returns the Kind of lane offset.
|
/// Returns the Kind of lane offset.
|
||||||
Kind getKind() const { return LaneKind; }
|
Kind getKind() const { return LaneKind; }
|
||||||
|
@ -199,7 +200,7 @@ struct VPIteration {
|
||||||
/// needed for generating the output IR.
|
/// needed for generating the output IR.
|
||||||
struct VPTransformState {
|
struct VPTransformState {
|
||||||
VPTransformState(ElementCount VF, unsigned UF, LoopInfo *LI,
|
VPTransformState(ElementCount VF, unsigned UF, LoopInfo *LI,
|
||||||
DominatorTree *DT, IRBuilder<> &Builder,
|
DominatorTree *DT, IRBuilderBase &Builder,
|
||||||
InnerLoopVectorizer *ILV, VPlan *Plan)
|
InnerLoopVectorizer *ILV, VPlan *Plan)
|
||||||
: VF(VF), UF(UF), LI(LI), DT(DT), Builder(Builder), ILV(ILV), Plan(Plan) {
|
: VF(VF), UF(UF), LI(LI), DT(DT), Builder(Builder), ILV(ILV), Plan(Plan) {
|
||||||
}
|
}
|
||||||
|
@ -337,7 +338,7 @@ struct VPTransformState {
|
||||||
DominatorTree *DT;
|
DominatorTree *DT;
|
||||||
|
|
||||||
/// Hold a reference to the IRBuilder used to generate output IR code.
|
/// Hold a reference to the IRBuilder used to generate output IR code.
|
||||||
IRBuilder<> &Builder;
|
IRBuilderBase &Builder;
|
||||||
|
|
||||||
VPValue2ValueTy VPValue2Value;
|
VPValue2ValueTy VPValue2Value;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue