Home | History | Annotate | Download | only in CodeGen
      1 //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file defines interfaces to access the target independent code generation
     11 // passes provided by the LLVM backend.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_CODEGEN_PASSES_H
     16 #define LLVM_CODEGEN_PASSES_H
     17 
     18 #include "llvm/Target/TargetMachine.h"
     19 #include <string>
     20 
     21 namespace llvm {
     22 
     23   class FunctionPass;
     24   class MachineFunctionPass;
     25   class PassInfo;
     26   class TargetLowering;
     27   class TargetRegisterClass;
     28   class raw_ostream;
     29 
     30   /// createUnreachableBlockEliminationPass - The LLVM code generator does not
     31   /// work well with unreachable basic blocks (what live ranges make sense for a
     32   /// block that cannot be reached?).  As such, a code generator should either
     33   /// not instruction select unreachable blocks, or run this pass as its
     34   /// last LLVM modifying pass to clean up blocks that are not reachable from
     35   /// the entry block.
     36   FunctionPass *createUnreachableBlockEliminationPass();
     37 
     38   /// MachineFunctionPrinter pass - This pass prints out the machine function to
     39   /// the given stream as a debugging tool.
     40   MachineFunctionPass *
     41   createMachineFunctionPrinterPass(raw_ostream &OS,
     42                                    const std::string &Banner ="");
     43 
     44   /// MachineLoopInfo pass - This pass is a loop analysis pass.
     45   ///
     46   extern char &MachineLoopInfoID;
     47 
     48   /// MachineLoopRanges pass - This pass is an on-demand loop coverage
     49   /// analysis pass.
     50   ///
     51   extern char &MachineLoopRangesID;
     52 
     53   /// MachineDominators pass - This pass is a machine dominators analysis pass.
     54   ///
     55   extern char &MachineDominatorsID;
     56 
     57   /// EdgeBundles analysis - Bundle machine CFG edges.
     58   ///
     59   extern char &EdgeBundlesID;
     60 
     61   /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
     62   /// by inserting copy instructions.  This destroys SSA information, but is the
     63   /// desired input for some register allocators.  This pass is "required" by
     64   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
     65   ///
     66   extern char &PHIEliminationID;
     67 
     68   /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
     69   /// nodes by inserting copy instructions.  This destroys SSA information, but
     70   /// is the desired input for some register allocators.  This pass is
     71   /// "required" by these register allocator like this:
     72   ///    AU.addRequiredID(PHIEliminationID);
     73   ///  This pass is still in development
     74   extern char &StrongPHIEliminationID;
     75 
     76   /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
     77   extern char &LiveStacksID;
     78 
     79   /// TwoAddressInstruction pass - This pass reduces two-address instructions to
     80   /// use two operands. This destroys SSA information but it is desired by
     81   /// register allocators.
     82   extern char &TwoAddressInstructionPassID;
     83 
     84   /// RegisteCoalescer pass - This pass merges live ranges to eliminate copies.
     85   extern char &RegisterCoalescerPassID;
     86 
     87   /// SpillPlacement analysis. Suggest optimal placement of spill code between
     88   /// basic blocks.
     89   ///
     90   extern char &SpillPlacementID;
     91 
     92   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
     93   /// machine basic blocks.
     94   extern char &UnreachableMachineBlockElimID;
     95 
     96   /// DeadMachineInstructionElim pass - This pass removes dead machine
     97   /// instructions.
     98   ///
     99   FunctionPass *createDeadMachineInstructionElimPass();
    100 
    101   /// Creates a register allocator as the user specified on the command line, or
    102   /// picks one that matches OptLevel.
    103   ///
    104   FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
    105 
    106   /// FastRegisterAllocation Pass - This pass register allocates as fast as
    107   /// possible. It is best suited for debug code where live ranges are short.
    108   ///
    109   FunctionPass *createFastRegisterAllocator();
    110 
    111   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
    112   /// register allocator using the basic regalloc framework.
    113   ///
    114   FunctionPass *createBasicRegisterAllocator();
    115 
    116   /// Greedy register allocation pass - This pass implements a global register
    117   /// allocator for optimized builds.
    118   ///
    119   FunctionPass *createGreedyRegisterAllocator();
    120 
    121   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
    122   /// register allocation algorithm, a global register allocator.
    123   ///
    124   FunctionPass *createLinearScanRegisterAllocator();
    125 
    126   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
    127   /// Quadratic Prograaming (PBQP) based register allocator.
    128   ///
    129   FunctionPass *createDefaultPBQPRegisterAllocator();
    130 
    131   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
    132   /// and eliminates abstract frame references.
    133   ///
    134   FunctionPass *createPrologEpilogCodeInserter();
    135 
    136   /// ExpandPostRAPseudos Pass - This pass expands pseudo instructions after
    137   /// register allocation.
    138   ///
    139   FunctionPass *createExpandPostRAPseudosPass();
    140 
    141   /// createPostRAScheduler - This pass performs post register allocation
    142   /// scheduling.
    143   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
    144 
    145   /// BranchFolding Pass - This pass performs machine code CFG based
    146   /// optimizations to delete branches to branches, eliminate branches to
    147   /// successor blocks (creating fall throughs), and eliminating branches over
    148   /// branches.
    149   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
    150 
    151   /// TailDuplicate Pass - Duplicate blocks with unconditional branches
    152   /// into tails of their predecessors.
    153   FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
    154 
    155   /// IfConverter Pass - This pass performs machine code if conversion.
    156   FunctionPass *createIfConverterPass();
    157 
    158   /// Code Placement Pass - This pass optimize code placement and aligns loop
    159   /// headers to target specific alignment boundary.
    160   FunctionPass *createCodePlacementOptPass();
    161 
    162   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
    163   /// transformations for highly portable strategies.
    164   FunctionPass *createGCLoweringPass();
    165 
    166   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
    167   /// machine code. Must be added very late during code generation, just prior
    168   /// to output, and importantly after all CFG transformations (such as branch
    169   /// folding).
    170   FunctionPass *createGCMachineCodeAnalysisPass();
    171 
    172   /// Deleter Pass - Releases GC metadata.
    173   ///
    174   FunctionPass *createGCInfoDeleter();
    175 
    176   /// Creates a pass to print GC metadata.
    177   ///
    178   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
    179 
    180   /// createMachineCSEPass - This pass performs global CSE on machine
    181   /// instructions.
    182   FunctionPass *createMachineCSEPass();
    183 
    184   /// createMachineLICMPass - This pass performs LICM on machine instructions.
    185   ///
    186   FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
    187 
    188   /// createMachineSinkingPass - This pass performs sinking on machine
    189   /// instructions.
    190   FunctionPass *createMachineSinkingPass();
    191 
    192   /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
    193   /// like extension and comparison eliminations.
    194   FunctionPass *createPeepholeOptimizerPass();
    195 
    196   /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
    197   /// to take advantage of opportunities created during DAG legalization.
    198   FunctionPass *createOptimizePHIsPass();
    199 
    200   /// createStackSlotColoringPass - This pass performs stack slot coloring.
    201   FunctionPass *createStackSlotColoringPass(bool);
    202 
    203   /// createStackProtectorPass - This pass adds stack protectors to functions.
    204   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
    205 
    206   /// createMachineVerifierPass - This pass verifies cenerated machine code
    207   /// instructions for correctness.
    208   FunctionPass *createMachineVerifierPass(const char *Banner = 0);
    209 
    210   /// createDwarfEHPass - This pass mulches exception handling code into a form
    211   /// adapted to code generation.  Required if using dwarf exception handling.
    212   FunctionPass *createDwarfEHPass(const TargetMachine *tm);
    213 
    214   /// createSjLjEHPass - This pass adapts exception handling code to use
    215   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
    216   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
    217 
    218   /// createLocalStackSlotAllocationPass - This pass assigns local frame
    219   /// indices to stack slots relative to one another and allocates
    220   /// base registers to access them when it is estimated by the target to
    221   /// be out of range of normal frame pointer or stack pointer index
    222   /// addressing.
    223   FunctionPass *createLocalStackSlotAllocationPass();
    224 
    225   /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
    226   ///
    227   FunctionPass *createExpandISelPseudosPass();
    228 
    229   /// createExecutionDependencyFixPass - This pass fixes execution time
    230   /// problems with dependent instructions, such as switching execution
    231   /// domains to match.
    232   ///
    233   /// The pass will examine instructions using and defining registers in RC.
    234   ///
    235   FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
    236 
    237 } // End llvm namespace
    238 
    239 #endif
    240