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 /// the given stream, 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 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan 00103 /// register allocation algorithm, a global register allocator. 00104 /// 00105 FunctionPass *createLinearScanRegisterAllocator(); 00106 00107 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean 00108 /// Quadratic Prograaming (PBQP) based register allocator. 00109 /// 00110 FunctionPass *createPBQPRegisterAllocator(); 00111 00112 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run 00113 /// independently of the register allocator. 00114 /// 00115 RegisterCoalescer *createSimpleRegisterCoalescer(); 00116 00117 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code, 00118 /// and eliminates abstract frame references. 00119 /// 00120 FunctionPass *createPrologEpilogCodeInserter(); 00121 00122 /// LowerSubregs Pass - This pass lowers subregs to register-register copies 00123 /// which yields suboptimal, but correct code if the register allocator 00124 /// cannot coalesce all subreg operations during allocation. 00125 /// 00126 FunctionPass *createLowerSubregsPass(); 00127 00128 /// createPostRAScheduler - under development. 00129 FunctionPass *createPostRAScheduler(); 00130 00131 /// BranchFolding Pass - This pass performs machine code CFG based 00132 /// optimizations to delete branches to branches, eliminate branches to 00133 /// successor blocks (creating fall throughs), and eliminating branches over 00134 /// branches. 00135 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge); 00136 00137 /// IfConverter Pass - This pass performs machine code if conversion. 00138 FunctionPass *createIfConverterPass(); 00139 00140 /// Code Placement Pass - This pass optimize code placement and aligns loop 00141 /// headers to target specific alignment boundary. 00142 FunctionPass *createCodePlacementOptPass(); 00143 00144 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This 00145 /// allows a debug emitter to determine if the range of two labels is empty, 00146 /// by seeing if the labels map to the same reduced label. 00147 FunctionPass *createDebugLabelFoldingPass(); 00148 00149 /// getRegisterAllocator - This creates an instance of the register allocator 00150 /// for the Sparc. 00151 FunctionPass *getRegisterAllocator(TargetMachine &T); 00152 00153 /// IntrinsicLowering Pass - Performs target-independent LLVM IR 00154 /// transformations for highly portable strategies. 00155 FunctionPass *createGCLoweringPass(); 00156 00157 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in 00158 /// machine code. Must be added very late during code generation, just prior 00159 /// to output, and importantly after all CFG transformations (such as branch 00160 /// folding). 00161 FunctionPass *createGCMachineCodeAnalysisPass(); 00162 00163 /// Deleter Pass - Releases GC metadata. 00164 /// 00165 FunctionPass *createGCInfoDeleter(); 00166 00167 /// Creates a pass to print GC metadata. 00168 /// 00169 FunctionPass *createGCInfoPrinter(std::ostream &OS); 00170 00171 /// createMachineLICMPass - This pass performs LICM on machine instructions. 00172 /// 00173 FunctionPass *createMachineLICMPass(); 00174 00175 /// createMachineSinkingPass - This pass performs sinking on machine 00176 /// instructions. 00177 FunctionPass *createMachineSinkingPass(); 00178 00179 /// createStackSlotColoringPass - This pass performs stack slot coloring. 00180 FunctionPass *createStackSlotColoringPass(bool); 00181 00182 /// createStackProtectorPass - This pass adds stack protectors to functions. 00183 FunctionPass *createStackProtectorPass(const TargetLowering *tli); 00184 00185 /// createMachineVerifierPass - This pass verifies cenerated machine code 00186 /// instructions for correctness. 00187 /// 00188 /// @param allowPhysDoubleDefs ignore double definitions of 00189 /// registers. Useful before LiveVariables has run. 00190 FunctionPass *createMachineVerifierPass(bool allowDoubleDefs); 00191 00192 /// createDwarfEHPass - This pass mulches exception handling code into a form 00193 /// adapted to code generation. Required if using dwarf exception handling. 00194 FunctionPass *createDwarfEHPass(const TargetLowering *tli, bool fast); 00195 00196 /// createSjLjEHPass - This pass adapts exception handling code to use 00197 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. 00198 FunctionPass *createSjLjEHPass(const TargetLowering *tli); 00199 00200 } // End llvm namespace 00201 00202 #endif