Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- SCCP.h - Sparse Conditional Constant Propagation ---------*- 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 // This pass implements  interprocedural sparse conditional constant
0010 // propagation and merging.
0011 //
0012 // Specifically, this:
0013 //   * Assumes values are constant unless proven otherwise
0014 //   * Assumes BasicBlocks are dead unless proven otherwise
0015 //   * Proves values to be constant, and replaces them with constants
0016 //   * Proves conditional branches to be unconditional
0017 //
0018 //===----------------------------------------------------------------------===//
0019 
0020 #ifndef LLVM_TRANSFORMS_IPO_SCCP_H
0021 #define LLVM_TRANSFORMS_IPO_SCCP_H
0022 
0023 #include "llvm/IR/PassManager.h"
0024 
0025 namespace llvm {
0026 
0027 class Module;
0028 
0029 /// A set of parameters to control various transforms performed by IPSCCP pass.
0030 /// Each of the boolean parameters can be set to:
0031 ///   true - enabling the transformation.
0032 ///   false - disabling the transformation.
0033 /// Intended use is to create a default object, modify parameters with
0034 /// additional setters and then pass it to IPSCCP.
0035 struct IPSCCPOptions {
0036   bool AllowFuncSpec;
0037 
0038   IPSCCPOptions(bool AllowFuncSpec = true) : AllowFuncSpec(AllowFuncSpec) {}
0039 
0040   /// Enables or disables Specialization of Functions.
0041   IPSCCPOptions &setFuncSpec(bool FuncSpec) {
0042     AllowFuncSpec = FuncSpec;
0043     return *this;
0044   }
0045 };
0046 
0047 /// Pass to perform interprocedural constant propagation.
0048 class IPSCCPPass : public PassInfoMixin<IPSCCPPass> {
0049   IPSCCPOptions Options;
0050 
0051 public:
0052   IPSCCPPass() = default;
0053 
0054   IPSCCPPass(IPSCCPOptions Options) : Options(Options) {}
0055 
0056   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
0057 
0058   bool isFuncSpecEnabled() const { return Options.AllowFuncSpec; }
0059 };
0060 
0061 } // end namespace llvm
0062 
0063 #endif // LLVM_TRANSFORMS_IPO_SCCP_H