1 //===- IPO/OpenMPOpt.h - Collection of OpenMP optimizations -----*- C++ -*-===// 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 #ifndef LLVM_TRANSFORMS_IPO_OPENMPOPT_H 10 #define LLVM_TRANSFORMS_IPO_OPENMPOPT_H 11 12 #include "llvm/Analysis/CGSCCPassManager.h" 13 #include "llvm/Analysis/LazyCallGraph.h" 14 #include "llvm/IR/PassManager.h" 15 16 namespace llvm { 17 18 namespace omp { 19 20 /// Summary of a kernel (=entry point for target offloading). 21 using Kernel = Function *; 22 23 /// Set of kernels in the module 24 using KernelSet = SetVector<Kernel>; 25 26 /// Helper to determine if \p M contains OpenMP. 27 bool containsOpenMP(Module &M); 28 29 /// Helper to determine if \p M is a OpenMP target offloading device module. 30 bool isOpenMPDevice(Module &M); 31 32 /// Get OpenMP device kernels in \p M. 33 KernelSet getDeviceKernels(Module &M); 34 35 } // namespace omp 36 37 /// OpenMP optimizations pass. 38 class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> { 39 public: 40 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); 41 }; 42 43 class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> { 44 public: 45 PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, 46 LazyCallGraph &CG, CGSCCUpdateResult &UR); 47 }; 48 49 } // end namespace llvm 50 51 #endif // LLVM_TRANSFORMS_IPO_OPENMPOPT_H 52