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