Skip to content

Commit ff5784b

Browse files
authored
[flang][OpenMP] Move extractOmpDirective to Utils.cpp, NFC (#148653)
1 parent d35931c commit ff5784b

File tree

3 files changed

+87
-84
lines changed

3 files changed

+87
-84
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -372,90 +372,6 @@ extractMappedBaseValues(llvm::ArrayRef<mlir::Value> vars,
372372
});
373373
}
374374

375-
/// Get the directive enumeration value corresponding to the given OpenMP
376-
/// construct PFT node.
377-
llvm::omp::Directive
378-
extractOmpDirective(const parser::OpenMPConstruct &ompConstruct) {
379-
return common::visit(
380-
common::visitors{
381-
[](const parser::OpenMPAllocatorsConstruct &c) {
382-
return llvm::omp::OMPD_allocators;
383-
},
384-
[](const parser::OpenMPAssumeConstruct &c) {
385-
return llvm::omp::OMPD_assume;
386-
},
387-
[](const parser::OpenMPAtomicConstruct &c) {
388-
return llvm::omp::OMPD_atomic;
389-
},
390-
[](const parser::OpenMPBlockConstruct &c) {
391-
return std::get<parser::OmpBlockDirective>(
392-
std::get<parser::OmpBeginBlockDirective>(c.t).t)
393-
.v;
394-
},
395-
[](const parser::OpenMPCriticalConstruct &c) {
396-
return llvm::omp::OMPD_critical;
397-
},
398-
[](const parser::OpenMPDeclarativeAllocate &c) {
399-
return llvm::omp::OMPD_allocate;
400-
},
401-
[](const parser::OpenMPDispatchConstruct &c) {
402-
return llvm::omp::OMPD_dispatch;
403-
},
404-
[](const parser::OpenMPExecutableAllocate &c) {
405-
return llvm::omp::OMPD_allocate;
406-
},
407-
[](const parser::OpenMPLoopConstruct &c) {
408-
return std::get<parser::OmpLoopDirective>(
409-
std::get<parser::OmpBeginLoopDirective>(c.t).t)
410-
.v;
411-
},
412-
[](const parser::OpenMPSectionConstruct &c) {
413-
return llvm::omp::OMPD_section;
414-
},
415-
[](const parser::OpenMPSectionsConstruct &c) {
416-
return std::get<parser::OmpSectionsDirective>(
417-
std::get<parser::OmpBeginSectionsDirective>(c.t).t)
418-
.v;
419-
},
420-
[](const parser::OpenMPStandaloneConstruct &c) {
421-
return common::visit(
422-
common::visitors{
423-
[](const parser::OpenMPSimpleStandaloneConstruct &c) {
424-
return c.v.DirId();
425-
},
426-
[](const parser::OpenMPFlushConstruct &c) {
427-
return llvm::omp::OMPD_flush;
428-
},
429-
[](const parser::OpenMPCancelConstruct &c) {
430-
return llvm::omp::OMPD_cancel;
431-
},
432-
[](const parser::OpenMPCancellationPointConstruct &c) {
433-
return llvm::omp::OMPD_cancellation_point;
434-
},
435-
[](const parser::OmpMetadirectiveDirective &c) {
436-
return llvm::omp::OMPD_metadirective;
437-
},
438-
[](const parser::OpenMPDepobjConstruct &c) {
439-
return llvm::omp::OMPD_depobj;
440-
},
441-
[](const parser::OpenMPInteropConstruct &c) {
442-
return llvm::omp::OMPD_interop;
443-
}},
444-
c.u);
445-
},
446-
[](const parser::OpenMPUtilityConstruct &c) {
447-
return common::visit(
448-
common::visitors{[](const parser::OmpErrorDirective &c) {
449-
return llvm::omp::OMPD_error;
450-
},
451-
[](const parser::OmpNothingDirective &c) {
452-
return llvm::omp::OMPD_nothing;
453-
}},
454-
c.u);
455-
}},
456-
ompConstruct.u);
457-
}
458-
459375
/// Populate the global \see hostEvalInfo after processing clauses for the given
460376
/// \p eval OpenMP target construct, or nested constructs, if these must be
461377
/// evaluated outside of the target region per the spec.

flang/lib/Lower/OpenMP/Utils.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,90 @@ bool collectLoopRelatedInfo(
661661

662662
return found;
663663
}
664+
665+
/// Get the directive enumeration value corresponding to the given OpenMP
666+
/// construct PFT node.
667+
llvm::omp::Directive
668+
extractOmpDirective(const parser::OpenMPConstruct &ompConstruct) {
669+
return common::visit(
670+
common::visitors{
671+
[](const parser::OpenMPAllocatorsConstruct &c) {
672+
return llvm::omp::OMPD_allocators;
673+
},
674+
[](const parser::OpenMPAssumeConstruct &c) {
675+
return llvm::omp::OMPD_assume;
676+
},
677+
[](const parser::OpenMPAtomicConstruct &c) {
678+
return llvm::omp::OMPD_atomic;
679+
},
680+
[](const parser::OpenMPBlockConstruct &c) {
681+
return std::get<parser::OmpBlockDirective>(
682+
std::get<parser::OmpBeginBlockDirective>(c.t).t)
683+
.v;
684+
},
685+
[](const parser::OpenMPCriticalConstruct &c) {
686+
return llvm::omp::OMPD_critical;
687+
},
688+
[](const parser::OpenMPDeclarativeAllocate &c) {
689+
return llvm::omp::OMPD_allocate;
690+
},
691+
[](const parser::OpenMPDispatchConstruct &c) {
692+
return llvm::omp::OMPD_dispatch;
693+
},
694+
[](const parser::OpenMPExecutableAllocate &c) {
695+
return llvm::omp::OMPD_allocate;
696+
},
697+
[](const parser::OpenMPLoopConstruct &c) {
698+
return std::get<parser::OmpLoopDirective>(
699+
std::get<parser::OmpBeginLoopDirective>(c.t).t)
700+
.v;
701+
},
702+
[](const parser::OpenMPSectionConstruct &c) {
703+
return llvm::omp::OMPD_section;
704+
},
705+
[](const parser::OpenMPSectionsConstruct &c) {
706+
return std::get<parser::OmpSectionsDirective>(
707+
std::get<parser::OmpBeginSectionsDirective>(c.t).t)
708+
.v;
709+
},
710+
[](const parser::OpenMPStandaloneConstruct &c) {
711+
return common::visit(
712+
common::visitors{
713+
[](const parser::OpenMPSimpleStandaloneConstruct &c) {
714+
return c.v.DirId();
715+
},
716+
[](const parser::OpenMPFlushConstruct &c) {
717+
return llvm::omp::OMPD_flush;
718+
},
719+
[](const parser::OpenMPCancelConstruct &c) {
720+
return llvm::omp::OMPD_cancel;
721+
},
722+
[](const parser::OpenMPCancellationPointConstruct &c) {
723+
return llvm::omp::OMPD_cancellation_point;
724+
},
725+
[](const parser::OmpMetadirectiveDirective &c) {
726+
return llvm::omp::OMPD_metadirective;
727+
},
728+
[](const parser::OpenMPDepobjConstruct &c) {
729+
return llvm::omp::OMPD_depobj;
730+
},
731+
[](const parser::OpenMPInteropConstruct &c) {
732+
return llvm::omp::OMPD_interop;
733+
}},
734+
c.u);
735+
},
736+
[](const parser::OpenMPUtilityConstruct &c) {
737+
return common::visit(
738+
common::visitors{[](const parser::OmpErrorDirective &c) {
739+
return llvm::omp::OMPD_error;
740+
},
741+
[](const parser::OmpNothingDirective &c) {
742+
return llvm::omp::OMPD_nothing;
743+
}},
744+
c.u);
745+
}},
746+
ompConstruct.u);
747+
}
664748
} // namespace omp
665749
} // namespace lower
666750
} // namespace Fortran

flang/lib/Lower/OpenMP/Utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ bool collectLoopRelatedInfo(
166166
lower::pft::Evaluation &eval, const omp::List<omp::Clause> &clauses,
167167
mlir::omp::LoopRelatedClauseOps &result,
168168
llvm::SmallVectorImpl<const semantics::Symbol *> &iv);
169+
170+
llvm::omp::Directive
171+
extractOmpDirective(const parser::OpenMPConstruct &ompConstruct);
169172
} // namespace omp
170173
} // namespace lower
171174
} // namespace Fortran

0 commit comments

Comments
 (0)