[Matrix] Hoist IRBuilder<> out of Visit* functions. NFC (#144369)
This commit is contained in:
@@ -1146,24 +1146,24 @@ public:
|
||||
Value *Op1;
|
||||
Value *Op2;
|
||||
MatrixTy Result;
|
||||
IRBuilder<> Builder(Inst);
|
||||
if (auto *BinOp = dyn_cast<BinaryOperator>(Inst))
|
||||
Result = VisitBinaryOperator(BinOp, SI);
|
||||
Result = VisitBinaryOperator(BinOp, SI, Builder);
|
||||
else if (auto *Cast = dyn_cast<CastInst>(Inst))
|
||||
Result = VisitCastInstruction(Cast, SI);
|
||||
Result = VisitCastInstruction(Cast, SI, Builder);
|
||||
else if (auto *UnOp = dyn_cast<UnaryOperator>(Inst))
|
||||
Result = VisitUnaryOperator(UnOp, SI);
|
||||
Result = VisitUnaryOperator(UnOp, SI, Builder);
|
||||
else if (auto *Intr = dyn_cast<IntrinsicInst>(Inst))
|
||||
Result = VisitIntrinsicInst(Intr, SI);
|
||||
Result = VisitIntrinsicInst(Intr, SI, Builder);
|
||||
else if (auto *Select = dyn_cast<SelectInst>(Inst))
|
||||
Result = VisitSelectInst(Select, SI);
|
||||
Result = VisitSelectInst(Select, SI, Builder);
|
||||
else if (match(Inst, m_Load(m_Value(Op1))))
|
||||
Result = VisitLoad(cast<LoadInst>(Inst), SI, Op1);
|
||||
Result = VisitLoad(cast<LoadInst>(Inst), SI, Op1, Builder);
|
||||
else if (match(Inst, m_Store(m_Value(Op1), m_Value(Op2))))
|
||||
Result = VisitStore(cast<StoreInst>(Inst), SI, Op1, Op2);
|
||||
Result = VisitStore(cast<StoreInst>(Inst), SI, Op1, Op2, Builder);
|
||||
else
|
||||
continue;
|
||||
|
||||
IRBuilder<> Builder(Inst);
|
||||
finalizeLowering(Inst, Result, Builder);
|
||||
Changed = true;
|
||||
}
|
||||
@@ -1204,7 +1204,8 @@ public:
|
||||
}
|
||||
|
||||
/// Replace intrinsic calls.
|
||||
MatrixTy VisitIntrinsicInst(IntrinsicInst *Inst, const ShapeInfo &SI) {
|
||||
MatrixTy VisitIntrinsicInst(IntrinsicInst *Inst, const ShapeInfo &SI,
|
||||
IRBuilder<> &Builder) {
|
||||
assert(Inst->getCalledFunction() &&
|
||||
Inst->getCalledFunction()->isIntrinsic());
|
||||
|
||||
@@ -1219,7 +1220,6 @@ public:
|
||||
return LowerColumnMajorStore(Inst);
|
||||
case Intrinsic::abs:
|
||||
case Intrinsic::fabs: {
|
||||
IRBuilder<> Builder(Inst);
|
||||
MatrixTy Result;
|
||||
MatrixTy M = getMatrix(Inst->getOperand(0), SI, Builder);
|
||||
Builder.setFastMathFlags(getFastMathFlags(Inst));
|
||||
@@ -1298,7 +1298,6 @@ public:
|
||||
ShapeInfo MatrixShape, Value *I, Value *J,
|
||||
ShapeInfo ResultShape, Type *EltTy,
|
||||
IRBuilder<> &Builder) {
|
||||
|
||||
Value *Offset = Builder.CreateAdd(
|
||||
Builder.CreateMul(J, Builder.getInt64(MatrixShape.getStride())), I);
|
||||
|
||||
@@ -2228,26 +2227,24 @@ public:
|
||||
}
|
||||
|
||||
/// Lower load instructions.
|
||||
MatrixTy VisitLoad(LoadInst *Inst, const ShapeInfo &SI, Value *Ptr) {
|
||||
IRBuilder<> Builder(Inst);
|
||||
MatrixTy VisitLoad(LoadInst *Inst, const ShapeInfo &SI, Value *Ptr,
|
||||
IRBuilder<> &Builder) {
|
||||
return LowerLoad(Inst, Ptr, Inst->getAlign(),
|
||||
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
|
||||
}
|
||||
|
||||
MatrixTy VisitStore(StoreInst *Inst, const ShapeInfo &SI, Value *StoredVal,
|
||||
Value *Ptr) {
|
||||
IRBuilder<> Builder(Inst);
|
||||
Value *Ptr, IRBuilder<> &Builder) {
|
||||
return LowerStore(Inst, StoredVal, Ptr, Inst->getAlign(),
|
||||
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
|
||||
}
|
||||
|
||||
/// Lower binary operators.
|
||||
MatrixTy VisitBinaryOperator(BinaryOperator *Inst, const ShapeInfo &SI) {
|
||||
MatrixTy VisitBinaryOperator(BinaryOperator *Inst, const ShapeInfo &SI,
|
||||
IRBuilder<> &Builder) {
|
||||
Value *Lhs = Inst->getOperand(0);
|
||||
Value *Rhs = Inst->getOperand(1);
|
||||
|
||||
IRBuilder<> Builder(Inst);
|
||||
|
||||
MatrixTy Result;
|
||||
MatrixTy A = getMatrix(Lhs, SI, Builder);
|
||||
MatrixTy B = getMatrix(Rhs, SI, Builder);
|
||||
@@ -2265,11 +2262,10 @@ public:
|
||||
}
|
||||
|
||||
/// Lower unary operators.
|
||||
MatrixTy VisitUnaryOperator(UnaryOperator *Inst, const ShapeInfo &SI) {
|
||||
MatrixTy VisitUnaryOperator(UnaryOperator *Inst, const ShapeInfo &SI,
|
||||
IRBuilder<> &Builder) {
|
||||
Value *Op = Inst->getOperand(0);
|
||||
|
||||
IRBuilder<> Builder(Inst);
|
||||
|
||||
MatrixTy Result;
|
||||
MatrixTy M = getMatrix(Op, SI, Builder);
|
||||
|
||||
@@ -2293,11 +2289,10 @@ public:
|
||||
}
|
||||
|
||||
/// Lower cast instructions.
|
||||
MatrixTy VisitCastInstruction(CastInst *Inst, const ShapeInfo &Shape) {
|
||||
MatrixTy VisitCastInstruction(CastInst *Inst, const ShapeInfo &Shape,
|
||||
IRBuilder<> &Builder) {
|
||||
Value *Op = Inst->getOperand(0);
|
||||
|
||||
IRBuilder<> Builder(Inst);
|
||||
|
||||
MatrixTy Result;
|
||||
MatrixTy M = getMatrix(Op, Shape, Builder);
|
||||
|
||||
@@ -2315,13 +2310,12 @@ public:
|
||||
}
|
||||
|
||||
/// Lower selects.
|
||||
MatrixTy VisitSelectInst(SelectInst *Inst, const ShapeInfo &Shape) {
|
||||
MatrixTy VisitSelectInst(SelectInst *Inst, const ShapeInfo &Shape,
|
||||
IRBuilder<> &Builder) {
|
||||
Value *Cond = Inst->getOperand(0);
|
||||
Value *OpA = Inst->getOperand(1);
|
||||
Value *OpB = Inst->getOperand(2);
|
||||
|
||||
IRBuilder<> Builder(Inst);
|
||||
|
||||
MatrixTy Result;
|
||||
MatrixTy A = getMatrix(OpA, Shape, Builder);
|
||||
MatrixTy B = getMatrix(OpB, Shape, Builder);
|
||||
|
||||
Reference in New Issue
Block a user