@@ -138,12 +138,10 @@ static void genRuntimeSetBounds(fir::FirOpBuilder &builder, mlir::Location loc,
138
138
builder)
139
139
: fir::runtime::getRuntimeFunc<mkRTKey (AllocatableSetBounds)>(
140
140
loc, builder);
141
- llvm::SmallVector<mlir::Value> args{box.getAddr (), dimIndex, lowerBound,
142
- upperBound};
143
- llvm::SmallVector<mlir::Value> operands;
144
- for (auto [fst, snd] : llvm::zip (args, callee.getFunctionType ().getInputs ()))
145
- operands.emplace_back (builder.createConvert (loc, snd, fst));
146
- builder.create <fir::CallOp>(loc, callee, operands);
141
+ const auto args = fir::runtime::createArguments (
142
+ builder, loc, callee.getFunctionType (), box.getAddr (), dimIndex,
143
+ lowerBound, upperBound);
144
+ builder.create <fir::CallOp>(loc, callee, args);
147
145
}
148
146
149
147
// / Generate runtime call to set the lengths of a character allocatable or
@@ -162,9 +160,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
162
160
if (inputTypes.size () != 5 )
163
161
fir::emitFatalError (
164
162
loc, " AllocatableInitCharacter runtime interface not as expected" );
165
- llvm::SmallVector<mlir::Value> args;
166
- args.push_back (builder.createConvert (loc, inputTypes[0 ], box.getAddr ()));
167
- args.push_back (builder.createConvert (loc, inputTypes[1 ], len));
163
+ llvm::SmallVector<mlir::Value> args = {box.getAddr (), len};
168
164
if (kind == 0 )
169
165
kind = mlir::cast<fir::CharacterType>(box.getEleTy ()).getFKind ();
170
166
args.push_back (builder.createIntegerConstant (loc, inputTypes[2 ], kind));
@@ -173,7 +169,9 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
173
169
// TODO: coarrays
174
170
int corank = 0 ;
175
171
args.push_back (builder.createIntegerConstant (loc, inputTypes[4 ], corank));
176
- builder.create <fir::CallOp>(loc, callee, args);
172
+ const auto convertedArgs = fir::runtime::createArguments (
173
+ builder, loc, callee.getFunctionType (), args);
174
+ builder.create <fir::CallOp>(loc, callee, convertedArgs);
177
175
}
178
176
179
177
// / Generate a sequence of runtime calls to allocate memory.
@@ -194,10 +192,9 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
194
192
args.push_back (errorManager.errMsgAddr );
195
193
args.push_back (errorManager.sourceFile );
196
194
args.push_back (errorManager.sourceLine );
197
- llvm::SmallVector<mlir::Value> operands;
198
- for (auto [fst, snd] : llvm::zip (args, callee.getFunctionType ().getInputs ()))
199
- operands.emplace_back (builder.createConvert (loc, snd, fst));
200
- return builder.create <fir::CallOp>(loc, callee, operands).getResult (0 );
195
+ const auto convertedArgs = fir::runtime::createArguments (
196
+ builder, loc, callee.getFunctionType (), args);
197
+ return builder.create <fir::CallOp>(loc, callee, convertedArgs).getResult (0 );
201
198
}
202
199
203
200
// / Generate a sequence of runtime calls to allocate memory and assign with the
@@ -213,14 +210,11 @@ static mlir::Value genRuntimeAllocateSource(fir::FirOpBuilder &builder,
213
210
loc, builder)
214
211
: fir::runtime::getRuntimeFunc<mkRTKey (AllocatableAllocateSource)>(
215
212
loc, builder);
216
- llvm::SmallVector<mlir::Value> args{
217
- box.getAddr (), fir::getBase (source),
218
- errorManager.hasStat , errorManager.errMsgAddr ,
219
- errorManager.sourceFile , errorManager.sourceLine };
220
- llvm::SmallVector<mlir::Value> operands;
221
- for (auto [fst, snd] : llvm::zip (args, callee.getFunctionType ().getInputs ()))
222
- operands.emplace_back (builder.createConvert (loc, snd, fst));
223
- return builder.create <fir::CallOp>(loc, callee, operands).getResult (0 );
213
+ const auto args = fir::runtime::createArguments (
214
+ builder, loc, callee.getFunctionType (), box.getAddr (),
215
+ fir::getBase (source), errorManager.hasStat , errorManager.errMsgAddr ,
216
+ errorManager.sourceFile , errorManager.sourceLine );
217
+ return builder.create <fir::CallOp>(loc, callee, args).getResult (0 );
224
218
}
225
219
226
220
// / Generate runtime call to apply mold to the descriptor.
@@ -234,14 +228,12 @@ static void genRuntimeAllocateApplyMold(fir::FirOpBuilder &builder,
234
228
builder)
235
229
: fir::runtime::getRuntimeFunc<mkRTKey (AllocatableApplyMold)>(
236
230
loc, builder);
237
- llvm::SmallVector<mlir::Value> args{
231
+ const auto args = fir::runtime::createArguments (
232
+ builder, loc, callee.getFunctionType (),
238
233
fir::factory::getMutableIRBox (builder, loc, box), fir::getBase (mold),
239
234
builder.createIntegerConstant (
240
- loc, callee.getFunctionType ().getInputs ()[2 ], rank)};
241
- llvm::SmallVector<mlir::Value> operands;
242
- for (auto [fst, snd] : llvm::zip (args, callee.getFunctionType ().getInputs ()))
243
- operands.emplace_back (builder.createConvert (loc, snd, fst));
244
- builder.create <fir::CallOp>(loc, callee, operands);
235
+ loc, callee.getFunctionType ().getInputs ()[2 ], rank));
236
+ builder.create <fir::CallOp>(loc, callee, args);
245
237
}
246
238
247
239
// / Generate a runtime call to deallocate memory.
@@ -669,15 +661,13 @@ class AllocateStmtHelper {
669
661
670
662
llvm::ArrayRef<mlir::Type> inputTypes =
671
663
callee.getFunctionType ().getInputs ();
672
- llvm::SmallVector<mlir::Value> args;
673
- args.push_back (builder.createConvert (loc, inputTypes[0 ], box.getAddr ()));
674
- args.push_back (builder.createConvert (loc, inputTypes[1 ], typeDescAddr));
675
664
mlir::Value rankValue =
676
665
builder.createIntegerConstant (loc, inputTypes[2 ], rank);
677
666
mlir::Value corankValue =
678
667
builder.createIntegerConstant (loc, inputTypes[3 ], corank);
679
- args.push_back (rankValue);
680
- args.push_back (corankValue);
668
+ const auto args = fir::runtime::createArguments (
669
+ builder, loc, callee.getFunctionType (), box.getAddr (), typeDescAddr,
670
+ rankValue, corankValue);
681
671
builder.create <fir::CallOp>(loc, callee, args);
682
672
}
683
673
@@ -696,8 +686,6 @@ class AllocateStmtHelper {
696
686
697
687
llvm::ArrayRef<mlir::Type> inputTypes =
698
688
callee.getFunctionType ().getInputs ();
699
- llvm::SmallVector<mlir::Value> args;
700
- args.push_back (builder.createConvert (loc, inputTypes[0 ], box.getAddr ()));
701
689
mlir::Value categoryValue = builder.createIntegerConstant (
702
690
loc, inputTypes[1 ], static_cast <int32_t >(category));
703
691
mlir::Value kindValue =
@@ -706,10 +694,9 @@ class AllocateStmtHelper {
706
694
builder.createIntegerConstant (loc, inputTypes[3 ], rank);
707
695
mlir::Value corankValue =
708
696
builder.createIntegerConstant (loc, inputTypes[4 ], corank);
709
- args.push_back (categoryValue);
710
- args.push_back (kindValue);
711
- args.push_back (rankValue);
712
- args.push_back (corankValue);
697
+ const auto args = fir::runtime::createArguments (
698
+ builder, loc, callee.getFunctionType (), box.getAddr (), categoryValue,
699
+ kindValue, rankValue, corankValue);
713
700
builder.create <fir::CallOp>(loc, callee, args);
714
701
}
715
702
0 commit comments