SCCP.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- SCCP.cpp - Sparse Conditional Constant Propagation -------*- 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. // This file implements sparse conditional constant propagation and merging:
  16. //
  17. // Specifically, this:
  18. // * Assumes values are constant unless proven otherwise
  19. // * Assumes BasicBlocks are dead unless proven otherwise
  20. // * Proves values to be constant, and replaces them with constants
  21. // * Proves conditional branches to be unconditional
  22. //
  23. //===----------------------------------------------------------------------===//
  24. #ifndef LLVM_TRANSFORMS_SCALAR_SCCP_H
  25. #define LLVM_TRANSFORMS_SCALAR_SCCP_H
  26. #include "llvm/ADT/STLExtras.h"
  27. #include "llvm/Analysis/TargetLibraryInfo.h"
  28. #include "llvm/Analysis/TargetTransformInfo.h"
  29. #include "llvm/IR/DataLayout.h"
  30. #include "llvm/IR/Function.h"
  31. #include "llvm/IR/Module.h"
  32. #include "llvm/IR/PassManager.h"
  33. #include "llvm/Transforms/Utils/PredicateInfo.h"
  34. #include "llvm/Transforms/Utils/SCCPSolver.h"
  35. namespace llvm {
  36. /// This pass performs function-level constant propagation and merging.
  37. class SCCPPass : public PassInfoMixin<SCCPPass> {
  38. public:
  39. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  40. };
  41. bool runIPSCCP(Module &M, const DataLayout &DL,
  42. std::function<const TargetLibraryInfo &(Function &)> GetTLI,
  43. function_ref<AnalysisResultsForFn(Function &)> getAnalysis);
  44. bool runFunctionSpecialization(
  45. Module &M, const DataLayout &DL,
  46. std::function<TargetLibraryInfo &(Function &)> GetTLI,
  47. std::function<TargetTransformInfo &(Function &)> GetTTI,
  48. std::function<AssumptionCache &(Function &)> GetAC,
  49. function_ref<AnalysisResultsForFn(Function &)> GetAnalysis);
  50. } // end namespace llvm
  51. #endif // LLVM_TRANSFORMS_SCALAR_SCCP_H
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif