@@ -132,10 +132,9 @@ static inline void genOmpAccAtomicCaptureStatement(
132
132
mlir::Value toAddress,
133
133
[[maybe_unused]] const AtomicListT *leftHandClauseList,
134
134
[[maybe_unused]] const AtomicListT *rightHandClauseList,
135
- mlir::Type elementType) {
135
+ mlir::Type elementType, mlir::Location loc ) {
136
136
// Generate `atomic.read` operation for atomic assigment statements
137
137
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
138
- mlir::Location currentLocation = converter.getCurrentLocation ();
139
138
140
139
if constexpr (std::is_same<AtomicListT,
141
140
Fortran::parser::OmpAtomicClauseList>()) {
@@ -151,12 +150,11 @@ static inline void genOmpAccAtomicCaptureStatement(
151
150
genOmpAtomicHintAndMemoryOrderClauses (converter, *rightHandClauseList,
152
151
hint, memoryOrder);
153
152
firOpBuilder.create <mlir::omp::AtomicReadOp>(
154
- currentLocation , fromAddress, toAddress,
155
- mlir::TypeAttr::get (elementType), hint, memoryOrder);
153
+ loc , fromAddress, toAddress, mlir::TypeAttr::get (elementType), hint ,
154
+ memoryOrder);
156
155
} else {
157
156
firOpBuilder.create <mlir::acc::AtomicReadOp>(
158
- currentLocation, fromAddress, toAddress,
159
- mlir::TypeAttr::get (elementType));
157
+ loc, fromAddress, toAddress, mlir::TypeAttr::get (elementType));
160
158
}
161
159
}
162
160
@@ -166,11 +164,10 @@ template <typename AtomicListT>
166
164
static inline void genOmpAccAtomicWriteStatement (
167
165
Fortran::lower::AbstractConverter &converter, mlir::Value lhsAddr,
168
166
mlir::Value rhsExpr, [[maybe_unused]] const AtomicListT *leftHandClauseList,
169
- [[maybe_unused]] const AtomicListT *rightHandClauseList,
167
+ [[maybe_unused]] const AtomicListT *rightHandClauseList, mlir::Location loc,
170
168
mlir::Value *evaluatedExprValue = nullptr ) {
171
169
// Generate `atomic.write` operation for atomic assignment statements
172
170
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
173
- mlir::Location currentLocation = converter.getCurrentLocation ();
174
171
175
172
if constexpr (std::is_same<AtomicListT,
176
173
Fortran::parser::OmpAtomicClauseList>()) {
@@ -184,11 +181,10 @@ static inline void genOmpAccAtomicWriteStatement(
184
181
if (rightHandClauseList)
185
182
genOmpAtomicHintAndMemoryOrderClauses (converter, *rightHandClauseList,
186
183
hint, memoryOrder);
187
- firOpBuilder.create <mlir::omp::AtomicWriteOp>(currentLocation , lhsAddr,
188
- rhsExpr, hint, memoryOrder);
184
+ firOpBuilder.create <mlir::omp::AtomicWriteOp>(loc , lhsAddr, rhsExpr, hint ,
185
+ memoryOrder);
189
186
} else {
190
- firOpBuilder.create <mlir::acc::AtomicWriteOp>(currentLocation, lhsAddr,
191
- rhsExpr);
187
+ firOpBuilder.create <mlir::acc::AtomicWriteOp>(loc, lhsAddr, rhsExpr);
192
188
}
193
189
}
194
190
@@ -200,7 +196,7 @@ static inline void genOmpAccAtomicUpdateStatement(
200
196
mlir::Type varType, const Fortran::parser::Variable &assignmentStmtVariable,
201
197
const Fortran::parser::Expr &assignmentStmtExpr,
202
198
[[maybe_unused]] const AtomicListT *leftHandClauseList,
203
- [[maybe_unused]] const AtomicListT *rightHandClauseList,
199
+ [[maybe_unused]] const AtomicListT *rightHandClauseList, mlir::Location loc,
204
200
mlir::Operation *atomicCaptureOp = nullptr ) {
205
201
// Generate `atomic.update` operation for atomic assignment statements
206
202
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
@@ -302,7 +298,7 @@ static inline void genOmpAccAtomicUpdateStatement(
302
298
// / Processes an atomic construct with write clause.
303
299
template <typename AtomicT, typename AtomicListT>
304
300
void genOmpAccAtomicWrite (Fortran::lower::AbstractConverter &converter,
305
- const AtomicT &atomicWrite) {
301
+ const AtomicT &atomicWrite, mlir::Location loc ) {
306
302
const AtomicListT *rightHandClauseList = nullptr ;
307
303
const AtomicListT *leftHandClauseList = nullptr ;
308
304
if constexpr (std::is_same<AtomicListT,
@@ -324,13 +320,13 @@ void genOmpAccAtomicWrite(Fortran::lower::AbstractConverter &converter,
324
320
mlir::Value lhsAddr =
325
321
fir::getBase (converter.genExprAddr (assign.lhs , stmtCtx));
326
322
genOmpAccAtomicWriteStatement (converter, lhsAddr, rhsExpr, leftHandClauseList,
327
- rightHandClauseList);
323
+ rightHandClauseList, loc );
328
324
}
329
325
330
326
// / Processes an atomic construct with read clause.
331
327
template <typename AtomicT, typename AtomicListT>
332
328
void genOmpAccAtomicRead (Fortran::lower::AbstractConverter &converter,
333
- const AtomicT &atomicRead) {
329
+ const AtomicT &atomicRead, mlir::Location loc ) {
334
330
const AtomicListT *rightHandClauseList = nullptr ;
335
331
const AtomicListT *leftHandClauseList = nullptr ;
336
332
if constexpr (std::is_same<AtomicListT,
@@ -357,20 +353,19 @@ void genOmpAccAtomicRead(Fortran::lower::AbstractConverter &converter,
357
353
fir::getBase (converter.genExprAddr (fromExpr, stmtCtx));
358
354
mlir::Value toAddress = fir::getBase (converter.genExprAddr (
359
355
*Fortran::semantics::GetExpr (assignmentStmtVariable), stmtCtx));
360
- mlir::Location loc = converter.getCurrentLocation ();
361
356
fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
362
357
if (fromAddress.getType () != toAddress.getType ())
363
358
fromAddress =
364
359
builder.create <fir::ConvertOp>(loc, toAddress.getType (), fromAddress);
365
360
genOmpAccAtomicCaptureStatement (converter, fromAddress, toAddress,
366
361
leftHandClauseList, rightHandClauseList,
367
- elementType);
362
+ elementType, loc );
368
363
}
369
364
370
365
// / Processes an atomic construct with update clause.
371
366
template <typename AtomicT, typename AtomicListT>
372
367
void genOmpAccAtomicUpdate (Fortran::lower::AbstractConverter &converter,
373
- const AtomicT &atomicUpdate) {
368
+ const AtomicT &atomicUpdate, mlir::Location loc ) {
374
369
const AtomicListT *rightHandClauseList = nullptr ;
375
370
const AtomicListT *leftHandClauseList = nullptr ;
376
371
if constexpr (std::is_same<AtomicListT,
@@ -395,13 +390,13 @@ void genOmpAccAtomicUpdate(Fortran::lower::AbstractConverter &converter,
395
390
mlir::Type varType = fir::unwrapRefType (lhsAddr.getType ());
396
391
genOmpAccAtomicUpdateStatement<AtomicListT>(
397
392
converter, lhsAddr, varType, assignmentStmtVariable, assignmentStmtExpr,
398
- leftHandClauseList, rightHandClauseList);
393
+ leftHandClauseList, rightHandClauseList, loc );
399
394
}
400
395
401
396
// / Processes an atomic construct with no clause - which implies update clause.
402
397
template <typename AtomicT, typename AtomicListT>
403
398
void genOmpAtomic (Fortran::lower::AbstractConverter &converter,
404
- const AtomicT &atomicConstruct) {
399
+ const AtomicT &atomicConstruct, mlir::Location loc ) {
405
400
const AtomicListT &atomicClauseList =
406
401
std::get<AtomicListT>(atomicConstruct.t );
407
402
const auto &assignmentStmtExpr = std::get<Fortran::parser::Expr>(
@@ -420,15 +415,14 @@ void genOmpAtomic(Fortran::lower::AbstractConverter &converter,
420
415
// the update clause is specified (for both OpenMP and OpenACC).
421
416
genOmpAccAtomicUpdateStatement<AtomicListT>(
422
417
converter, lhsAddr, varType, assignmentStmtVariable, assignmentStmtExpr,
423
- &atomicClauseList, nullptr );
418
+ &atomicClauseList, nullptr , loc );
424
419
}
425
420
426
421
// / Processes an atomic construct with capture clause.
427
422
template <typename AtomicT, typename AtomicListT>
428
423
void genOmpAccAtomicCapture (Fortran::lower::AbstractConverter &converter,
429
- const AtomicT &atomicCapture) {
424
+ const AtomicT &atomicCapture, mlir::Location loc ) {
430
425
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
431
- mlir::Location currentLocation = converter.getCurrentLocation ();
432
426
433
427
const Fortran::parser::AssignmentStmt &stmt1 =
434
428
std::get<typename AtomicT::Stmt1>(atomicCapture.t ).v .statement ;
@@ -480,11 +474,10 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
480
474
memoryOrder);
481
475
genOmpAtomicHintAndMemoryOrderClauses (converter, rightHandClauseList, hint,
482
476
memoryOrder);
483
- atomicCaptureOp = firOpBuilder.create <mlir::omp::AtomicCaptureOp>(
484
- currentLocation, hint, memoryOrder);
485
- } else {
486
477
atomicCaptureOp =
487
- firOpBuilder.create <mlir::acc::AtomicCaptureOp>(currentLocation);
478
+ firOpBuilder.create <mlir::omp::AtomicCaptureOp>(loc, hint, memoryOrder);
479
+ } else {
480
+ atomicCaptureOp = firOpBuilder.create <mlir::acc::AtomicCaptureOp>(loc);
488
481
}
489
482
490
483
firOpBuilder.createBlock (&(atomicCaptureOp->getRegion (0 )));
@@ -499,11 +492,11 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
499
492
genOmpAccAtomicCaptureStatement<AtomicListT>(
500
493
converter, stmt1RHSArg, stmt1LHSArg,
501
494
/* leftHandClauseList=*/ nullptr ,
502
- /* rightHandClauseList=*/ nullptr , elementType);
495
+ /* rightHandClauseList=*/ nullptr , elementType, loc );
503
496
genOmpAccAtomicUpdateStatement<AtomicListT>(
504
497
converter, stmt1RHSArg, stmt2VarType, stmt2Var, stmt2Expr,
505
498
/* leftHandClauseList=*/ nullptr ,
506
- /* rightHandClauseList=*/ nullptr , atomicCaptureOp);
499
+ /* rightHandClauseList=*/ nullptr , loc, atomicCaptureOp);
507
500
} else {
508
501
// Atomic capture construct is of the form [capture-stmt, write-stmt]
509
502
const Fortran::semantics::SomeExpr &fromExpr =
@@ -512,11 +505,11 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
512
505
genOmpAccAtomicCaptureStatement<AtomicListT>(
513
506
converter, stmt1RHSArg, stmt1LHSArg,
514
507
/* leftHandClauseList=*/ nullptr ,
515
- /* rightHandClauseList=*/ nullptr , elementType);
508
+ /* rightHandClauseList=*/ nullptr , elementType, loc );
516
509
genOmpAccAtomicWriteStatement<AtomicListT>(
517
510
converter, stmt1RHSArg, stmt2RHSArg,
518
511
/* leftHandClauseList=*/ nullptr ,
519
- /* rightHandClauseList=*/ nullptr );
512
+ /* rightHandClauseList=*/ nullptr , loc );
520
513
}
521
514
} else {
522
515
// Atomic capture construct is of the form [update-stmt, capture-stmt]
@@ -527,19 +520,19 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
527
520
genOmpAccAtomicCaptureStatement<AtomicListT>(
528
521
converter, stmt1LHSArg, stmt2LHSArg,
529
522
/* leftHandClauseList=*/ nullptr ,
530
- /* rightHandClauseList=*/ nullptr , elementType);
523
+ /* rightHandClauseList=*/ nullptr , elementType, loc );
531
524
firOpBuilder.setInsertionPointToStart (&block);
532
525
genOmpAccAtomicUpdateStatement<AtomicListT>(
533
526
converter, stmt1LHSArg, stmt1VarType, stmt1Var, stmt1Expr,
534
527
/* leftHandClauseList=*/ nullptr ,
535
- /* rightHandClauseList=*/ nullptr , atomicCaptureOp);
528
+ /* rightHandClauseList=*/ nullptr , loc, atomicCaptureOp);
536
529
}
537
530
firOpBuilder.setInsertionPointToEnd (&block);
538
531
if constexpr (std::is_same<AtomicListT,
539
532
Fortran::parser::OmpAtomicClauseList>()) {
540
- firOpBuilder.create <mlir::omp::TerminatorOp>(currentLocation );
533
+ firOpBuilder.create <mlir::omp::TerminatorOp>(loc );
541
534
} else {
542
- firOpBuilder.create <mlir::acc::TerminatorOp>(currentLocation );
535
+ firOpBuilder.create <mlir::acc::TerminatorOp>(loc );
543
536
}
544
537
firOpBuilder.setInsertionPointToStart (&block);
545
538
}
0 commit comments