Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:40

0001 //===- IPO/OpenMPOpt.h - Collection of OpenMP optimizations -----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_TRANSFORMS_IPO_OPENMPOPT_H
0010 #define LLVM_TRANSFORMS_IPO_OPENMPOPT_H
0011 
0012 #include "llvm/Analysis/CGSCCPassManager.h"
0013 #include "llvm/Analysis/LazyCallGraph.h"
0014 #include "llvm/IR/PassManager.h"
0015 
0016 namespace llvm {
0017 
0018 namespace omp {
0019 
0020 /// Summary of a kernel (=entry point for target offloading).
0021 using Kernel = Function *;
0022 
0023 /// Set of kernels in the module
0024 using KernelSet = SetVector<Kernel>;
0025 
0026 /// Helper to determine if \p M contains OpenMP.
0027 bool containsOpenMP(Module &M);
0028 
0029 /// Helper to determine if \p M is a OpenMP target offloading device module.
0030 bool isOpenMPDevice(Module &M);
0031 
0032 /// Return true iff \p Fn is an OpenMP GPU kernel; \p Fn has the "kernel"
0033 /// attribute.
0034 bool isOpenMPKernel(Function &Fn);
0035 
0036 /// Get OpenMP device kernels in \p M.
0037 KernelSet getDeviceKernels(Module &M);
0038 
0039 } // namespace omp
0040 
0041 /// OpenMP optimizations pass.
0042 class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
0043 public:
0044   OpenMPOptPass() = default;
0045   OpenMPOptPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
0046 
0047   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
0048 
0049 private:
0050   const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
0051 };
0052 
0053 class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> {
0054 public:
0055   OpenMPOptCGSCCPass() = default;
0056   OpenMPOptCGSCCPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
0057 
0058   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
0059                         LazyCallGraph &CG, CGSCCUpdateResult &UR);
0060 
0061 private:
0062   const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
0063 };
0064 
0065 } // end namespace llvm
0066 
0067 #endif // LLVM_TRANSFORMS_IPO_OPENMPOPT_H