Skip to content

Commit 951f40a

Browse files
authored
[flang][NFC] Update flang/unittests to the new create APIs (#152056)
While I was updating the creation of CUF operation in #152050, I noticed some other places in flang that were not updated. This patch updates the FIR operation creations in `flang/unittests`
1 parent 314e825 commit 951f40a

File tree

9 files changed

+101
-101
lines changed

9 files changed

+101
-101
lines changed

flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ TEST_F(RuntimeCallTest, genMoveAlloc) {
1717
mlir::Location loc = firBuilder->getUnknownLoc();
1818
mlir::Type seqTy =
1919
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
20-
mlir::Value from = firBuilder->create<fir::UndefOp>(loc, seqTy);
21-
mlir::Value to = firBuilder->create<fir::UndefOp>(loc, seqTy);
22-
mlir::Value errMsg = firBuilder->create<fir::UndefOp>(loc, seqTy);
20+
mlir::Value from = fir::UndefOp::create(*firBuilder, loc, seqTy);
21+
mlir::Value to = fir::UndefOp::create(*firBuilder, loc, seqTy);
22+
mlir::Value errMsg = fir::UndefOp::create(*firBuilder, loc, seqTy);
2323
mlir::Value hasStat = firBuilder->createBool(loc, false);
2424
fir::runtime::genMoveAlloc(*firBuilder, loc, to, from, hasStat, errMsg);
2525
checkCallOpFromResultBox(to, "_FortranAMoveAlloc", 5);

flang/unittests/Optimizer/Builder/Runtime/AssignTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ TEST_F(RuntimeCallTest, genDerivedTypeAssign) {
1414
auto loc = firBuilder->getUnknownLoc();
1515
mlir::Type seqTy =
1616
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
17-
mlir::Value source = firBuilder->create<fir::UndefOp>(loc, seqTy);
18-
mlir::Value dest = firBuilder->create<fir::UndefOp>(loc, seqTy);
17+
mlir::Value source = fir::UndefOp::create(*firBuilder, loc, seqTy);
18+
mlir::Value dest = fir::UndefOp::create(*firBuilder, loc, seqTy);
1919
fir::runtime::genAssign(*firBuilder, loc, dest, source);
2020
checkCallOpFromResultBox(dest, "_FortranAAssign", 2);
2121
}

flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ using namespace mlir;
1515

1616
TEST_F(RuntimeCallTest, genAdjustLTest) {
1717
auto loc = firBuilder->getUnknownLoc();
18-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, boxTy);
19-
mlir::Value string = firBuilder->create<fir::UndefOp>(loc, boxTy);
18+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, boxTy);
19+
mlir::Value string = fir::UndefOp::create(*firBuilder, loc, boxTy);
2020
fir::runtime::genAdjustL(*firBuilder, loc, result, string);
2121
checkCallOpFromResultBox(result, "_FortranAAdjustl", 2);
2222
}
2323

2424
TEST_F(RuntimeCallTest, genAdjustRTest) {
2525
auto loc = firBuilder->getUnknownLoc();
26-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, boxTy);
27-
mlir::Value string = firBuilder->create<fir::UndefOp>(loc, boxTy);
26+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, boxTy);
27+
mlir::Value string = fir::UndefOp::create(*firBuilder, loc, boxTy);
2828
fir::runtime::genAdjustR(*firBuilder, loc, result, string);
2929
checkCallOpFromResultBox(result, "_FortranAAdjustr", 2);
3030
}
@@ -115,40 +115,40 @@ TEST_F(RuntimeCallTest, genIndexTest) {
115115

116116
TEST_F(RuntimeCallTest, genIndexDescriptorTest) {
117117
auto loc = firBuilder->getUnknownLoc();
118-
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
119-
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
120-
mlir::Value substringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
121-
mlir::Value backOpt = firBuilder->create<fir::UndefOp>(loc, boxTy);
122-
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
118+
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
119+
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
120+
mlir::Value substringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
121+
mlir::Value backOpt = fir::UndefOp::create(*firBuilder, loc, boxTy);
122+
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
123123
fir::runtime::genIndexDescriptor(
124124
*firBuilder, loc, resultBox, stringBox, substringBox, backOpt, kind);
125125
checkCallOpFromResultBox(resultBox, "_FortranAIndex", 5);
126126
}
127127

128128
TEST_F(RuntimeCallTest, genRepeatTest) {
129129
auto loc = firBuilder->getUnknownLoc();
130-
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
131-
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
132-
mlir::Value ncopies = firBuilder->create<fir::UndefOp>(loc, i32Ty);
130+
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
131+
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
132+
mlir::Value ncopies = fir::UndefOp::create(*firBuilder, loc, i32Ty);
133133
fir::runtime::genRepeat(*firBuilder, loc, resultBox, stringBox, ncopies);
134134
checkCallOpFromResultBox(resultBox, "_FortranARepeat", 3);
135135
}
136136

137137
TEST_F(RuntimeCallTest, genTrimTest) {
138138
auto loc = firBuilder->getUnknownLoc();
139-
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
140-
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
139+
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
140+
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
141141
fir::runtime::genTrim(*firBuilder, loc, resultBox, stringBox);
142142
checkCallOpFromResultBox(resultBox, "_FortranATrim", 2);
143143
}
144144

145145
TEST_F(RuntimeCallTest, genScanDescriptorTest) {
146146
auto loc = firBuilder->getUnknownLoc();
147-
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
148-
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
149-
mlir::Value setBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
150-
mlir::Value backBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
151-
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
147+
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
148+
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
149+
mlir::Value setBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
150+
mlir::Value backBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
151+
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
152152
fir::runtime::genScanDescriptor(
153153
*firBuilder, loc, resultBox, stringBox, setBox, backBox, kind);
154154
checkCallOpFromResultBox(resultBox, "_FortranAScan", 5);
@@ -178,11 +178,11 @@ TEST_F(RuntimeCallTest, genScanTest) {
178178

179179
TEST_F(RuntimeCallTest, genVerifyDescriptorTest) {
180180
auto loc = firBuilder->getUnknownLoc();
181-
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
182-
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
183-
mlir::Value setBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
184-
mlir::Value backBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
185-
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
181+
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
182+
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
183+
mlir::Value setBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
184+
mlir::Value backBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
185+
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
186186
fir::runtime::genVerifyDescriptor(
187187
*firBuilder, loc, resultBox, stringBox, setBox, backBox, kind);
188188
checkCallOpFromResultBox(resultBox, "_FortranAVerify", 5);

flang/unittests/Optimizer/Builder/Runtime/CommandTest.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ TEST_F(RuntimeCallTest, genGetCommandArgument) {
2121
mlir::Location loc = firBuilder->getUnknownLoc();
2222
mlir::Type intTy = firBuilder->getDefaultIntegerType();
2323
mlir::Type boxTy = fir::BoxType::get(firBuilder->getNoneType());
24-
mlir::Value number = firBuilder->create<fir::UndefOp>(loc, intTy);
25-
mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
26-
mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
27-
mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
24+
mlir::Value number = fir::UndefOp::create(*firBuilder, loc, intTy);
25+
mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);
26+
mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);
27+
mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);
2828
mlir::Value result = fir::runtime::genGetCommandArgument(
2929
*firBuilder, loc, number, value, length, errmsg);
3030
checkCallOp(result.getDefiningOp(), "_FortranAGetCommandArgument",
@@ -34,11 +34,11 @@ TEST_F(RuntimeCallTest, genGetCommandArgument) {
3434

3535
TEST_F(RuntimeCallTest, genGetEnvVariable) {
3636
mlir::Location loc = firBuilder->getUnknownLoc();
37-
mlir::Value name = firBuilder->create<fir::UndefOp>(loc, boxTy);
38-
mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
39-
mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
40-
mlir::Value trimName = firBuilder->create<fir::UndefOp>(loc, i1Ty);
41-
mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
37+
mlir::Value name = fir::UndefOp::create(*firBuilder, loc, boxTy);
38+
mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);
39+
mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);
40+
mlir::Value trimName = fir::UndefOp::create(*firBuilder, loc, i1Ty);
41+
mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);
4242
mlir::Value result = fir::runtime::genGetEnvVariable(
4343
*firBuilder, loc, name, value, length, trimName, errmsg);
4444
checkCallOp(result.getDefiningOp(), "_FortranAGetEnvVariable", /*nbArgs=*/5,

flang/unittests/Optimizer/Builder/Runtime/DerivedTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TEST_F(RuntimeCallTest, genDerivedTypeInitialize) {
1414
auto loc = firBuilder->getUnknownLoc();
1515
mlir::Type seqTy =
1616
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
17-
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy);
17+
mlir::Value box = fir::UndefOp::create(*firBuilder, loc, seqTy);
1818
fir::runtime::genDerivedTypeInitialize(*firBuilder, loc, box);
1919
checkCallOpFromResultBox(box, "_FortranAInitialize", 1);
2020
}
@@ -23,7 +23,7 @@ TEST_F(RuntimeCallTest, genDerivedTypeDestroy) {
2323
auto loc = firBuilder->getUnknownLoc();
2424
mlir::Type seqTy =
2525
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
26-
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy);
26+
mlir::Value box = fir::UndefOp::create(*firBuilder, loc, seqTy);
2727
fir::runtime::genDerivedTypeDestroy(*firBuilder, loc, box);
2828
checkCallOpFromResultBox(box, "_FortranADestroy", 1, /*addLocArg=*/false);
2929
}

flang/unittests/Optimizer/Builder/Runtime/RaggedTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TEST_F(RuntimeCallTest, genRaggedArrayAllocateTest) {
1414
auto loc = firBuilder->getUnknownLoc();
1515
mlir::TupleType headerTy =
1616
fir::factory::getRaggedArrayHeaderType(*firBuilder);
17-
mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
17+
mlir::Value header = fir::UndefOp::create(*firBuilder, loc, headerTy);
1818
mlir::Value eleSize = firBuilder->createIntegerConstant(loc, i32Ty, 1);
1919
mlir::Value extent = firBuilder->createIntegerConstant(loc, i32Ty, 1);
2020
// Use a dummy header just to test the correctness of the generated call.
@@ -29,7 +29,7 @@ TEST_F(RuntimeCallTest, genRaggedArrayDeallocateTest) {
2929
mlir::TupleType headerTy =
3030
fir::factory::getRaggedArrayHeaderType(*firBuilder);
3131
// Use a dummy header just to test the correctness of the generated call.
32-
mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
32+
mlir::Value header = fir::UndefOp::create(*firBuilder, loc, headerTy);
3333
fir::runtime::genRaggedArrayDeallocate(loc, *firBuilder, header);
3434
checkCallOpFromResultBox(
3535
header, "_FortranARaggedArrayDeallocate", 1, /*addLocArgs=*/false);

flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,50 @@
1212

1313
TEST_F(RuntimeCallTest, genAllTest) {
1414
mlir::Location loc = firBuilder->getUnknownLoc();
15-
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
15+
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
1616
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
1717
mlir::Value all = fir::runtime::genAll(*firBuilder, loc, undef, dim);
1818
checkCallOp(all.getDefiningOp(), "_FortranAAll", 2);
1919
}
2020

2121
TEST_F(RuntimeCallTest, genAllDescriptorTest) {
2222
mlir::Location loc = firBuilder->getUnknownLoc();
23-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
24-
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
23+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
24+
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
2525
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
2626
fir::runtime::genAllDescriptor(*firBuilder, loc, result, mask, dim);
2727
checkCallOpFromResultBox(result, "_FortranAAllDim", 3);
2828
}
2929

3030
TEST_F(RuntimeCallTest, genAnyTest) {
3131
mlir::Location loc = firBuilder->getUnknownLoc();
32-
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
32+
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
3333
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
3434
mlir::Value any = fir::runtime::genAny(*firBuilder, loc, undef, dim);
3535
checkCallOp(any.getDefiningOp(), "_FortranAAny", 2);
3636
}
3737

3838
TEST_F(RuntimeCallTest, genAnyDescriptorTest) {
3939
mlir::Location loc = firBuilder->getUnknownLoc();
40-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
41-
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
40+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
41+
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
4242
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
4343
fir::runtime::genAnyDescriptor(*firBuilder, loc, result, mask, dim);
4444
checkCallOpFromResultBox(result, "_FortranAAnyDim", 3);
4545
}
4646

4747
TEST_F(RuntimeCallTest, genCountTest) {
4848
mlir::Location loc = firBuilder->getUnknownLoc();
49-
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
49+
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
5050
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
5151
mlir::Value count = fir::runtime::genCount(*firBuilder, loc, undef, dim);
5252
checkCallOp(count.getDefiningOp(), "_FortranACount", 2);
5353
}
5454

5555
TEST_F(RuntimeCallTest, genCountDimTest) {
5656
mlir::Location loc = firBuilder->getUnknownLoc();
57-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
58-
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
57+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
58+
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
5959
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
6060
mlir::Value kind = firBuilder->createIntegerConstant(loc, i32Ty, 1);
6161
fir::runtime::genCountDim(*firBuilder, loc, result, mask, dim, kind);
@@ -114,16 +114,16 @@ TEST_F(RuntimeCallTest, genMinValTest) {
114114

115115
TEST_F(RuntimeCallTest, genParityTest) {
116116
mlir::Location loc = firBuilder->getUnknownLoc();
117-
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
117+
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
118118
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
119119
mlir::Value parity = fir::runtime::genParity(*firBuilder, loc, undef, dim);
120120
checkCallOp(parity.getDefiningOp(), "_FortranAParity", 2);
121121
}
122122

123123
TEST_F(RuntimeCallTest, genParityDescriptorTest) {
124124
mlir::Location loc = firBuilder->getUnknownLoc();
125-
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
126-
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
125+
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
126+
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
127127
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
128128
fir::runtime::genParityDescriptor(*firBuilder, loc, result, mask, dim);
129129
checkCallOpFromResultBox(result, "_FortranAParityDim", 3);

0 commit comments

Comments
 (0)