blob: bd13664852608ea6679573b292c6b14d0db97daf [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
Chris Lattner3e200e62003-12-20 10:18:58 +000047 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
48 /// use two operands. This destroys SSA information but it is desired by
49 /// register allocators.
50 extern const PassInfo *TwoAddressInstructionPassID;
Chris Lattnerdb000652003-01-13 01:01:31 +000051
Chris Lattner3e200e62003-12-20 10:18:58 +000052 /// Creates a register allocator as the user specified on the command line.
53 ///
54 FunctionPass *createRegisterAllocator();
Alkis Evlogimenos4c080862003-12-18 22:40:24 +000055
Chris Lattner3e200e62003-12-20 10:18:58 +000056 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
57 /// from SSA form to use explicit registers by spilling every register. Wow,
58 /// great policy huh?
59 ///
60 FunctionPass *createSimpleRegisterAllocator();
Alkis Evlogimenoseed462b2003-10-02 06:13:19 +000061
Chris Lattner3e200e62003-12-20 10:18:58 +000062 /// LocalRegisterAllocation Pass - This pass register allocates the input code
63 /// a basic block at a time, yielding code better than the simple register
64 /// allocator, but not as good as a global allocator.
Misha Brukmanea61c352005-04-21 20:39:54 +000065 ///
Chris Lattner3e200e62003-12-20 10:18:58 +000066 FunctionPass *createLocalRegisterAllocator();
Misha Brukmanea61c352005-04-21 20:39:54 +000067
Chris Lattner3e200e62003-12-20 10:18:58 +000068 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
69 /// register allocation algorithm, a global register allocator.
70 ///
71 FunctionPass *createLinearScanRegisterAllocator();
Chris Lattnerdb000652003-01-13 01:01:31 +000072
Chris Lattner3e200e62003-12-20 10:18:58 +000073 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
74 /// and eliminates abstract frame references.
75 ///
76 FunctionPass *createPrologEpilogCodeInserter();
Chris Lattnerdb000652003-01-13 01:01:31 +000077
Chris Lattner36c29db2004-07-31 09:59:14 +000078 /// BranchFolding Pass - This pass performs machine code CFG based
79 /// optimizations to delete branches to branches, eliminate branches to
80 /// successor blocks (creating fall throughs), and eliminating branches over
81 /// branches.
82 FunctionPass *createBranchFoldingPass();
83
Evan Cheng4e654852007-05-16 02:00:57 +000084 /// IfConverter Pass - This pass performs machine code if conversion.
85 FunctionPass *createIfConverterPass();
86
Jim Laskey9d4209f2006-11-07 19:33:46 +000087 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
88 /// allows a debug emitter to determine if the range of two labels is empty,
89 /// by seeing if the labels map to the same reduced label.
90 FunctionPass *createDebugLabelFoldingPass();
91
Chris Lattner3e200e62003-12-20 10:18:58 +000092 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
93 /// the current function, which should happen after the function has been
94 /// emitted to a .s file or to memory.
95 FunctionPass *createMachineCodeDeleter();
Misha Brukmanea61c352005-04-21 20:39:54 +000096
Chris Lattner3e200e62003-12-20 10:18:58 +000097 /// getRegisterAllocator - This creates an instance of the register allocator
98 /// for the Sparc.
99 FunctionPass *getRegisterAllocator(TargetMachine &T);
Tanya Lattner5a75c912004-05-08 16:14:02 +0000100
101 //createModuloSchedulingPass - Creates the Swing Modulo Scheduling Pass
102 FunctionPass *createModuloSchedulingPass(TargetMachine & targ);
103
Tanya Lattner9d6b6282005-05-01 16:14:34 +0000104 //createModuloSchedulingPass - Creates the Swing Modulo Scheduling Pass
105 FunctionPass *createModuloSchedulingSBPass(TargetMachine & targ);
106
Brian Gaeked0fde302003-11-11 22:41:34 +0000107} // End llvm namespace
108
Chris Lattnerdb000652003-01-13 01:01:31 +0000109#endif