SCCP.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- SCCP.h - 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. // This pass implements interprocedural sparse conditional constant
  15. // 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_IPO_SCCP_H
  25. #define LLVM_TRANSFORMS_IPO_SCCP_H
  26. #include "llvm/IR/PassManager.h"
  27. namespace llvm {
  28. class Module;
  29. /// A set of parameters to control various transforms performed by IPSCCP pass.
  30. /// Each of the boolean parameters can be set to:
  31. /// true - enabling the transformation.
  32. /// false - disabling the transformation.
  33. /// Intended use is to create a default object, modify parameters with
  34. /// additional setters and then pass it to IPSCCP.
  35. struct IPSCCPOptions {
  36. bool AllowFuncSpec;
  37. IPSCCPOptions(bool AllowFuncSpec = true) : AllowFuncSpec(AllowFuncSpec) {}
  38. /// Enables or disables Specialization of Functions.
  39. IPSCCPOptions &setFuncSpec(bool FuncSpec) {
  40. AllowFuncSpec = FuncSpec;
  41. return *this;
  42. }
  43. };
  44. /// Pass to perform interprocedural constant propagation.
  45. class IPSCCPPass : public PassInfoMixin<IPSCCPPass> {
  46. IPSCCPOptions Options;
  47. public:
  48. IPSCCPPass() = default;
  49. IPSCCPPass(IPSCCPOptions Options) : Options(Options) {}
  50. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  51. bool isFuncSpecEnabled() const { return Options.AllowFuncSpec; }
  52. };
  53. } // end namespace llvm
  54. #endif // LLVM_TRANSFORMS_IPO_SCCP_H
  55. #ifdef __GNUC__
  56. #pragma GCC diagnostic pop
  57. #endif