2003-08-22 00:14:26 +02:00
|
|
|
//===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:39:54 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-01-13 02:01:31 +01:00
|
|
|
//
|
2003-08-22 00:14:26 +02:00
|
|
|
// This file defines interfaces to access the target independent code generation
|
2003-01-13 02:01:31 +01:00
|
|
|
// passes provided by the LLVM backend.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_PASSES_H
|
|
|
|
#define LLVM_CODEGEN_PASSES_H
|
|
|
|
|
2009-10-16 23:06:15 +02:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2004-02-04 22:41:10 +01:00
|
|
|
#include <string>
|
2004-01-30 22:53:46 +01:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
class FunctionPass;
|
2010-04-03 01:17:14 +02:00
|
|
|
class MachineFunctionPass;
|
2003-12-20 11:18:58 +01:00
|
|
|
class PassInfo;
|
2008-11-04 22:53:09 +01:00
|
|
|
class TargetLowering;
|
2007-09-06 18:18:45 +02:00
|
|
|
class RegisterCoalescer;
|
2009-08-23 05:13:20 +02:00
|
|
|
class raw_ostream;
|
2004-07-02 07:44:13 +02:00
|
|
|
|
|
|
|
/// createUnreachableBlockEliminationPass - The LLVM code generator does not
|
|
|
|
/// work well with unreachable basic blocks (what live ranges make sense for a
|
|
|
|
/// block that cannot be reached?). As such, a code generator should either
|
|
|
|
/// not instruction select unreachable blocks, or it can run this pass as it's
|
|
|
|
/// last LLVM modifying pass to clean up blocks that are not reachable from
|
|
|
|
/// the entry block.
|
|
|
|
FunctionPass *createUnreachableBlockEliminationPass();
|
2005-04-21 22:39:54 +02:00
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
/// MachineFunctionPrinter pass - This pass prints out the machine function to
|
2009-08-03 03:02:24 +02:00
|
|
|
/// the given stream, as a debugging tool.
|
2010-04-03 01:17:14 +02:00
|
|
|
MachineFunctionPass *
|
|
|
|
createMachineFunctionPrinterPass(raw_ostream &OS,
|
|
|
|
const std::string &Banner ="");
|
2004-01-30 22:53:46 +01:00
|
|
|
|
2008-01-04 21:54:55 +01:00
|
|
|
/// MachineLoopInfo pass - This pass is a loop analysis pass.
|
|
|
|
///
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const MachineLoopInfoID;
|
2008-01-04 21:54:55 +01:00
|
|
|
|
|
|
|
/// MachineDominators pass - This pass is a machine dominators analysis pass.
|
|
|
|
///
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const MachineDominatorsID;
|
2008-01-04 21:54:55 +01:00
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
/// PHIElimination pass - This pass eliminates machine instruction PHI nodes
|
|
|
|
/// by inserting copy instructions. This destroys SSA information, but is the
|
|
|
|
/// desired input for some register allocators. This pass is "required" by
|
|
|
|
/// these register allocator like this: AU.addRequiredID(PHIEliminationID);
|
|
|
|
///
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const PHIEliminationID;
|
2007-10-31 04:37:57 +01:00
|
|
|
|
|
|
|
/// StrongPHIElimination pass - This pass eliminates machine instruction PHI
|
|
|
|
/// nodes by inserting copy instructions. This destroys SSA information, but
|
|
|
|
/// is the desired input for some register allocators. This pass is
|
|
|
|
/// "required" by these register allocator like this:
|
|
|
|
/// AU.addRequiredID(PHIEliminationID);
|
|
|
|
/// This pass is still in development
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const StrongPHIEliminationID;
|
2003-01-13 02:01:31 +01:00
|
|
|
|
2008-10-20 23:44:59 +02:00
|
|
|
extern const PassInfo *const PreAllocSplittingID;
|
|
|
|
|
2007-06-08 19:18:56 +02:00
|
|
|
/// SimpleRegisterCoalescing pass. Aggressively coalesces every register
|
|
|
|
/// copy it can.
|
|
|
|
///
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const SimpleRegisterCoalescingID;
|
2007-06-08 19:18:56 +02:00
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
/// TwoAddressInstruction pass - This pass reduces two-address instructions to
|
|
|
|
/// use two operands. This destroys SSA information but it is desired by
|
|
|
|
/// register allocators.
|
2008-05-13 04:05:11 +02:00
|
|
|
extern const PassInfo *const TwoAddressInstructionPassID;
|
2003-01-13 02:01:31 +01:00
|
|
|
|
2008-08-05 01:54:43 +02:00
|
|
|
/// UnreachableMachineBlockElimination pass - This pass removes unreachable
|
|
|
|
/// machine basic blocks.
|
|
|
|
extern const PassInfo *const UnreachableMachineBlockElimID;
|
|
|
|
|
2008-09-17 02:43:24 +02:00
|
|
|
/// DeadMachineInstructionElim pass - This pass removes dead machine
|
|
|
|
/// instructions.
|
|
|
|
///
|
|
|
|
FunctionPass *createDeadMachineInstructionElimPass();
|
|
|
|
|
2010-05-28 01:57:25 +02:00
|
|
|
/// Creates a register allocator as the user specified on the command line, or
|
|
|
|
/// picks one that matches OptLevel.
|
2003-12-20 11:18:58 +01:00
|
|
|
///
|
2010-05-28 01:57:25 +02:00
|
|
|
FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
|
2003-01-13 02:01:31 +01:00
|
|
|
|
2010-04-21 20:02:42 +02:00
|
|
|
/// FastRegisterAllocation Pass - This pass register allocates as fast as
|
|
|
|
/// possible. It is best suited for debug code where live ranges are short.
|
|
|
|
///
|
|
|
|
FunctionPass *createFastRegisterAllocator();
|
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
/// LinearScanRegisterAllocation Pass - This pass implements the linear scan
|
|
|
|
/// register allocation algorithm, a global register allocator.
|
|
|
|
///
|
|
|
|
FunctionPass *createLinearScanRegisterAllocator();
|
2008-10-02 20:29:27 +02:00
|
|
|
|
|
|
|
/// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
|
|
|
|
/// Quadratic Prograaming (PBQP) based register allocator.
|
|
|
|
///
|
|
|
|
FunctionPass *createPBQPRegisterAllocator();
|
2003-01-13 02:01:31 +01:00
|
|
|
|
2007-09-06 18:18:45 +02:00
|
|
|
/// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
|
|
|
|
/// independently of the register allocator.
|
|
|
|
///
|
|
|
|
RegisterCoalescer *createSimpleRegisterCoalescer();
|
|
|
|
|
2003-12-20 11:18:58 +01:00
|
|
|
/// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
|
|
|
|
/// and eliminates abstract frame references.
|
|
|
|
///
|
|
|
|
FunctionPass *createPrologEpilogCodeInserter();
|
2007-07-26 10:18:32 +02:00
|
|
|
|
|
|
|
/// LowerSubregs Pass - This pass lowers subregs to register-register copies
|
2007-08-06 18:33:56 +02:00
|
|
|
/// which yields suboptimal, but correct code if the register allocator
|
2007-07-26 10:18:32 +02:00
|
|
|
/// cannot coalesce all subreg operations during allocation.
|
|
|
|
///
|
|
|
|
FunctionPass *createLowerSubregsPass();
|
2003-09-30 22:14:43 +02:00
|
|
|
|
2009-10-16 23:06:15 +02:00
|
|
|
/// createPostRAScheduler - This pass performs post register allocation
|
|
|
|
/// scheduling.
|
|
|
|
FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
|
2007-07-13 19:13:54 +02:00
|
|
|
|
2004-07-31 11:59:14 +02:00
|
|
|
/// BranchFolding Pass - This pass performs machine code CFG based
|
|
|
|
/// optimizations to delete branches to branches, eliminate branches to
|
|
|
|
/// successor blocks (creating fall throughs), and eliminating branches over
|
|
|
|
/// branches.
|
2009-10-28 21:46:46 +01:00
|
|
|
FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
|
2004-07-31 11:59:14 +02:00
|
|
|
|
2009-11-26 22:38:41 +01:00
|
|
|
/// TailDuplicate Pass - Duplicate blocks with unconditional branches
|
2009-11-26 01:32:21 +01:00
|
|
|
/// into tails of their predecessors.
|
2009-12-04 10:42:45 +01:00
|
|
|
FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
|
2009-11-26 01:32:21 +01:00
|
|
|
|
2009-10-28 21:46:46 +01:00
|
|
|
/// IfConverter Pass - This pass performs machine code if conversion.
|
|
|
|
FunctionPass *createIfConverterPass();
|
2007-05-16 04:00:57 +02:00
|
|
|
|
2009-05-07 07:42:24 +02:00
|
|
|
/// Code Placement Pass - This pass optimize code placement and aligns loop
|
|
|
|
/// headers to target specific alignment boundary.
|
|
|
|
FunctionPass *createCodePlacementOptPass();
|
2008-02-28 01:43:03 +01:00
|
|
|
|
2007-12-11 01:30:17 +01:00
|
|
|
/// IntrinsicLowering Pass - Performs target-independent LLVM IR
|
2008-08-17 20:44:35 +02:00
|
|
|
/// transformations for highly portable strategies.
|
2007-12-11 01:30:17 +01:00
|
|
|
FunctionPass *createGCLoweringPass();
|
|
|
|
|
|
|
|
/// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
|
|
|
|
/// machine code. Must be added very late during code generation, just prior
|
|
|
|
/// to output, and importantly after all CFG transformations (such as branch
|
|
|
|
/// folding).
|
|
|
|
FunctionPass *createGCMachineCodeAnalysisPass();
|
|
|
|
|
2008-08-17 20:44:35 +02:00
|
|
|
/// Deleter Pass - Releases GC metadata.
|
2007-12-11 01:30:17 +01:00
|
|
|
///
|
2008-08-17 20:44:35 +02:00
|
|
|
FunctionPass *createGCInfoDeleter();
|
2007-12-11 01:30:17 +01:00
|
|
|
|
2008-08-17 20:44:35 +02:00
|
|
|
/// Creates a pass to print GC metadata.
|
2007-12-11 01:30:17 +01:00
|
|
|
///
|
2009-08-23 05:13:20 +02:00
|
|
|
FunctionPass *createGCInfoPrinter(raw_ostream &OS);
|
2007-12-11 01:30:17 +01:00
|
|
|
|
2010-03-02 03:38:24 +01:00
|
|
|
/// createMachineCSEPass - This pass performs global CSE on machine
|
|
|
|
/// instructions.
|
|
|
|
FunctionPass *createMachineCSEPass();
|
|
|
|
|
Initial commit of the machine code LICM pass. It successfully hoists this:
_foo:
li r2, 0
LBB1_1: ; bb
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
to:
_foo:
li r2, 0
li r5, 0
LBB1_1: ; bb
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
ZOMG!! :-)
Moar to come...
llvm-svn: 44687
2007-12-07 22:42:31 +01:00
|
|
|
/// createMachineLICMPass - This pass performs LICM on machine instructions.
|
|
|
|
///
|
2010-04-07 02:41:17 +02:00
|
|
|
FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
|
Initial commit of the machine code LICM pass. It successfully hoists this:
_foo:
li r2, 0
LBB1_1: ; bb
li r5, 0
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
to:
_foo:
li r2, 0
li r5, 0
LBB1_1: ; bb
stw r5, 0(r3)
addi r2, r2, 1
addi r3, r3, 4
cmplw cr0, r2, r4
bne cr0, LBB1_1 ; bb
LBB1_2: ; return
blr
ZOMG!! :-)
Moar to come...
llvm-svn: 44687
2007-12-07 22:42:31 +01:00
|
|
|
|
Add a really quick hack at a machine code sinking pass, enabled with --enable-sinking.
It is missing validity checks, so it is known broken. However, it is powerful enough
to compile this contrived code:
void test1(int C, double A, double B, double *P) {
double Tmp = A*A+B*B;
*P = C ? Tmp : A;
}
into:
_test1:
movsd 8(%esp), %xmm0
cmpl $0, 4(%esp)
je LBB1_2 # entry
LBB1_1: # entry
movsd 16(%esp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
LBB1_2: # entry
movl 24(%esp), %eax
movsd %xmm0, (%eax)
ret
instead of:
_test1:
movsd 16(%esp), %xmm0
mulsd %xmm0, %xmm0
movsd 8(%esp), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
cmpl $0, 4(%esp)
je LBB1_2 # entry
LBB1_1: # entry
movapd %xmm2, %xmm1
LBB1_2: # entry
movl 24(%esp), %eax
movsd %xmm1, (%eax)
ret
woo.
llvm-svn: 45570
2008-01-04 08:36:53 +01:00
|
|
|
/// createMachineSinkingPass - This pass performs sinking on machine
|
|
|
|
/// instructions.
|
|
|
|
FunctionPass *createMachineSinkingPass();
|
2008-06-04 11:18:41 +02:00
|
|
|
|
2010-01-13 01:30:23 +01:00
|
|
|
/// createOptimizeExtsPass - This pass performs sign / zero extension
|
|
|
|
/// optimization by increasing uses of extended values.
|
|
|
|
FunctionPass *createOptimizeExtsPass();
|
|
|
|
|
2010-02-12 02:30:21 +01:00
|
|
|
/// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
|
|
|
|
/// to take advantage of opportunities created during DAG legalization.
|
|
|
|
FunctionPass *createOptimizePHIsPass();
|
|
|
|
|
2008-06-04 11:18:41 +02:00
|
|
|
/// createStackSlotColoringPass - This pass performs stack slot coloring.
|
2009-05-07 03:33:38 +02:00
|
|
|
FunctionPass *createStackSlotColoringPass(bool);
|
2008-11-04 03:10:20 +01:00
|
|
|
|
|
|
|
/// createStackProtectorPass - This pass adds stack protectors to functions.
|
2008-11-13 02:02:14 +01:00
|
|
|
FunctionPass *createStackProtectorPass(const TargetLowering *tli);
|
2008-11-04 03:10:20 +01:00
|
|
|
|
2009-05-16 02:33:53 +02:00
|
|
|
/// createMachineVerifierPass - This pass verifies cenerated machine code
|
|
|
|
/// instructions for correctness.
|
|
|
|
///
|
2010-02-22 05:10:52 +01:00
|
|
|
/// @param allowDoubleDefs ignore double definitions of
|
2009-05-16 02:33:53 +02:00
|
|
|
/// registers. Useful before LiveVariables has run.
|
|
|
|
FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
|
|
|
|
|
2009-05-22 22:36:31 +02:00
|
|
|
/// createDwarfEHPass - This pass mulches exception handling code into a form
|
|
|
|
/// adapted to code generation. Required if using dwarf exception handling.
|
2010-04-19 21:05:59 +02:00
|
|
|
FunctionPass *createDwarfEHPass(const TargetMachine *tm, bool fast);
|
2009-05-22 22:36:31 +02:00
|
|
|
|
2009-08-17 18:41:22 +02:00
|
|
|
/// createSjLjEHPass - This pass adapts exception handling code to use
|
|
|
|
/// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
|
|
|
|
FunctionPass *createSjLjEHPass(const TargetLowering *tli);
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-01-13 02:01:31 +01:00
|
|
|
#endif
|