1 //===-- OpenMP.cpp -- Open MP directive lowering --------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/ 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "flang/Lower/OpenMP.h" 14 #include "flang/Lower/Bridge.h" 15 #include "flang/Lower/FIRBuilder.h" 16 #include "flang/Lower/PFTBuilder.h" 17 #include "flang/Parser/parse-tree.h" 18 #include "mlir/Dialect/OpenMP/OpenMPDialect.h" 19 #include "llvm/Frontend/OpenMP/OMPConstants.h" 20 21 #define TODO() llvm_unreachable("not yet implemented") 22 23 static void genOMP(Fortran::lower::AbstractConverter &absConv, 24 Fortran::lower::pft::Evaluation &eval, 25 const Fortran::parser::OpenMPSimpleStandaloneConstruct 26 &simpleStandaloneConstruct) { 27 const auto &directive = 28 std::get<Fortran::parser::OmpSimpleStandaloneDirective>( 29 simpleStandaloneConstruct.t); 30 switch (directive.v) { 31 default: 32 break; 33 case llvm::omp::Directive::OMPD_barrier: 34 absConv.getFirOpBuilder().create<mlir::omp::BarrierOp>( 35 absConv.getCurrentLocation()); 36 break; 37 case llvm::omp::Directive::OMPD_taskwait: 38 absConv.getFirOpBuilder().create<mlir::omp::TaskwaitOp>( 39 absConv.getCurrentLocation()); 40 break; 41 case llvm::omp::Directive::OMPD_taskyield: 42 TODO(); 43 case llvm::omp::Directive::OMPD_target_enter_data: 44 TODO(); 45 case llvm::omp::Directive::OMPD_target_exit_data: 46 TODO(); 47 case llvm::omp::Directive::OMPD_target_update: 48 TODO(); 49 case llvm::omp::Directive::OMPD_ordered: 50 TODO(); 51 } 52 } 53 54 static void 55 genOMP(Fortran::lower::AbstractConverter &absConv, 56 Fortran::lower::pft::Evaluation &eval, 57 const Fortran::parser::OpenMPStandaloneConstruct &standaloneConstruct) { 58 std::visit( 59 Fortran::common::visitors{ 60 [&](const Fortran::parser::OpenMPSimpleStandaloneConstruct 61 &simpleStandaloneConstruct) { 62 genOMP(absConv, eval, simpleStandaloneConstruct); 63 }, 64 [&](const Fortran::parser::OpenMPFlushConstruct &flushConstruct) { 65 TODO(); 66 }, 67 [&](const Fortran::parser::OpenMPCancelConstruct &cancelConstruct) { 68 TODO(); 69 }, 70 [&](const Fortran::parser::OpenMPCancellationPointConstruct 71 &cancellationPointConstruct) { TODO(); }, 72 }, 73 standaloneConstruct.u); 74 } 75 76 void Fortran::lower::genOpenMPConstruct( 77 Fortran::lower::AbstractConverter &absConv, 78 Fortran::lower::pft::Evaluation &eval, 79 const Fortran::parser::OpenMPConstruct &ompConstruct) { 80 81 std::visit( 82 common::visitors{ 83 [&](const Fortran::parser::OpenMPStandaloneConstruct 84 &standaloneConstruct) { 85 genOMP(absConv, eval, standaloneConstruct); 86 }, 87 [&](const Fortran::parser::OpenMPSectionsConstruct 88 §ionsConstruct) { TODO(); }, 89 [&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) { 90 TODO(); 91 }, 92 [&](const Fortran::parser::OpenMPBlockConstruct &blockConstruct) { 93 TODO(); 94 }, 95 [&](const Fortran::parser::OpenMPAtomicConstruct &atomicConstruct) { 96 TODO(); 97 }, 98 [&](const Fortran::parser::OpenMPCriticalConstruct 99 &criticalConstruct) { TODO(); }, 100 }, 101 ompConstruct.u); 102 } 103 104 void Fortran::lower::genOpenMPEndLoop( 105 Fortran::lower::AbstractConverter &, Fortran::lower::pft::Evaluation &, 106 const Fortran::parser::OmpEndLoopDirective &) { 107 TODO(); 108 } 109