Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 1 | //===-- LLVMTargetMachine.cpp - Implement the LLVMTargetMachine class -----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the LLVMTargetMachine class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/Target/TargetMachine.h" |
| 15 | #include "llvm/PassManager.h" |
| 16 | #include "llvm/Pass.h" |
Chris Lattner | 31442f9 | 2007-03-31 00:24:43 +0000 | [diff] [blame] | 17 | #include "llvm/Assembly/PrintModulePass.h" |
Devang Patel | 0f54dcb | 2007-03-06 21:14:09 +0000 | [diff] [blame] | 18 | #include "llvm/Analysis/LoopPass.h" |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/Passes.h" |
Gordon Henriksen | 5a29c9e | 2008-08-17 12:56:54 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/GCStrategy.h" |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetOptions.h" |
Dale Johannesen | 1532f3d | 2008-04-02 00:25:04 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetAsmInfo.h" |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 23 | #include "llvm/Transforms/Scalar.h" |
Chris Lattner | 31442f9 | 2007-03-31 00:24:43 +0000 | [diff] [blame] | 24 | #include "llvm/Support/CommandLine.h" |
Owen Anderson | cb37188 | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 25 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 26 | using namespace llvm; |
| 27 | |
Dan Gohman | 2c4bf11 | 2008-09-25 01:14:49 +0000 | [diff] [blame] | 28 | namespace llvm { |
| 29 | bool EnableFastISel; |
| 30 | } |
| 31 | |
Chris Lattner | 85ef254 | 2007-06-19 05:47:49 +0000 | [diff] [blame] | 32 | static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden, |
| 33 | cl::desc("Print LLVM IR produced by the loop-reduce pass")); |
| 34 | static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden, |
| 35 | cl::desc("Print LLVM IR input to isel pass")); |
Evan Cheng | 8bd6035 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 36 | static cl::opt<bool> PrintEmittedAsm("print-emitted-asm", cl::Hidden, |
| 37 | cl::desc("Dump emitter generated instructions as assembly")); |
Gordon Henriksen | 93f96d0 | 2008-01-07 01:33:09 +0000 | [diff] [blame] | 38 | static cl::opt<bool> PrintGCInfo("print-gc", cl::Hidden, |
| 39 | cl::desc("Dump garbage collector data")); |
Chris Lattner | 85ef254 | 2007-06-19 05:47:49 +0000 | [diff] [blame] | 40 | |
Chris Lattner | 459525d | 2008-01-14 19:00:06 +0000 | [diff] [blame] | 41 | // When this works it will be on by default. |
| 42 | static cl::opt<bool> |
| 43 | DisablePostRAScheduler("disable-post-RA-scheduler", |
| 44 | cl::desc("Disable scheduling after register allocation"), |
| 45 | cl::init(true)); |
| 46 | |
Dan Gohman | dc75685 | 2008-10-01 20:39:19 +0000 | [diff] [blame] | 47 | // Enable or disable FastISel. Both options are needed, because |
| 48 | // FastISel is enabled by default with -fast, and we wish to be |
| 49 | // able to enable or disable fast-isel independently from -fast. |
Dan Gohman | eb0d6ab | 2008-10-07 23:00:56 +0000 | [diff] [blame] | 50 | static cl::opt<cl::boolOrDefault> |
Dan Gohman | dc75685 | 2008-10-01 20:39:19 +0000 | [diff] [blame] | 51 | EnableFastISelOption("fast-isel", cl::Hidden, |
| 52 | cl::desc("Enable the experimental \"fast\" instruction selector")); |
Dan Gohman | 2c4bf11 | 2008-09-25 01:14:49 +0000 | [diff] [blame] | 53 | |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 54 | FileModel::Model |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 55 | LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, |
Owen Anderson | cb37188 | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 56 | raw_ostream &Out, |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 57 | CodeGenFileType FileType, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 58 | CodeGenOpt::Level OptLevel) { |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 59 | // Add common CodeGen passes. |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 60 | if (addCommonCodeGenPasses(PM, OptLevel)) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 61 | return FileModel::Error; |
| 62 | |
Jim Laskey | 9d4209f | 2006-11-07 19:33:46 +0000 | [diff] [blame] | 63 | // Fold redundant debug labels. |
| 64 | PM.add(createDebugLabelFoldingPass()); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 65 | |
| 66 | if (PrintMachineCode) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 67 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 68 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 69 | if (addPreEmitPass(PM, OptLevel) && PrintMachineCode) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 70 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 71 | |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 72 | if (OptLevel != CodeGenOpt::None) |
Evan Cheng | d703ed6 | 2008-02-28 23:29:57 +0000 | [diff] [blame] | 73 | PM.add(createLoopAlignerPass()); |
| 74 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 75 | switch (FileType) { |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 76 | default: |
| 77 | break; |
| 78 | case TargetMachine::AssemblyFile: |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 79 | if (addAssemblyEmitter(PM, OptLevel, getAsmVerbosityDefault(), Out)) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 80 | return FileModel::Error; |
| 81 | return FileModel::AsmFile; |
| 82 | case TargetMachine::ObjectFile: |
| 83 | if (getMachOWriterInfo()) |
| 84 | return FileModel::MachOFile; |
| 85 | else if (getELFWriterInfo()) |
| 86 | return FileModel::ElfFile; |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 87 | } |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 88 | |
| 89 | return FileModel::Error; |
| 90 | } |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 91 | |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 92 | /// addPassesToEmitFileFinish - If the passes to emit the specified file had to |
| 93 | /// be split up (e.g., to add an object writer pass), this method can be used to |
| 94 | /// finish up adding passes to emit the file, if necessary. |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 95 | bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 96 | MachineCodeEmitter *MCE, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 97 | CodeGenOpt::Level OptLevel) { |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 98 | if (MCE) |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 99 | addSimpleCodeEmitter(PM, OptLevel, PrintEmittedAsm, *MCE); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 100 | |
Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 101 | PM.add(createGCInfoDeleter()); |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 102 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 103 | // Delete machine code for this function |
| 104 | PM.add(createMachineCodeDeleter()); |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 105 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 106 | return false; // success! |
| 107 | } |
| 108 | |
| 109 | /// addPassesToEmitMachineCode - Add passes to the specified pass manager to |
| 110 | /// get machine code emitted. This uses a MachineCodeEmitter object to handle |
| 111 | /// actually outputting the machine code and resolving things like the address |
| 112 | /// of functions. This method should returns true if machine code emission is |
| 113 | /// not supported. |
| 114 | /// |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 115 | bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM, |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 116 | MachineCodeEmitter &MCE, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 117 | CodeGenOpt::Level OptLevel) { |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 118 | // Add common CodeGen passes. |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 119 | if (addCommonCodeGenPasses(PM, OptLevel)) |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 120 | return true; |
| 121 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 122 | if (addPreEmitPass(PM, OptLevel) && PrintMachineCode) |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 123 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 124 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 125 | addCodeEmitter(PM, OptLevel, PrintEmittedAsm, MCE); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 126 | |
| 127 | PM.add(createGCInfoDeleter()); |
| 128 | |
| 129 | // Delete machine code for this function |
| 130 | PM.add(createMachineCodeDeleter()); |
| 131 | |
| 132 | return false; // success! |
| 133 | } |
| 134 | |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 135 | /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for both |
| 136 | /// emitting to assembly files or machine code output. |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 137 | /// |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 138 | bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 139 | CodeGenOpt::Level OptLevel) { |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 140 | // Standard LLVM-Level Passes. |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 141 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 142 | // Run loop strength reduction before anything else. |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 143 | if (OptLevel != CodeGenOpt::None) { |
Chris Lattner | c8d288f | 2007-03-31 04:18:03 +0000 | [diff] [blame] | 144 | PM.add(createLoopStrengthReducePass(getTargetLowering())); |
| 145 | if (PrintLSR) |
Daniel Dunbar | 3b0da26 | 2008-10-22 03:25:22 +0000 | [diff] [blame] | 146 | PM.add(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &errs())); |
Chris Lattner | c8d288f | 2007-03-31 04:18:03 +0000 | [diff] [blame] | 147 | } |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 148 | |
Gordon Henriksen | 93f96d0 | 2008-01-07 01:33:09 +0000 | [diff] [blame] | 149 | PM.add(createGCLoweringPass()); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 150 | |
Dale Johannesen | 1532f3d | 2008-04-02 00:25:04 +0000 | [diff] [blame] | 151 | if (!getTargetAsmInfo()->doesSupportExceptionHandling()) |
Dale Johannesen | b6d5b14 | 2008-04-01 20:00:57 +0000 | [diff] [blame] | 152 | PM.add(createLowerInvokePass(getTargetLowering())); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 153 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 154 | // Make sure that no unreachable blocks are instruction selected. |
| 155 | PM.add(createUnreachableBlockEliminationPass()); |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 156 | |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 157 | if (OptLevel != CodeGenOpt::None) |
Chris Lattner | c8d288f | 2007-03-31 04:18:03 +0000 | [diff] [blame] | 158 | PM.add(createCodeGenPreparePass(getTargetLowering())); |
| 159 | |
Bill Wendling | e9e6bdf | 2008-11-13 01:02:14 +0000 | [diff] [blame] | 160 | PM.add(createStackProtectorPass(getTargetLowering())); |
Bill Wendling | 2b58ce5 | 2008-11-04 02:10:20 +0000 | [diff] [blame] | 161 | |
Chris Lattner | c8d288f | 2007-03-31 04:18:03 +0000 | [diff] [blame] | 162 | if (PrintISelInput) |
Daniel Dunbar | f4db3a5 | 2008-10-21 23:33:38 +0000 | [diff] [blame] | 163 | PM.add(createPrintFunctionPass("\n\n" |
| 164 | "*** Final LLVM Code input to ISel ***\n", |
Daniel Dunbar | 3b0da26 | 2008-10-22 03:25:22 +0000 | [diff] [blame] | 165 | &errs())); |
Chris Lattner | c8d288f | 2007-03-31 04:18:03 +0000 | [diff] [blame] | 166 | |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 167 | // Standard Lower-Level Passes. |
| 168 | |
Dan Gohman | dc75685 | 2008-10-01 20:39:19 +0000 | [diff] [blame] | 169 | // Enable FastISel with -fast, but allow that to be overridden. |
Dan Gohman | eb0d6ab | 2008-10-07 23:00:56 +0000 | [diff] [blame] | 170 | if (EnableFastISelOption == cl::BOU_TRUE || |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 171 | (OptLevel == CodeGenOpt::None && EnableFastISelOption != cl::BOU_FALSE)) |
Dan Gohman | dc75685 | 2008-10-01 20:39:19 +0000 | [diff] [blame] | 172 | EnableFastISel = true; |
| 173 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 174 | // Ask the target for an isel. |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 175 | if (addInstSelector(PM, OptLevel)) |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 176 | return true; |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 177 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 178 | // Print the instruction selected machine code... |
| 179 | if (PrintMachineCode) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 180 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 181 | |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 182 | if (OptLevel != CodeGenOpt::None) { |
Bill Wendling | cc8f603 | 2008-01-04 08:11:03 +0000 | [diff] [blame] | 183 | PM.add(createMachineLICMPass()); |
Chris Lattner | 3c42f12 | 2008-01-05 06:14:16 +0000 | [diff] [blame] | 184 | PM.add(createMachineSinkingPass()); |
Evan Cheng | 8f0d99e | 2009-02-09 08:45:39 +0000 | [diff] [blame] | 185 | } |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 186 | |
Anton Korobeynikov | b013f50 | 2008-04-23 18:26:03 +0000 | [diff] [blame] | 187 | // Run pre-ra passes. |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 188 | if (addPreRegAlloc(PM, OptLevel) && PrintMachineCode) |
Anton Korobeynikov | b013f50 | 2008-04-23 18:26:03 +0000 | [diff] [blame] | 189 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 190 | |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 191 | // Perform register allocation. |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 192 | PM.add(createRegisterAllocator()); |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 193 | |
| 194 | // Perform stack slot coloring. |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 195 | if (OptLevel != CodeGenOpt::None) |
Evan Cheng | 9ef4c53 | 2008-06-30 22:33:16 +0000 | [diff] [blame] | 196 | PM.add(createStackSlotColoringPass()); |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 197 | |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 198 | if (PrintMachineCode) // Print the register-allocated code |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 199 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 200 | |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 201 | // Run post-ra passes. |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 202 | if (addPostRegAlloc(PM, OptLevel) && PrintMachineCode) |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 203 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 204 | |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 205 | if (PrintMachineCode) |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 206 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 207 | |
Christopher Lamb | ada779f | 2007-07-27 07:36:14 +0000 | [diff] [blame] | 208 | PM.add(createLowerSubregsPass()); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 209 | |
Christopher Lamb | ada779f | 2007-07-27 07:36:14 +0000 | [diff] [blame] | 210 | if (PrintMachineCode) // Print the subreg lowered code |
| 211 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 212 | |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 213 | // Insert prolog/epilog code. Eliminate abstract frame index references... |
| 214 | PM.add(createPrologEpilogCodeInserter()); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 215 | |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 216 | if (PrintMachineCode) |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 217 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 218 | |
Dale Johannesen | e7e7d0d | 2007-07-13 17:13:54 +0000 | [diff] [blame] | 219 | // Second pass scheduler. |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 220 | if (OptLevel != CodeGenOpt::None && !DisablePostRAScheduler) { |
Dale Johannesen | 72f1596 | 2007-07-13 17:31:29 +0000 | [diff] [blame] | 221 | PM.add(createPostRAScheduler()); |
Dale Johannesen | e7e7d0d | 2007-07-13 17:13:54 +0000 | [diff] [blame] | 222 | |
Dan Gohman | 5ce0973 | 2008-11-20 19:54:21 +0000 | [diff] [blame] | 223 | if (PrintMachineCode) |
| 224 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 225 | } |
| 226 | |
Dan Gohman | 23b0d49 | 2008-12-18 01:36:42 +0000 | [diff] [blame] | 227 | // Branch folding must be run after regalloc and prolog/epilog insertion. |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame^] | 228 | if (OptLevel != CodeGenOpt::None) |
Dan Gohman | 23b0d49 | 2008-12-18 01:36:42 +0000 | [diff] [blame] | 229 | PM.add(createBranchFoldingPass(getEnableTailMergeDefault())); |
| 230 | |
| 231 | if (PrintMachineCode) |
| 232 | PM.add(createMachineFunctionPrinterPass(cerr)); |
| 233 | |
Gordon Henriksen | 93f96d0 | 2008-01-07 01:33:09 +0000 | [diff] [blame] | 234 | PM.add(createGCMachineCodeAnalysisPass()); |
Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 235 | |
Gordon Henriksen | 93f96d0 | 2008-01-07 01:33:09 +0000 | [diff] [blame] | 236 | if (PrintMachineCode) |
| 237 | PM.add(createMachineFunctionPrinterPass(cerr)); |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 238 | |
Gordon Henriksen | 93f96d0 | 2008-01-07 01:33:09 +0000 | [diff] [blame] | 239 | if (PrintGCInfo) |
Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 240 | PM.add(createGCInfoPrinter(*cerr)); |
Bill Wendling | 04523ea | 2007-02-08 01:36:53 +0000 | [diff] [blame] | 241 | |
Dan Gohman | 02dae4b | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 242 | return false; |
Chris Lattner | 4787705 | 2006-09-04 04:16:09 +0000 | [diff] [blame] | 243 | } |