1 //===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // A set of parameters used to control the transforms in the SimplifyCFG pass.
10 // Options may change depending on the position in the optimization pipeline.
11 // For example, canonical form that includes switches and branches may later be
12 // replaced by lookup tables and selects.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
17 #define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H
21 class AssumptionCache;
23 struct SimplifyCFGOptions {
24 int BonusInstThreshold = 1;
25 bool ForwardSwitchCondToPhi = false;
26 bool ConvertSwitchRangeToICmp = false;
27 bool ConvertSwitchToLookupTable = false;
28 bool NeedCanonicalLoop = true;
29 bool HoistCommonInsts = false;
30 bool SinkCommonInsts = false;
31 bool SimplifyCondBranch = true;
32 bool SpeculateBlocks = true;
34 AssumptionCache *AC = nullptr;
36 // Support 'builder' pattern to set members by name at construction time.
37 SimplifyCFGOptions &bonusInstThreshold(int I) {
38 BonusInstThreshold = I;
41 SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) {
42 ForwardSwitchCondToPhi = B;
45 SimplifyCFGOptions &convertSwitchRangeToICmp(bool B) {
46 ConvertSwitchRangeToICmp = B;
49 SimplifyCFGOptions &convertSwitchToLookupTable(bool B) {
50 ConvertSwitchToLookupTable = B;
53 SimplifyCFGOptions &needCanonicalLoops(bool B) {
54 NeedCanonicalLoop = B;
57 SimplifyCFGOptions &hoistCommonInsts(bool B) {
61 SimplifyCFGOptions &sinkCommonInsts(bool B) {
65 SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) {
69 SimplifyCFGOptions &setSimplifyCondBranch(bool B) {
70 SimplifyCondBranch = B;
74 SimplifyCFGOptions &speculateBlocks(bool B) {
82 #endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H