UniformityAnalysis.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ConvergenceUtils.h -----------------------*- 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. //
  14. /// \file
  15. /// \brief Convergence info and convergence-aware uniform info for LLVM IR
  16. ///
  17. /// This differs from traditional divergence analysis by taking convergence
  18. /// intrinsics into account.
  19. //
  20. //===----------------------------------------------------------------------===//
  21. #ifndef LLVM_ANALYSIS_UNIFORMITYANALYSIS_H
  22. #define LLVM_ANALYSIS_UNIFORMITYANALYSIS_H
  23. #include "llvm/ADT/GenericUniformityInfo.h"
  24. #include "llvm/Analysis/CycleAnalysis.h"
  25. namespace llvm {
  26. extern template class GenericUniformityInfo<SSAContext>;
  27. using UniformityInfo = GenericUniformityInfo<SSAContext>;
  28. /// Analysis pass which computes \ref UniformityInfo.
  29. class UniformityInfoAnalysis
  30. : public AnalysisInfoMixin<UniformityInfoAnalysis> {
  31. friend AnalysisInfoMixin<UniformityInfoAnalysis>;
  32. static AnalysisKey Key;
  33. public:
  34. /// Provide the result typedef for this analysis pass.
  35. using Result = UniformityInfo;
  36. /// Run the analysis pass over a function and produce a dominator tree.
  37. UniformityInfo run(Function &F, FunctionAnalysisManager &);
  38. // TODO: verify analysis
  39. };
  40. /// Printer pass for the \c UniformityInfo.
  41. class UniformityInfoPrinterPass
  42. : public PassInfoMixin<UniformityInfoPrinterPass> {
  43. raw_ostream &OS;
  44. public:
  45. explicit UniformityInfoPrinterPass(raw_ostream &OS);
  46. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  47. };
  48. /// Legacy analysis pass which computes a \ref CycleInfo.
  49. class UniformityInfoWrapperPass : public FunctionPass {
  50. Function *m_function = nullptr;
  51. UniformityInfo m_uniformityInfo;
  52. public:
  53. static char ID;
  54. UniformityInfoWrapperPass();
  55. UniformityInfo &getUniformityInfo() { return m_uniformityInfo; }
  56. const UniformityInfo &getUniformityInfo() const { return m_uniformityInfo; }
  57. bool runOnFunction(Function &F) override;
  58. void getAnalysisUsage(AnalysisUsage &AU) const override;
  59. void releaseMemory() override;
  60. void print(raw_ostream &OS, const Module *M = nullptr) const override;
  61. // TODO: verify analysis
  62. };
  63. } // namespace llvm
  64. #endif // LLVM_ANALYSIS_UNIFORMITYANALYSIS_H
  65. #ifdef __GNUC__
  66. #pragma GCC diagnostic pop
  67. #endif