28
28
// mlir tuple (a struct) inside the host containing the addresses and properties
29
29
// of variables that are accessed by internal procedures. The address of this
30
30
// tuple is passed as an argument by the host when calling internal procedures.
31
- // Internal procedures are propagating this tuple address when calling other
31
+ // Internal procedures propagate a reference to this tuple when calling other
32
32
// internal procedures of the host.
33
33
//
34
34
// This file defines how the type of the host tuple is built, how the tuple
35
35
// value is created inside the host, and how the host associated variables are
36
36
// instantiated inside the internal procedures from the tuple value. The
37
- // CapturedXXX classes are defining each of these three actions for a specific
38
- // kind of variables by providing a `getType`, a `placeInTuple `, and a
37
+ // CapturedXXX classes define each of these three actions for a specific
38
+ // kind of variables by providing a `getType`, a `instantiateHostTuple `, and a
39
39
// `getFromTuple` method. These classes are structured as follow:
40
40
//
41
41
// class CapturedKindOfVar : public CapturedSymbols<CapturedKindOfVar> {
45
45
// static mlir::Type getType();
46
46
// // Build the tuple element value for a host associated variable given its
47
47
// // value inside the host. This is called when lowering the host body.
48
- // static void placeInTuple ();
48
+ // static void instantiateHostTuple ();
49
49
// // Instantiate a host variable inside an internal procedure given its
50
50
// // tuple element value. This is called when lowering internal procedure
51
51
// // bodies.
52
52
// static void getFromTuple();
53
53
// };
54
54
//
55
- // If a new kind of variables requires ad-hoc handling, a new CapturedXXX class
55
+ // If a new kind of variable requires ad-hoc handling, a new CapturedXXX class
56
56
// should be added to handle it, and `walkCaptureCategories` should be updated
57
57
// to dispatch this new kind of variable to this new class.
58
58
@@ -65,7 +65,7 @@ struct GetTypeInTuple {
65
65
66
66
// / Struct to be used as argument in walkCaptureCategories when building the
67
67
// / tuple element value for a host associated variable.
68
- struct PlaceInTuple {
68
+ struct InstantiateHostTuple {
69
69
// / walkCaptureCategories returns nothing.
70
70
using Result = void ;
71
71
// / Value of the variable inside the host procedure.
@@ -107,11 +107,11 @@ class CapturedSymbols {
107
107
const Fortran::lower::BoxAnalyzer &) {
108
108
return SymbolCategory::getType (converter, sym);
109
109
}
110
- static void visit (const PlaceInTuple &args,
110
+ static void visit (const InstantiateHostTuple &args,
111
111
Fortran::lower::AbstractConverter &converter,
112
112
const Fortran::semantics::Symbol &sym,
113
113
const Fortran::lower::BoxAnalyzer &) {
114
- return SymbolCategory::placeInTuple (args, converter, sym);
114
+ return SymbolCategory::instantiateHostTuple (args, converter, sym);
115
115
}
116
116
static void visit (const GetFromTuple &args,
117
117
Fortran::lower::AbstractConverter &converter,
@@ -131,9 +131,9 @@ class CapturedSimpleScalars : public CapturedSymbols<CapturedSimpleScalars> {
131
131
return fir::PointerType::get (converter.genType (sym));
132
132
}
133
133
134
- static void placeInTuple (const PlaceInTuple &args,
135
- Fortran::lower::AbstractConverter &converter,
136
- const Fortran::semantics::Symbol &) {
134
+ static void instantiateHostTuple (const InstantiateHostTuple &args,
135
+ Fortran::lower::AbstractConverter &converter,
136
+ const Fortran::semantics::Symbol &) {
137
137
auto &builder = converter.getFirOpBuilder ();
138
138
auto typeInTuple = fir::dyn_cast_ptrEleTy (args.addrInTuple .getType ());
139
139
assert (typeInTuple && " addrInTuple must be an address" );
@@ -165,9 +165,9 @@ class CapturedCharacterScalars
165
165
return fir::BoxCharType::get (&converter.getMLIRContext (), kind);
166
166
}
167
167
168
- static void placeInTuple (const PlaceInTuple &args,
169
- Fortran::lower::AbstractConverter &converter,
170
- const Fortran::semantics::Symbol &) {
168
+ static void instantiateHostTuple (const InstantiateHostTuple &args,
169
+ Fortran::lower::AbstractConverter &converter,
170
+ const Fortran::semantics::Symbol &) {
171
171
auto *charBox = args.hostValue .getCharBox ();
172
172
assert (charBox && " host value must be a fir::CharBoxValue" );
173
173
auto &builder = converter.getFirOpBuilder ();
@@ -206,9 +206,9 @@ class CapturedAllocatableAndPointer
206
206
const Fortran::semantics::Symbol &sym) {
207
207
return fir::ReferenceType::get (converter.genType (sym));
208
208
}
209
- static void placeInTuple (const PlaceInTuple &args,
210
- Fortran::lower::AbstractConverter &converter,
211
- const Fortran::semantics::Symbol &) {
209
+ static void instantiateHostTuple (const InstantiateHostTuple &args,
210
+ Fortran::lower::AbstractConverter &converter,
211
+ const Fortran::semantics::Symbol &) {
212
212
assert (args.hostValue .getBoxOf <fir::MutableBoxValue>() &&
213
213
" host value must be a fir::MutableBoxValue" );
214
214
auto &builder = converter.getFirOpBuilder ();
@@ -294,9 +294,9 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
294
294
return fir::BoxType::get (fir::PointerType::get (type));
295
295
}
296
296
297
- static void placeInTuple (const PlaceInTuple &args,
298
- Fortran::lower::AbstractConverter &converter,
299
- const Fortran::semantics::Symbol &sym) {
297
+ static void instantiateHostTuple (const InstantiateHostTuple &args,
298
+ Fortran::lower::AbstractConverter &converter,
299
+ const Fortran::semantics::Symbol &sym) {
300
300
auto &builder = converter.getFirOpBuilder ();
301
301
auto loc = args.loc ;
302
302
fir::MutableBoxValue boxInTuple (args.addrInTuple , {}, {});
@@ -312,16 +312,17 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
312
312
loc, builder.getI1Type (), fir::getBase (args.hostValue ));
313
313
builder.genIfThenElse (loc, isPresent)
314
314
.genThen ([&]() {
315
- Fortran::lower::associateMutableBoxWithShift (
316
- builder, loc, boxInTuple, args.hostValue , /* shift*/ llvm::None);
315
+ Fortran::lower::associateMutableBox (builder, loc, boxInTuple,
316
+ args.hostValue ,
317
+ /* lbounds=*/ llvm::None);
317
318
})
318
319
.genElse ([&]() {
319
320
Fortran::lower::disassociateMutableBox (builder, loc, boxInTuple);
320
321
})
321
322
.end ();
322
323
} else {
323
- Fortran::lower::associateMutableBoxWithShift (
324
- builder, loc, boxInTuple, args.hostValue , /* shift */ llvm::None);
324
+ Fortran::lower::associateMutableBox (
325
+ builder, loc, boxInTuple, args.hostValue , /* lbounds= */ llvm::None);
325
326
}
326
327
}
327
328
@@ -450,9 +451,9 @@ void Fortran::lower::HostAssociations::hostProcedureBindings(
450
451
auto off = builder.createIntegerConstant (loc, offTy, indexInTuple);
451
452
auto varTy = tupTy.getType (indexInTuple);
452
453
auto eleOff = genTupleCoor (builder, loc, varTy, hostTuple, off);
453
- PlaceInTuple placeInTuple{symMap. lookupSymbol (s. value ()). toExtendedValue (),
454
- eleOff, loc};
455
- walkCaptureCategories (placeInTuple , converter, *s.value ());
454
+ InstantiateHostTuple instantiateHostTuple{
455
+ symMap. lookupSymbol (s. value ()). toExtendedValue (), eleOff, loc};
456
+ walkCaptureCategories (instantiateHostTuple , converter, *s.value ());
456
457
}
457
458
458
459
converter.bindHostAssocTuple (hostTuple);
0 commit comments