blob: 290e86f37ec761a154764aaea18d6d5e8f652cf4 [file] [log] [blame]
Misha Brukmanef6a6a62003-08-21 22:14:26 +00001//===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
Misha Brukmanea61c352005-04-21 20:39:54 +00002//
John Criswell6fbcc262003-10-20 20:19:47 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukmanea61c352005-04-21 20:39:54 +00007//
John Criswell6fbcc262003-10-20 20:19:47 +00008//===----------------------------------------------------------------------===//
Chris Lattnerdb000652003-01-13 01:01:31 +00009//
Misha Brukmanef6a6a62003-08-21 22:14:26 +000010// This file defines interfaces to access the target independent code generation
Chris Lattnerdb000652003-01-13 01:01:31 +000011// passes provided by the LLVM backend.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_PASSES_H
16#define LLVM_CODEGEN_PASSES_H
17
Brian Gaekefc1f6e82004-02-04 21:41:10 +000018#include <iosfwd>
19#include <string>
Brian Gaeke09caa372004-01-30 21:53:46 +000020
Brian Gaeked0fde302003-11-11 22:41:34 +000021namespace llvm {
22
Chris Lattner3e200e62003-12-20 10:18:58 +000023 class FunctionPass;
24 class PassInfo;
25 class TargetMachine;
Chris Lattner8b708e42004-07-02 05:44:13 +000026
27 /// createUnreachableBlockEliminationPass - The LLVM code generator does not
28 /// work well with unreachable basic blocks (what live ranges make sense for a
29 /// block that cannot be reached?). As such, a code generator should either
30 /// not instruction select unreachable blocks, or it can run this pass as it's
31 /// last LLVM modifying pass to clean up blocks that are not reachable from
32 /// the entry block.
33 FunctionPass *createUnreachableBlockEliminationPass();
Misha Brukmanea61c352005-04-21 20:39:54 +000034
Chris Lattner3e200e62003-12-20 10:18:58 +000035 /// MachineFunctionPrinter pass - This pass prints out the machine function to
36 /// standard error, as a debugging tool.
Brian Gaekefc1f6e82004-02-04 21:41:10 +000037 FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
Brian Gaeke09caa372004-01-30 21:53:46 +000038 const std::string &Banner ="");
39
Chris Lattner3e200e62003-12-20 10:18:58 +000040 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
41 /// by inserting copy instructions. This destroys SSA information, but is the
42 /// desired input for some register allocators. This pass is "required" by
43 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
44 ///
45 extern const PassInfo *PHIEliminationID;
Chris Lattnerdb000652003-01-13 01:01:31 +000046
David Greene25133302007-06-08 17:18:56 +000047 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
48 /// copy it can.
49 ///
50 extern const PassInfo *SimpleRegisterCoalescingID;
51
Chris Lattner3e200e62003-12-20 10:18:58 +000052 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
53 /// use two operands. This destroys SSA information but it is desired by
54 /// register allocators.
55 extern const PassInfo *TwoAddressInstructionPassID;
Chris Lattnerdb000652003-01-13 01:01:31 +000056
Chris Lattner3e200e62003-12-20 10:18:58 +000057 /// Creates a register allocator as the user specified on the command line.
58 ///
59 FunctionPass *createRegisterAllocator();
Alkis Evlogimenos4c080862003-12-18 22:40:24 +000060
Chris Lattner3e200e62003-12-20 10:18:58 +000061 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
62 /// from SSA form to use explicit registers by spilling every register. Wow,
63 /// great policy huh?
64 ///
65 FunctionPass *createSimpleRegisterAllocator();
Alkis Evlogimenoseed462b2003-10-02 06:13:19 +000066
Chris Lattner3e200e62003-12-20 10:18:58 +000067 /// LocalRegisterAllocation Pass - This pass register allocates the input code
68 /// a basic block at a time, yielding code better than the simple register
69 /// allocator, but not as good as a global allocator.
Misha Brukmanea61c352005-04-21 20:39:54 +000070 ///
Chris Lattner3e200e62003-12-20 10:18:58 +000071 FunctionPass *createLocalRegisterAllocator();
Misha Brukmanea61c352005-04-21 20:39:54 +000072
Duraid Madinaa8c76822007-06-22 08:27:12 +000073 /// BigBlockRegisterAllocation Pass - The BigBlock register allocator
74 /// munches single basic blocks at a time, like the local register
75 /// allocator. While the BigBlock allocator is a little slower, and uses
76 /// somewhat more memory than the local register allocator, it tends to
77 /// yield the best allocations (of any of the allocators) for blocks that
78 /// have hundreds or thousands of instructions in sequence.
79 ///
80 FunctionPass *createBigBlockRegisterAllocator();
81
Chris Lattner3e200e62003-12-20 10:18:58 +000082 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
83 /// register allocation algorithm, a global register allocator.
84 ///
85 FunctionPass *createLinearScanRegisterAllocator();
Chris Lattnerdb000652003-01-13 01:01:31 +000086
Chris Lattner3e200e62003-12-20 10:18:58 +000087 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
88 /// and eliminates abstract frame references.
89 ///
90 FunctionPass *createPrologEpilogCodeInserter();
Christopher Lambbab24742007-07-26 08:18:32 +000091
92 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
93 /// which yields suboptimial, but correct code if the register allocator
94 /// cannot coalesce all subreg operations during allocation.
95 ///
96 FunctionPass *createLowerSubregsPass();
Chris Lattnerdb000652003-01-13 01:01:31 +000097
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000098 /// createPostRAScheduler - under development.
99 FunctionPass *createPostRAScheduler();
100
Chris Lattner36c29db2004-07-31 09:59:14 +0000101 /// BranchFolding Pass - This pass performs machine code CFG based
102 /// optimizations to delete branches to branches, eliminate branches to
103 /// successor blocks (creating fall throughs), and eliminating branches over
104 /// branches.
Dale Johannesen81da02b2007-05-22 17:14:46 +0000105 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
Chris Lattner36c29db2004-07-31 09:59:14 +0000106
Evan Cheng4e654852007-05-16 02:00:57 +0000107 /// IfConverter Pass - This pass performs machine code if conversion.
108 FunctionPass *createIfConverterPass();
109
Jim Laskey9d4209f2006-11-07 19:33:46 +0000110 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
111 /// allows a debug emitter to determine if the range of two labels is empty,
112 /// by seeing if the labels map to the same reduced label.
113 FunctionPass *createDebugLabelFoldingPass();
114
Chris Lattner3e200e62003-12-20 10:18:58 +0000115 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
116 /// the current function, which should happen after the function has been
117 /// emitted to a .s file or to memory.
118 FunctionPass *createMachineCodeDeleter();
Misha Brukmanea61c352005-04-21 20:39:54 +0000119
Chris Lattner3e200e62003-12-20 10:18:58 +0000120 /// getRegisterAllocator - This creates an instance of the register allocator
121 /// for the Sparc.
122 FunctionPass *getRegisterAllocator(TargetMachine &T);
Tanya Lattner5a75c912004-05-08 16:14:02 +0000123
Brian Gaeked0fde302003-11-11 22:41:34 +0000124} // End llvm namespace
125
Chris Lattnerdb000652003-01-13 01:01:31 +0000126#endif