Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- 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 // A set of parameters used to control the transforms in the SimplifyCFG pass.
0010 // Options may change depending on the position in the optimization pipeline.
0011 // For example, canonical form that includes switches and branches may later be
0012 // replaced by lookup tables and selects.
0013 //
0014 //===----------------------------------------------------------------------===//
0015 
0016 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
0017 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
0018 
0019 namespace llvm {
0020 
0021 class AssumptionCache;
0022 
0023 struct SimplifyCFGOptions {
0024   int BonusInstThreshold = 1;
0025   bool ForwardSwitchCondToPhi = false;
0026   bool ConvertSwitchRangeToICmp = false;
0027   bool ConvertSwitchToLookupTable = false;
0028   bool NeedCanonicalLoop = true;
0029   bool HoistCommonInsts = false;
0030   bool HoistLoadsStoresWithCondFaulting = false;
0031   bool SinkCommonInsts = false;
0032   bool SimplifyCondBranch = true;
0033   bool SpeculateBlocks = true;
0034   bool SpeculateUnpredictables = false;
0035 
0036   AssumptionCache *AC = nullptr;
0037 
0038   // Support 'builder' pattern to set members by name at construction time.
0039   SimplifyCFGOptions &bonusInstThreshold(int I) {
0040     BonusInstThreshold = I;
0041     return *this;
0042   }
0043   SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) {
0044     ForwardSwitchCondToPhi = B;
0045     return *this;
0046   }
0047   SimplifyCFGOptions &convertSwitchRangeToICmp(bool B) {
0048     ConvertSwitchRangeToICmp = B;
0049     return *this;
0050   }
0051   SimplifyCFGOptions &convertSwitchToLookupTable(bool B) {
0052     ConvertSwitchToLookupTable = B;
0053     return *this;
0054   }
0055   SimplifyCFGOptions &needCanonicalLoops(bool B) {
0056     NeedCanonicalLoop = B;
0057     return *this;
0058   }
0059   SimplifyCFGOptions &hoistCommonInsts(bool B) {
0060     HoistCommonInsts = B;
0061     return *this;
0062   }
0063   SimplifyCFGOptions &hoistLoadsStoresWithCondFaulting(bool B) {
0064     HoistLoadsStoresWithCondFaulting = B;
0065     return *this;
0066   }
0067   SimplifyCFGOptions &sinkCommonInsts(bool B) {
0068     SinkCommonInsts = B;
0069     return *this;
0070   }
0071   SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) {
0072     AC = Cache;
0073     return *this;
0074   }
0075   SimplifyCFGOptions &setSimplifyCondBranch(bool B) {
0076     SimplifyCondBranch = B;
0077     return *this;
0078   }
0079 
0080   SimplifyCFGOptions &speculateBlocks(bool B) {
0081     SpeculateBlocks = B;
0082     return *this;
0083   }
0084   SimplifyCFGOptions &speculateUnpredictables(bool B) {
0085     SpeculateUnpredictables = B;
0086     return *this;
0087   }
0088 };
0089 
0090 } // namespace llvm
0091 
0092 #endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H