Skip to content

Commit 9fd5ec3

Browse files
committed
[NFC] Update based on review comments
> Moved to using a type-alias for the tuple > Made names a little more consistent and OpenMP specific
1 parent 68a5337 commit 9fd5ec3

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

flang/include/flang/Lower/OpenMP.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
#ifndef FORTRAN_LOWER_OPENMP_H
1414
#define FORTRAN_LOWER_OPENMP_H
1515

16+
#include "llvm/ADT/SmallVector.h"
17+
1618
#include <cinttypes>
1719
#include <utility>
1820

19-
#include "llvm/ADT/SmallVector.h"
20-
2121
namespace mlir {
2222
class Value;
2323
class Operation;
@@ -52,6 +52,11 @@ struct Evaluation;
5252
struct Variable;
5353
} // namespace pft
5454

55+
using OMPDeferredDeclTarInfo =
56+
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
57+
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
58+
Fortran::semantics::Symbol>;
59+
5560
// Generate the OpenMP terminator for Operation at Location.
5661
mlir::Operation *genOpenMPTerminator(fir::FirOpBuilder &, mlir::Operation *,
5762
mlir::Location);
@@ -89,19 +94,13 @@ bool isOpenMPDeviceDeclareTarget(Fortran::lower::AbstractConverter &,
8994
Fortran::semantics::SemanticsContext &,
9095
Fortran::lower::pft::Evaluation &,
9196
const parser::OpenMPDeclarativeConstruct &);
92-
void gatherDeferredDeclareTargets(
97+
void gatherOpenMPDeferredDeclareTargets(
9398
Fortran::lower::AbstractConverter &, Fortran::semantics::SemanticsContext &,
9499
Fortran::lower::pft::Evaluation &,
95100
const parser::OpenMPDeclarativeConstruct &,
96-
llvm::SmallVectorImpl<std::tuple<
97-
uint32_t /*mlir::omp::DeclareTargetCaptureClause*/, uint32_t,
98-
/*mlir::omp::DeclareTargetDeviceType*/ Fortran::semantics::Symbol>> &);
99-
bool markDelayedDeclareTargetFunctions(
100-
mlir::Operation *,
101-
llvm::SmallVectorImpl<
102-
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
103-
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
104-
Fortran::semantics::Symbol>> &,
101+
llvm::SmallVectorImpl<OMPDeferredDeclTarInfo> &);
102+
bool markOpenMPDeferredDeclareTargetFunctions(
103+
mlir::Operation *, llvm::SmallVectorImpl<OMPDeferredDeclTarInfo> &,
105104
AbstractConverter &);
106105
void genOpenMPRequires(mlir::Operation *, const Fortran::semantics::Symbol *);
107106

flang/lib/Lower/Bridge.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,9 +2472,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
24722472
ompDeviceCodeFound ||
24732473
Fortran::lower::isOpenMPDeviceDeclareTarget(
24742474
*this, bridge.getSemanticsContext(), getEval(), ompDecl);
2475-
Fortran::lower::gatherDeferredDeclareTargets(
2475+
Fortran::lower::gatherOpenMPDeferredDeclareTargets(
24762476
*this, bridge.getSemanticsContext(), getEval(), ompDecl,
2477-
deferredDeclareTarget);
2477+
ompDeferredDeclareTarget);
24782478
genOpenMPDeclarativeConstruct(
24792479
*this, localSymbols, bridge.getSemanticsContext(), getEval(), ompDecl);
24802480
builder->restoreInsertionPoint(insertPt);
@@ -5004,10 +5004,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
50045004
/// lowering.
50055005
void finalizeOpenMPLowering(
50065006
const Fortran::semantics::Symbol *globalOmpRequiresSymbol) {
5007-
if (!deferredDeclareTarget.empty()) {
5007+
if (!ompDeferredDeclareTarget.empty()) {
50085008
bool deferredDeviceFuncFound =
5009-
Fortran::lower::markDelayedDeclareTargetFunctions(
5010-
getModuleOp().getOperation(), deferredDeclareTarget, *this);
5009+
Fortran::lower::markOpenMPDeferredDeclareTargetFunctions(
5010+
getModuleOp().getOperation(), ompDeferredDeclareTarget, *this);
50115011
if (!ompDeviceCodeFound)
50125012
ompDeviceCodeFound = deferredDeviceFuncFound;
50135013
}
@@ -5072,12 +5072,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
50725072
/// processed at the time of lowering the declare target construct, such
50735073
/// as certain cases where interfaces are declared but not defined within
50745074
/// a module.
5075-
llvm::SmallVector<
5076-
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
5077-
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
5078-
Fortran::semantics::Symbol>,
5079-
2>
5080-
deferredDeclareTarget;
5075+
llvm::SmallVector<Fortran::lower::OMPDeferredDeclTarInfo, 2>
5076+
ompDeferredDeclareTarget;
50815077

50825078
const Fortran::lower::ExprToValueMap *exprValueOverrides{nullptr};
50835079

flang/lib/Lower/OpenMP.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,10 +3187,8 @@ static void insertDeferredDeclareTargets(
31873187
Fortran::semantics::SemanticsContext &semaCtx,
31883188
Fortran::lower::pft::Evaluation &eval,
31893189
const Fortran::parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
3190-
llvm::SmallVectorImpl<
3191-
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
3192-
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
3193-
Fortran::semantics::Symbol>> &deferredDeclareTarget) {
3190+
llvm::SmallVectorImpl<Fortran::lower::OMPDeferredDeclTarInfo>
3191+
&deferredDeclareTarget) {
31943192
llvm::SmallVector<DeclareTargetCapturePair, 0> symbolAndClause;
31953193
mlir::omp::DeclareTargetDeviceType devType = getDeclareTargetInfo(
31963194
converter, semaCtx, eval, declareTargetConstruct, symbolAndClause);
@@ -4485,15 +4483,12 @@ bool Fortran::lower::isOpenMPTargetConstruct(
44854483
return llvm::omp::allTargetSet.test(dir);
44864484
}
44874485

4488-
void Fortran::lower::gatherDeferredDeclareTargets(
4486+
void Fortran::lower::gatherOpenMPDeferredDeclareTargets(
44894487
Fortran::lower::AbstractConverter &converter,
44904488
Fortran::semantics::SemanticsContext &semaCtx,
44914489
Fortran::lower::pft::Evaluation &eval,
44924490
const Fortran::parser::OpenMPDeclarativeConstruct &ompDecl,
4493-
llvm::SmallVectorImpl<
4494-
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
4495-
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
4496-
Fortran::semantics::Symbol>> &deferredDeclareTarget) {
4491+
llvm::SmallVectorImpl<OMPDeferredDeclTarInfo> &deferredDeclareTarget) {
44974492
std::visit(
44984493
Fortran::common::visitors{
44994494
[&](const Fortran::parser::OpenMPDeclareTargetConstruct &ompReq) {
@@ -4531,12 +4526,9 @@ bool Fortran::lower::isOpenMPDeviceDeclareTarget(
45314526
// This function will also return true if we encounter any device declare
45324527
// target cases, to satisfy checking if we require the requires attributes
45334528
// on the module.
4534-
bool Fortran::lower::markDelayedDeclareTargetFunctions(
4529+
bool Fortran::lower::markOpenMPDeferredDeclareTargetFunctions(
45354530
mlir::Operation *mod,
4536-
llvm::SmallVectorImpl<
4537-
std::tuple<uint32_t /*mlir::omp::DeclareTargetCaptureClause*/,
4538-
uint32_t, /*mlir::omp::DeclareTargetDeviceType*/
4539-
Fortran::semantics::Symbol>> &deferredDeclareTargets,
4531+
llvm::SmallVectorImpl<OMPDeferredDeclTarInfo> &deferredDeclareTargets,
45404532
AbstractConverter &converter) {
45414533
bool deviceCodeFound = false;
45424534
if (auto modOp = llvm::dyn_cast<mlir::ModuleOp>(mod)) {

0 commit comments

Comments
 (0)