Skip to content

Commit 1f10c6a

Browse files
committed
[Matrix] Hoist more IRBuilder<>'s. NFC
1 parent 391dafd commit 1f10c6a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,13 +1211,13 @@ class LowerMatrixIntrinsics {
12111211

12121212
switch (Inst->getCalledFunction()->getIntrinsicID()) {
12131213
case Intrinsic::matrix_multiply:
1214-
return LowerMultiply(Inst);
1214+
return LowerMultiply(Inst, Builder);
12151215
case Intrinsic::matrix_transpose:
1216-
return LowerTranspose(Inst);
1216+
return LowerTranspose(Inst, Builder);
12171217
case Intrinsic::matrix_column_major_load:
1218-
return LowerColumnMajorLoad(Inst);
1218+
return LowerColumnMajorLoad(Inst, Builder);
12191219
case Intrinsic::matrix_column_major_store:
1220-
return LowerColumnMajorStore(Inst);
1220+
return LowerColumnMajorStore(Inst, Builder);
12211221
case Intrinsic::abs:
12221222
case Intrinsic::fabs: {
12231223
MatrixTy Result;
@@ -1312,23 +1312,23 @@ class LowerMatrixIntrinsics {
13121312

13131313
/// Lower a load instruction with shape information.
13141314
MatrixTy LowerLoad(Instruction *Inst, Value *Ptr, MaybeAlign Align,
1315-
Value *Stride, bool IsVolatile, ShapeInfo Shape) {
1316-
IRBuilder<> Builder(Inst);
1315+
Value *Stride, bool IsVolatile, ShapeInfo Shape,
1316+
IRBuilder<> &Builder) {
13171317
return loadMatrix(Inst->getType(), Ptr, Align, Stride, IsVolatile, Shape,
13181318
Builder);
13191319
}
13201320

13211321
/// Lowers llvm.matrix.column.major.load.
13221322
///
13231323
/// The intrinsic loads a matrix from memory using a stride between columns.
1324-
MatrixTy LowerColumnMajorLoad(CallInst *Inst) {
1324+
MatrixTy LowerColumnMajorLoad(CallInst *Inst, IRBuilder<> &Builder) {
13251325
assert(MatrixLayout == MatrixLayoutTy::ColumnMajor &&
13261326
"Intrinsic only supports column-major layout!");
13271327
Value *Ptr = Inst->getArgOperand(0);
13281328
Value *Stride = Inst->getArgOperand(1);
13291329
return LowerLoad(Inst, Ptr, Inst->getParamAlign(0), Stride,
13301330
cast<ConstantInt>(Inst->getArgOperand(2))->isOne(),
1331-
{Inst->getArgOperand(3), Inst->getArgOperand(4)});
1331+
{Inst->getArgOperand(3), Inst->getArgOperand(4)}, Builder);
13321332
}
13331333

13341334
/// Stores a sub-matrix \p StoreVal into the \p R x \p C matrix starting at \p
@@ -1373,8 +1373,7 @@ class LowerMatrixIntrinsics {
13731373
/// Lower a store instruction with shape information.
13741374
MatrixTy LowerStore(Instruction *Inst, Value *Matrix, Value *Ptr,
13751375
MaybeAlign A, Value *Stride, bool IsVolatile,
1376-
ShapeInfo Shape) {
1377-
IRBuilder<> Builder(Inst);
1376+
ShapeInfo Shape, IRBuilder<> &Builder) {
13781377
auto StoreVal = getMatrix(Matrix, Shape, Builder);
13791378
return storeMatrix(Matrix->getType(), StoreVal, Ptr, A, Stride, IsVolatile,
13801379
Builder);
@@ -1383,15 +1382,16 @@ class LowerMatrixIntrinsics {
13831382
/// Lowers llvm.matrix.column.major.store.
13841383
///
13851384
/// The intrinsic store a matrix back memory using a stride between columns.
1386-
MatrixTy LowerColumnMajorStore(CallInst *Inst) {
1385+
MatrixTy LowerColumnMajorStore(CallInst *Inst, IRBuilder<> &Builder) {
13871386
assert(MatrixLayout == MatrixLayoutTy::ColumnMajor &&
13881387
"Intrinsic only supports column-major layout!");
13891388
Value *Matrix = Inst->getArgOperand(0);
13901389
Value *Ptr = Inst->getArgOperand(1);
13911390
Value *Stride = Inst->getArgOperand(2);
13921391
return LowerStore(Inst, Matrix, Ptr, Inst->getParamAlign(1), Stride,
13931392
cast<ConstantInt>(Inst->getArgOperand(3))->isOne(),
1394-
{Inst->getArgOperand(4), Inst->getArgOperand(5)});
1393+
{Inst->getArgOperand(4), Inst->getArgOperand(5)},
1394+
Builder);
13951395
}
13961396

13971397
// Set elements I..I+NumElts-1 to Block
@@ -2166,8 +2166,7 @@ class LowerMatrixIntrinsics {
21662166
}
21672167

21682168
/// Lowers llvm.matrix.multiply.
2169-
MatrixTy LowerMultiply(CallInst *MatMul) {
2170-
IRBuilder<> Builder(MatMul);
2169+
MatrixTy LowerMultiply(CallInst *MatMul, IRBuilder<> &Builder) {
21712170
auto *EltType = cast<FixedVectorType>(MatMul->getType())->getElementType();
21722171
ShapeInfo LShape(MatMul->getArgOperand(2), MatMul->getArgOperand(3));
21732172
ShapeInfo RShape(MatMul->getArgOperand(3), MatMul->getArgOperand(4));
@@ -2192,9 +2191,8 @@ class LowerMatrixIntrinsics {
21922191
}
21932192

21942193
/// Lowers llvm.matrix.transpose.
2195-
MatrixTy LowerTranspose(CallInst *Inst) {
2194+
MatrixTy LowerTranspose(CallInst *Inst, IRBuilder<> &Builder) {
21962195
MatrixTy Result;
2197-
IRBuilder<> Builder(Inst);
21982196
Value *InputVal = Inst->getArgOperand(0);
21992197
FixedVectorType *VectorTy = cast<FixedVectorType>(InputVal->getType());
22002198
ShapeInfo ArgShape(Inst->getArgOperand(1), Inst->getArgOperand(2));
@@ -2230,13 +2228,15 @@ class LowerMatrixIntrinsics {
22302228
MatrixTy VisitLoad(LoadInst *Inst, const ShapeInfo &SI, Value *Ptr,
22312229
IRBuilder<> &Builder) {
22322230
return LowerLoad(Inst, Ptr, Inst->getAlign(),
2233-
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
2231+
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI,
2232+
Builder);
22342233
}
22352234

22362235
MatrixTy VisitStore(StoreInst *Inst, const ShapeInfo &SI, Value *StoredVal,
22372236
Value *Ptr, IRBuilder<> &Builder) {
22382237
return LowerStore(Inst, StoredVal, Ptr, Inst->getAlign(),
2239-
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI);
2238+
Builder.getInt64(SI.getStride()), Inst->isVolatile(), SI,
2239+
Builder);
22402240
}
22412241

22422242
/// Lower binary operators.

0 commit comments

Comments
 (0)