LLVM API Documentation
00001 //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines interfaces to access the target independent code generation 00011 // passes provided by the LLVM backend. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CODEGEN_PASSES_H 00016 #define LLVM_CODEGEN_PASSES_H 00017 00018 #include <iosfwd> 00019 #include <string> 00020 00021 namespace llvm { 00022 00023 class FunctionPass; 00024 class PassInfo; 00025 class TargetMachine; 00026 class TargetLowering; 00027 class RegisterCoalescer; 00028 00029 /// createUnreachableBlockEliminationPass - The LLVM code generator does not 00030 /// work well with unreachable basic blocks (what live ranges make sense for a 00031 /// block that cannot be reached?). As such, a code generator should either 00032 /// not instruction select unreachable blocks, or it can run this pass as it's 00033 /// last LLVM modifying pass to clean up blocks that are not reachable from 00034 /// the entry block. 00035 FunctionPass *createUnreachableBlockEliminationPass(); 00036 00037 /// MachineFunctionPrinter pass - This pass prints out the machine function to 00038 /// standard error, as a debugging tool. 00039 FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS, 00040 const std::string &Banner =""); 00041 00042 /// MachineLoopInfo pass - This pass is a loop analysis pass. 00043 /// 00044 extern const PassInfo *const MachineLoopInfoID; 00045 00046 /// MachineDominators pass - This pass is a machine dominators analysis pass. 00047 /// 00048 extern const PassInfo *const MachineDominatorsID; 00049 00050 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes 00051 /// by inserting copy instructions. This destroys SSA information, but is the 00052 /// desired input for some register allocators. This pass is "required" by 00053 /// these register allocator like this: AU.addRequiredID(PHIEliminationID); 00054 /// 00055 extern const PassInfo *const PHIEliminationID; 00056 00057 /// StrongPHIElimination pass - This pass eliminates machine instruction PHI 00058 /// nodes by inserting copy instructions. This destroys SSA information, but 00059 /// is the desired input for some register allocators. This pass is 00060 /// "required" by these register allocator like this: 00061 /// AU.addRequiredID(PHIEliminationID); 00062 /// This pass is still in development 00063 extern const PassInfo *const StrongPHIEliminationID; 00064 00065 extern const PassInfo *const PreAllocSplittingID; 00066 00067 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register 00068 /// copy it can. 00069 /// 00070 extern const PassInfo *const SimpleRegisterCoalescingID; 00071 00072 /// TwoAddressInstruction pass - This pass reduces two-address instructions to 00073 /// use two operands. This destroys SSA information but it is desired by 00074 /// register allocators. 00075 extern const PassInfo *const TwoAddressInstructionPassID; 00076 00077 /// UnreachableMachineBlockElimination pass - This pass removes unreachable 00078 /// machine basic blocks. 00079 extern const PassInfo *const UnreachableMachineBlockElimID; 00080 00081 /// DeadMachineInstructionElim pass - This pass removes dead machine 00082 /// instructions. 00083 /// 00084 FunctionPass *createDeadMachineInstructionElimPass(); 00085 00086 /// Creates a register allocator as the user specified on the command line. 00087 /// 00088 FunctionPass *createRegisterAllocator(); 00089 00090 /// SimpleRegisterAllocation Pass - This pass converts the input machine code 00091 /// from SSA form to use explicit registers by spilling every register. Wow, 00092 /// great policy huh? 00093 /// 00094 FunctionPass *createSimpleRegisterAllocator(); 00095 00096 /// LocalRegisterAllocation Pass - This pass register allocates the input code 00097 /// a basic block at a time, yielding code better than the simple register 00098 /// allocator, but not as good as a global allocator. 00099 /// 00100 FunctionPass *createLocalRegisterAllocator(); 00101 00102 /// BigBlockRegisterAllocation Pass - The BigBlock register allocator 00103 /// munches single basic blocks at a time, like the local register 00104 /// allocator. While the BigBlock allocator is a little slower, and uses 00105 /// somewhat more memory than the local register allocator, it tends to 00106 /// yield the best allocations (of any of the allocators) for blocks that 00107 /// have hundreds or thousands of instructions in sequence. 00108 /// 00109 FunctionPass *createBigBlockRegisterAllocator(); 00110 00111 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan 00112 /// register allocation algorithm, a global register allocator. 00113 /// 00114 FunctionPass *createLinearScanRegisterAllocator(); 00115 00116 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean 00117 /// Quadratic Prograaming (PBQP) based register allocator. 00118 /// 00119 FunctionPass *createPBQPRegisterAllocator(); 00120 00121 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run 00122 /// independently of the register allocator. 00123 /// 00124 RegisterCoalescer *createSimpleRegisterCoalescer(); 00125 00126 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code, 00127 /// and eliminates abstract frame references. 00128 /// 00129 FunctionPass *createPrologEpilogCodeInserter(); 00130 00131 /// LowerSubregs Pass - This pass lowers subregs to register-register copies 00132 /// which yields suboptimal, but correct code if the register allocator 00133 /// cannot coalesce all subreg operations during allocation. 00134 /// 00135 FunctionPass *createLowerSubregsPass(); 00136 00137 /// createPostRAScheduler - under development. 00138 FunctionPass *createPostRAScheduler(); 00139 00140 /// BranchFolding Pass - This pass performs machine code CFG based 00141 /// optimizations to delete branches to branches, eliminate branches to 00142 /// successor blocks (creating fall throughs), and eliminating branches over 00143 /// branches. 00144 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge); 00145 00146 /// IfConverter Pass - This pass performs machine code if conversion. 00147 FunctionPass *createIfConverterPass(); 00148 00149 /// LoopAligner Pass - This pass aligns loop headers to target specific 00150 /// alignment boundary. 00151 FunctionPass *createLoopAlignerPass(); 00152 00153 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This 00154 /// allows a debug emitter to determine if the range of two labels is empty, 00155 /// by seeing if the labels map to the same reduced label. 00156 FunctionPass *createDebugLabelFoldingPass(); 00157 00158 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for 00159 /// the current function, which should happen after the function has been 00160 /// emitted to a .s file or to memory. 00161 FunctionPass *createMachineCodeDeleter(); 00162 00163 /// getRegisterAllocator - This creates an instance of the register allocator 00164 /// for the Sparc. 00165 FunctionPass *getRegisterAllocator(TargetMachine &T); 00166 00167 /// IntrinsicLowering Pass - Performs target-independent LLVM IR 00168 /// transformations for highly portable strategies. 00169 FunctionPass *createGCLoweringPass(); 00170 00171 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in 00172 /// machine code. Must be added very late during code generation, just prior 00173 /// to output, and importantly after all CFG transformations (such as branch 00174 /// folding). 00175 FunctionPass *createGCMachineCodeAnalysisPass(); 00176 00177 /// Deleter Pass - Releases GC metadata. 00178 /// 00179 FunctionPass *createGCInfoDeleter(); 00180 00181 /// Creates a pass to print GC metadata. 00182 /// 00183 FunctionPass *createGCInfoPrinter(std::ostream &OS); 00184 00185 /// createMachineLICMPass - This pass performs LICM on machine instructions. 00186 /// 00187 FunctionPass *createMachineLICMPass(); 00188 00189 /// createMachineSinkingPass - This pass performs sinking on machine 00190 /// instructions. 00191 FunctionPass *createMachineSinkingPass(); 00192 00193 /// createStackSlotColoringPass - This pass performs stack slot coloring. 00194 FunctionPass *createStackSlotColoringPass(); 00195 00196 /// createStackProtectorPass - This pass adds stack protectors to functions. 00197 FunctionPass *createStackProtectorPass(const TargetLowering *tli); 00198 00199 } // End llvm namespace 00200 00201 #endif