1 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This header file defines prototypes for accessor functions that expose passes 10 // in the Scalar transformations library. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_TRANSFORMS_SCALAR_H 15 #define LLVM_TRANSFORMS_SCALAR_H 16 17 #include "llvm/Transforms/Utils/SimplifyCFGOptions.h" 18 #include <functional> 19 20 namespace llvm { 21 22 class Function; 23 class FunctionPass; 24 class Pass; 25 26 //===----------------------------------------------------------------------===// 27 // 28 // DeadCodeElimination - This pass is more powerful than DeadInstElimination, 29 // because it is worklist driven that can potentially revisit instructions when 30 // their other instructions become dead, to eliminate chains of dead 31 // computations. 32 // 33 FunctionPass *createDeadCodeEliminationPass(); 34 35 //===----------------------------------------------------------------------===// 36 // 37 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values. 38 // 39 FunctionPass *createSROAPass(bool PreserveCFG = true); 40 41 //===----------------------------------------------------------------------===// 42 // 43 // LICM - This pass is a loop invariant code motion and memory promotion pass. 44 // 45 Pass *createLICMPass(); 46 47 //===----------------------------------------------------------------------===// 48 // 49 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use 50 // a loop's canonical induction variable as one of their indices. 51 // 52 Pass *createLoopStrengthReducePass(); 53 54 //===----------------------------------------------------------------------===// 55 // 56 // LoopUnroll - This pass is a simple loop unrolling pass. 57 // 58 Pass *createLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false, 59 bool ForgetAllSCEV = false, int Threshold = -1, 60 int Count = -1, int AllowPartial = -1, 61 int Runtime = -1, int UpperBound = -1, 62 int AllowPeeling = -1); 63 64 //===----------------------------------------------------------------------===// 65 // 66 // Reassociate - This pass reassociates commutative expressions in an order that 67 // is designed to promote better constant propagation, GCSE, LICM, PRE... 68 // 69 // For example: 4 + (x + 5) -> x + (4 + 5) 70 // 71 FunctionPass *createReassociatePass(); 72 73 //===----------------------------------------------------------------------===// 74 // 75 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks, 76 // simplify terminator instructions, convert switches to lookup tables, etc. 77 // 78 FunctionPass *createCFGSimplificationPass( 79 SimplifyCFGOptions Options = SimplifyCFGOptions(), 80 std::function<bool(const Function &)> Ftor = nullptr); 81 82 //===----------------------------------------------------------------------===// 83 // 84 // FlattenCFG - flatten CFG, reduce number of conditional branches by using 85 // parallel-and and parallel-or mode, etc... 86 // 87 FunctionPass *createFlattenCFGPass(); 88 89 //===----------------------------------------------------------------------===// 90 // 91 // CFG Structurization - Remove irreducible control flow 92 // 93 /// 94 /// When \p SkipUniformRegions is true the structizer will not structurize 95 /// regions that only contain uniform branches. 96 Pass *createStructurizeCFGPass(bool SkipUniformRegions = false); 97 98 //===----------------------------------------------------------------------===// 99 // 100 // TailCallElimination - This pass eliminates call instructions to the current 101 // function which occur immediately before return instructions. 102 // 103 FunctionPass *createTailCallEliminationPass(); 104 105 //===----------------------------------------------------------------------===// 106 // 107 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator 108 // tree. 109 // 110 FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false); 111 112 //===----------------------------------------------------------------------===// 113 // 114 // ConstantHoisting - This pass prepares a function for expensive constants. 115 // 116 FunctionPass *createConstantHoistingPass(); 117 118 //===----------------------------------------------------------------------===// 119 // 120 // Sink - Code Sinking 121 // 122 FunctionPass *createSinkingPass(); 123 124 //===----------------------------------------------------------------------===// 125 // 126 // LowerAtomic - Lower atomic intrinsics to non-atomic form 127 // 128 Pass *createLowerAtomicPass(); 129 130 //===----------------------------------------------------------------------===// 131 // 132 // MergeICmps - Merge integer comparison chains into a memcmp 133 // 134 Pass *createMergeICmpsLegacyPass(); 135 136 //===----------------------------------------------------------------------===// 137 // 138 // InferAddressSpaces - Modify users of addrspacecast instructions with values 139 // in the source address space if using the destination address space is slower 140 // on the target. If AddressSpace is left to its default value, it will be 141 // obtained from the TargetTransformInfo. 142 // 143 FunctionPass *createInferAddressSpacesPass(unsigned AddressSpace = ~0u); 144 extern char &InferAddressSpacesID; 145 146 //===----------------------------------------------------------------------===// 147 // 148 // TLSVariableHoist - This pass reduce duplicated TLS address call. 149 // 150 FunctionPass *createTLSVariableHoistPass(); 151 152 //===----------------------------------------------------------------------===// 153 // 154 // LowerConstantIntrinsicss - Expand any remaining llvm.objectsize and 155 // llvm.is.constant intrinsic calls, even for the unknown cases. 156 // 157 FunctionPass *createLowerConstantIntrinsicsPass(); 158 159 //===----------------------------------------------------------------------===// 160 // 161 // PartiallyInlineLibCalls - Tries to inline the fast path of library 162 // calls such as sqrt. 163 // 164 FunctionPass *createPartiallyInlineLibCallsPass(); 165 166 //===----------------------------------------------------------------------===// 167 // 168 // SeparateConstOffsetFromGEP - Split GEPs for better CSE 169 // 170 FunctionPass *createSeparateConstOffsetFromGEPPass(bool LowerGEP = false); 171 172 //===----------------------------------------------------------------------===// 173 // 174 // SpeculativeExecution - Aggressively hoist instructions to enable 175 // speculative execution on targets where branches are expensive. 176 // 177 FunctionPass *createSpeculativeExecutionPass(); 178 179 // Same as createSpeculativeExecutionPass, but does nothing unless 180 // TargetTransformInfo::hasBranchDivergence() is true. 181 FunctionPass *createSpeculativeExecutionIfHasBranchDivergencePass(); 182 183 //===----------------------------------------------------------------------===// 184 // 185 // StraightLineStrengthReduce - This pass strength-reduces some certain 186 // instruction patterns in straight-line code. 187 // 188 FunctionPass *createStraightLineStrengthReducePass(); 189 190 //===----------------------------------------------------------------------===// 191 // 192 // NaryReassociate - Simplify n-ary operations by reassociation. 193 // 194 FunctionPass *createNaryReassociatePass(); 195 196 //===----------------------------------------------------------------------===// 197 // 198 // LoopDataPrefetch - Perform data prefetching in loops. 199 // 200 FunctionPass *createLoopDataPrefetchPass(); 201 202 //===----------------------------------------------------------------------===// 203 // 204 // This pass does instruction simplification on each 205 // instruction in a function. 206 // 207 FunctionPass *createInstSimplifyLegacyPass(); 208 209 210 //===----------------------------------------------------------------------===// 211 // 212 // createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather 213 // and scatter intrinsics with scalar code when target doesn't support them. 214 // 215 FunctionPass *createScalarizeMaskedMemIntrinLegacyPass(); 216 } // End llvm namespace 217 218 #endif 219