OpenMPOpt.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- IPO/OpenMPOpt.h - Collection of OpenMP optimizations -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TRANSFORMS_IPO_OPENMPOPT_H
  14. #define LLVM_TRANSFORMS_IPO_OPENMPOPT_H
  15. #include "llvm/Analysis/CGSCCPassManager.h"
  16. #include "llvm/Analysis/LazyCallGraph.h"
  17. #include "llvm/IR/PassManager.h"
  18. namespace llvm {
  19. namespace omp {
  20. /// Summary of a kernel (=entry point for target offloading).
  21. using Kernel = Function *;
  22. /// Set of kernels in the module
  23. using KernelSet = SetVector<Kernel>;
  24. /// Helper to determine if \p M contains OpenMP.
  25. bool containsOpenMP(Module &M);
  26. /// Helper to determine if \p M is a OpenMP target offloading device module.
  27. bool isOpenMPDevice(Module &M);
  28. /// Get OpenMP device kernels in \p M.
  29. KernelSet getDeviceKernels(Module &M);
  30. } // namespace omp
  31. /// OpenMP optimizations pass.
  32. class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
  33. public:
  34. OpenMPOptPass() : LTOPhase(ThinOrFullLTOPhase::None) {}
  35. OpenMPOptPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
  36. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  37. private:
  38. const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
  39. };
  40. class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> {
  41. public:
  42. OpenMPOptCGSCCPass() : LTOPhase(ThinOrFullLTOPhase::None) {}
  43. OpenMPOptCGSCCPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
  44. PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
  45. LazyCallGraph &CG, CGSCCUpdateResult &UR);
  46. private:
  47. const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
  48. };
  49. } // end namespace llvm
  50. #endif // LLVM_TRANSFORMS_IPO_OPENMPOPT_H
  51. #ifdef __GNUC__
  52. #pragma GCC diagnostic pop
  53. #endif