@@ -24,7 +24,18 @@ template <typename FN>
24
24
static void genCharacterSearch (FN func, fir::FirOpBuilder &builder,
25
25
mlir::Location loc, mlir::Value resultBox,
26
26
mlir::Value string1Box, mlir::Value string2Box,
27
- mlir::Value backBox, mlir::Value kind);
27
+ mlir::Value backBox, mlir::Value kind) {
28
+
29
+ auto fTy = func.getType ();
30
+ auto sourceFile = fir::factory::locationToFilename (builder, loc);
31
+ auto sourceLine =
32
+ fir::factory::locationToLineNo (builder, loc, fTy .getInput (6 ));
33
+
34
+ auto args = fir::runtime::createArguments (builder, loc, fTy , resultBox,
35
+ string1Box, string2Box, backBox,
36
+ kind, sourceFile, sourceLine);
37
+ builder.create <fir::CallOp>(loc, func, args);
38
+ }
28
39
29
40
// / Helper function to recover the KIND from the FIR type.
30
41
static int discoverKind (mlir::Type ty) {
@@ -45,31 +56,37 @@ static int discoverKind(mlir::Type ty) {
45
56
// Lower character operations
46
57
// ===----------------------------------------------------------------------===//
47
58
59
+ // / Generate a call to the `ADJUST[L|R]` runtime.
60
+ // /
61
+ // / \p resultBox must be an unallocated allocatable used for the temporary
62
+ // / result. \p StringBox must be a fir.box describing the adjustr string
63
+ // / argument. The \p adjustFunc should be a mlir::FuncOp for the appropriate
64
+ // / runtime entry function.
65
+ static void genAdjust (fir::FirOpBuilder &builder, mlir::Location loc,
66
+ mlir::Value resultBox, mlir::Value stringBox,
67
+ mlir::FuncOp &adjustFunc) {
68
+
69
+ auto fTy = adjustFunc.getType ();
70
+ auto sourceLine =
71
+ fir::factory::locationToLineNo (builder, loc, fTy .getInput (3 ));
72
+ auto sourceFile = fir::factory::locationToFilename (builder, loc);
73
+ auto args = fir::runtime::createArguments (builder, loc, fTy , resultBox,
74
+ stringBox, sourceFile, sourceLine);
75
+ builder.create <fir::CallOp>(loc, adjustFunc, args);
76
+ }
77
+
48
78
void fir::runtime::genAdjustL (fir::FirOpBuilder &builder, mlir::Location loc,
49
79
mlir::Value resultBox, mlir::Value stringBox) {
50
80
auto adjustFunc =
51
81
fir::runtime::getRuntimeFunc<mkRTKey (Adjustl)>(loc, builder);
52
- fir::runtime:: genAdjust (builder, loc, resultBox, stringBox, adjustFunc);
82
+ genAdjust (builder, loc, resultBox, stringBox, adjustFunc);
53
83
}
54
84
55
85
void fir::runtime::genAdjustR (fir::FirOpBuilder &builder, mlir::Location loc,
56
86
mlir::Value resultBox, mlir::Value stringBox) {
57
87
auto adjustFunc =
58
88
fir::runtime::getRuntimeFunc<mkRTKey (Adjustr)>(loc, builder);
59
- fir::runtime::genAdjust (builder, loc, resultBox, stringBox, adjustFunc);
60
- }
61
-
62
- void fir::runtime::genAdjust (fir::FirOpBuilder &builder, mlir::Location loc,
63
- mlir::Value resultBox, mlir::Value stringBox,
64
- mlir::FuncOp &adjustFunc) {
65
-
66
- auto fTy = adjustFunc.getType ();
67
- auto sourceLine =
68
- fir::factory::locationToLineNo (builder, loc, fTy .getInput (3 ));
69
- auto sourceFile = fir::factory::locationToFilename (builder, loc);
70
- auto args = fir::runtime::createArguments (builder, loc, fTy , resultBox,
71
- stringBox, sourceFile, sourceLine);
72
- builder.create <fir::CallOp>(loc, adjustFunc, args);
89
+ genAdjust (builder, loc, resultBox, stringBox, adjustFunc);
73
90
}
74
91
75
92
mlir::Value
@@ -112,7 +129,8 @@ mlir::Value fir::runtime::genCharCompare(fir::FirOpBuilder &builder,
112
129
auto allocateIfNotInMemory = [&](mlir::Value base) -> mlir::Value {
113
130
if (fir::isa_ref_type (base.getType ()))
114
131
return base;
115
- auto mem = builder.create <fir::AllocaOp>(loc, base.getType (), /* pinned=*/ false );
132
+ auto mem =
133
+ builder.create <fir::AllocaOp>(loc, base.getType (), /* pinned=*/ false );
116
134
builder.create <fir::StoreOp>(loc, base, mem);
117
135
return mem;
118
136
};
@@ -187,9 +205,6 @@ void fir::runtime::genTrim(fir::FirOpBuilder &builder, mlir::Location loc,
187
205
builder.create <fir::CallOp>(loc, trimFunc, args);
188
206
}
189
207
190
- // / Generate call to scan runtime routine.
191
- // / This calls the descriptor based runtime call implementation of the scan
192
- // / intrinsic.
193
208
void fir::runtime::genScanDescriptor (fir::FirOpBuilder &builder,
194
209
mlir::Location loc, mlir::Value resultBox,
195
210
mlir::Value stringBox, mlir::Value setBox,
@@ -199,9 +214,6 @@ void fir::runtime::genScanDescriptor(fir::FirOpBuilder &builder,
199
214
kind);
200
215
}
201
216
202
- // / Generate call to scan runtime routine that is specialized on
203
- // / \param kind.
204
- // / The \param kind represents the kind of the elements in the strings.
205
217
mlir::Value fir::runtime::genScan (fir::FirOpBuilder &builder,
206
218
mlir::Location loc, int kind,
207
219
mlir::Value stringBase, mlir::Value stringLen,
@@ -228,9 +240,6 @@ mlir::Value fir::runtime::genScan(fir::FirOpBuilder &builder,
228
240
return builder.create <fir::CallOp>(loc, func, args).getResult (0 );
229
241
}
230
242
231
- // / Generate call to verify runtime routine.
232
- // / This calls the descriptor based runtime call implementation of the
233
- // / verify intrinsic.
234
243
void fir::runtime::genVerifyDescriptor (fir::FirOpBuilder &builder,
235
244
mlir::Location loc,
236
245
mlir::Value resultBox,
@@ -242,9 +251,6 @@ void fir::runtime::genVerifyDescriptor(fir::FirOpBuilder &builder,
242
251
kind);
243
252
}
244
253
245
- // / Generate call to verify runtime routine that is specialized on
246
- // / \param kind.
247
- // / The \param kind represents the kind of the elements in the strings.
248
254
mlir::Value fir::runtime::genVerify (fir::FirOpBuilder &builder,
249
255
mlir::Location loc, int kind,
250
256
mlir::Value stringBase,
@@ -270,23 +276,3 @@ mlir::Value fir::runtime::genVerify(fir::FirOpBuilder &builder,
270
276
stringLen, setBase, setLen, back);
271
277
return builder.create <fir::CallOp>(loc, func, args).getResult (0 );
272
278
}
273
-
274
- // / Generate calls to string handling intrinsics such as index, scan, and
275
- // / verify. These are the descriptor based implementations that take four
276
- // / arguments (string1, string2, back, kind).
277
- template <typename FN>
278
- static void genCharacterSearch (FN func, fir::FirOpBuilder &builder,
279
- mlir::Location loc, mlir::Value resultBox,
280
- mlir::Value string1Box, mlir::Value string2Box,
281
- mlir::Value backBox, mlir::Value kind) {
282
-
283
- auto fTy = func.getType ();
284
- auto sourceFile = fir::factory::locationToFilename (builder, loc);
285
- auto sourceLine =
286
- fir::factory::locationToLineNo (builder, loc, fTy .getInput (6 ));
287
-
288
- auto args = fir::runtime::createArguments (builder, loc, fTy , resultBox,
289
- string1Box, string2Box, backBox,
290
- kind, sourceFile, sourceLine);
291
- builder.create <fir::CallOp>(loc, func, args);
292
- }
0 commit comments