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 // LoopRotate - This pass is a simple loop rotating pass. 67 // 68 Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false); 69 70 //===----------------------------------------------------------------------===// 71 // 72 // Reassociate - This pass reassociates commutative expressions in an order that 73 // is designed to promote better constant propagation, GCSE, LICM, PRE... 74 // 75 // For example: 4 + (x + 5) -> x + (4 + 5) 76 // 77 FunctionPass *createReassociatePass(); 78 79 //===----------------------------------------------------------------------===// 80 // 81 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks, 82 // simplify terminator instructions, convert switches to lookup tables, etc. 83 // 84 FunctionPass *createCFGSimplificationPass( 85 SimplifyCFGOptions Options = SimplifyCFGOptions(), 86 std::function<bool(const Function &)> Ftor = nullptr); 87 88 //===----------------------------------------------------------------------===// 89 // 90 // FlattenCFG - flatten CFG, reduce number of conditional branches by using 91 // parallel-and and parallel-or mode, etc... 92 // 93 FunctionPass *createFlattenCFGPass(); 94 95 //===----------------------------------------------------------------------===// 96 // 97 // CFG Structurization - Remove irreducible control flow 98 // 99 /// 100 /// When \p SkipUniformRegions is true the structizer will not structurize 101 /// regions that only contain uniform branches. 102 Pass *createStructurizeCFGPass(bool SkipUniformRegions = false); 103 104 //===----------------------------------------------------------------------===// 105 // 106 // TailCallElimination - This pass eliminates call instructions to the current 107 // function which occur immediately before return instructions. 108 // 109 FunctionPass *createTailCallEliminationPass(); 110 111 //===----------------------------------------------------------------------===// 112 // 113 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator 114 // tree. 115 // 116 FunctionPass *createEarlyCSEPass(bool UseMemorySSA = false); 117 118 //===----------------------------------------------------------------------===// 119 // 120 // ConstantHoisting - This pass prepares a function for expensive constants. 121 // 122 FunctionPass *createConstantHoistingPass(); 123 124 //===----------------------------------------------------------------------===// 125 // 126 // Sink - Code Sinking 127 // 128 FunctionPass *createSinkingPass(); 129 130 //===----------------------------------------------------------------------===// 131 // 132 // LowerAtomic - Lower atomic intrinsics to non-atomic form 133 // 134 Pass *createLowerAtomicPass(); 135 136 //===----------------------------------------------------------------------===// 137 // 138 // MergeICmps - Merge integer comparison chains into a memcmp 139 // 140 Pass *createMergeICmpsLegacyPass(); 141 142 //===----------------------------------------------------------------------===// 143 // 144 // InferAddressSpaces - Modify users of addrspacecast instructions with values 145 // in the source address space if using the destination address space is slower 146 // on the target. If AddressSpace is left to its default value, it will be 147 // obtained from the TargetTransformInfo. 148 // 149 FunctionPass *createInferAddressSpacesPass(unsigned AddressSpace = ~0u); 150 extern char &InferAddressSpacesID; 151 152 //===----------------------------------------------------------------------===// 153 // 154 // TLSVariableHoist - This pass reduce duplicated TLS address call. 155 // 156 FunctionPass *createTLSVariableHoistPass(); 157 158 //===----------------------------------------------------------------------===// 159 // 160 // LowerConstantIntrinsicss - Expand any remaining llvm.objectsize and 161 // llvm.is.constant intrinsic calls, even for the unknown cases. 162 // 163 FunctionPass *createLowerConstantIntrinsicsPass(); 164 165 //===----------------------------------------------------------------------===// 166 // 167 // PartiallyInlineLibCalls - Tries to inline the fast path of library 168 // calls such as sqrt. 169 // 170 FunctionPass *createPartiallyInlineLibCallsPass(); 171 172 //===----------------------------------------------------------------------===// 173 // 174 // SeparateConstOffsetFromGEP - Split GEPs for better CSE 175 // 176 FunctionPass *createSeparateConstOffsetFromGEPPass(bool LowerGEP = false); 177 178 //===----------------------------------------------------------------------===// 179 // 180 // SpeculativeExecution - Aggressively hoist instructions to enable 181 // speculative execution on targets where branches are expensive. 182 // 183 FunctionPass *createSpeculativeExecutionPass(); 184 185 // Same as createSpeculativeExecutionPass, but does nothing unless 186 // TargetTransformInfo::hasBranchDivergence() is true. 187 FunctionPass *createSpeculativeExecutionIfHasBranchDivergencePass(); 188 189 //===----------------------------------------------------------------------===// 190 // 191 // StraightLineStrengthReduce - This pass strength-reduces some certain 192 // instruction patterns in straight-line code. 193 // 194 FunctionPass *createStraightLineStrengthReducePass(); 195 196 //===----------------------------------------------------------------------===// 197 // 198 // NaryReassociate - Simplify n-ary operations by reassociation. 199 // 200 FunctionPass *createNaryReassociatePass(); 201 202 //===----------------------------------------------------------------------===// 203 // 204 // LoopDataPrefetch - Perform data prefetching in loops. 205 // 206 FunctionPass *createLoopDataPrefetchPass(); 207 208 //===----------------------------------------------------------------------===// 209 // 210 // This pass does instruction simplification on each 211 // instruction in a function. 212 // 213 FunctionPass *createInstSimplifyLegacyPass(); 214 215 216 //===----------------------------------------------------------------------===// 217 // 218 // createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather 219 // and scatter intrinsics with scalar code when target doesn't support them. 220 // 221 FunctionPass *createScalarizeMaskedMemIntrinLegacyPass(); 222 } // End llvm namespace 223 224 #endif 225