Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 84e66db | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the TargetMachine and LLVMTargetMachine classes. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TARGET_TARGETMACHINE_H |
| 15 | #define LLVM_TARGET_TARGETMACHINE_H |
| 16 | |
| 17 | #include "llvm/Target/TargetInstrItineraries.h" |
| 18 | #include <cassert> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class TargetAsmInfo; |
| 23 | class TargetData; |
| 24 | class TargetSubtarget; |
| 25 | class TargetInstrInfo; |
Dale Johannesen | fe5921a | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 26 | class TargetIntrinsicInfo; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | class TargetJITInfo; |
| 28 | class TargetLowering; |
| 29 | class TargetFrameInfo; |
| 30 | class MachineCodeEmitter; |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 31 | class JITCodeEmitter; |
Dan Gohman | 1e57df3 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 32 | class TargetRegisterInfo; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 33 | class Module; |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 34 | class PassManagerBase; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 35 | class PassManager; |
| 36 | class Pass; |
| 37 | class TargetMachOWriterInfo; |
| 38 | class TargetELFWriterInfo; |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 39 | class raw_ostream; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | |
| 41 | // Relocation model types. |
| 42 | namespace Reloc { |
| 43 | enum Model { |
| 44 | Default, |
| 45 | Static, |
| 46 | PIC_, // Cannot be named PIC due to collision with -DPIC |
| 47 | DynamicNoPIC |
| 48 | }; |
| 49 | } |
| 50 | |
| 51 | // Code model types. |
| 52 | namespace CodeModel { |
| 53 | enum Model { |
| 54 | Default, |
| 55 | Small, |
| 56 | Kernel, |
| 57 | Medium, |
| 58 | Large |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | namespace FileModel { |
| 63 | enum Model { |
| 64 | Error, |
| 65 | None, |
| 66 | AsmFile, |
| 67 | MachOFile, |
| 68 | ElfFile |
| 69 | }; |
| 70 | } |
| 71 | |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 72 | // Code generation optimization level. |
| 73 | namespace CodeGenOpt { |
| 74 | enum Level { |
| 75 | Default, |
| 76 | None, |
Bill Wendling | 2d1c116 | 2009-04-29 23:40:42 +0000 | [diff] [blame] | 77 | Aggressive |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 78 | }; |
| 79 | } |
| 80 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 81 | //===----------------------------------------------------------------------===// |
| 82 | /// |
| 83 | /// TargetMachine - Primary interface to the complete machine description for |
| 84 | /// the target machine. All target-specific information should be accessible |
| 85 | /// through this interface. |
| 86 | /// |
| 87 | class TargetMachine { |
| 88 | TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT |
| 89 | void operator=(const TargetMachine &); // DO NOT IMPLEMENT |
| 90 | protected: // Can only create subclasses. |
Dan Gohman | c24a3f8 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 91 | TargetMachine() : AsmInfo(0) { } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 92 | |
| 93 | /// getSubtargetImpl - virtual method implemented by subclasses that returns |
| 94 | /// a reference to that target's TargetSubtarget-derived member variable. |
| 95 | virtual const TargetSubtarget *getSubtargetImpl() const { return 0; } |
| 96 | |
| 97 | /// AsmInfo - Contains target specific asm information. |
| 98 | /// |
| 99 | mutable const TargetAsmInfo *AsmInfo; |
| 100 | |
| 101 | /// createTargetAsmInfo - Create a new instance of target specific asm |
| 102 | /// information. |
Dan Gohman | c24a3f8 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 103 | virtual const TargetAsmInfo *createTargetAsmInfo() const { return 0; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 104 | |
| 105 | public: |
| 106 | virtual ~TargetMachine(); |
| 107 | |
| 108 | /// getModuleMatchQuality - This static method should be implemented by |
| 109 | /// targets to indicate how closely they match the specified module. This is |
| 110 | /// used by the LLC tool to determine which target to use when an explicit |
| 111 | /// -march option is not specified. If a target returns zero, it will never |
| 112 | /// be chosen without an explicit -march option. |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 113 | static unsigned getModuleMatchQuality(const Module &) { return 0; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 114 | |
| 115 | /// getJITMatchQuality - This static method should be implemented by targets |
| 116 | /// that provide JIT capabilities to indicate how suitable they are for |
| 117 | /// execution on the current host. If a value of 0 is returned, the target |
| 118 | /// will not be used unless an explicit -march option is used. |
| 119 | static unsigned getJITMatchQuality() { return 0; } |
| 120 | |
| 121 | // Interfaces to the major aspects of target machine information: |
| 122 | // -- Instruction opcode and operand information |
| 123 | // -- Pipelines and scheduling information |
| 124 | // -- Stack frame information |
| 125 | // -- Selection DAG lowering information |
| 126 | // |
| 127 | virtual const TargetInstrInfo *getInstrInfo() const { return 0; } |
| 128 | virtual const TargetFrameInfo *getFrameInfo() const { return 0; } |
| 129 | virtual TargetLowering *getTargetLowering() const { return 0; } |
| 130 | virtual const TargetData *getTargetData() const { return 0; } |
| 131 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 132 | /// getTargetAsmInfo - Return target specific asm information. |
| 133 | /// |
| 134 | const TargetAsmInfo *getTargetAsmInfo() const { |
| 135 | if (!AsmInfo) AsmInfo = createTargetAsmInfo(); |
| 136 | return AsmInfo; |
| 137 | } |
| 138 | |
| 139 | /// getSubtarget - This method returns a pointer to the specified type of |
| 140 | /// TargetSubtarget. In debug builds, it verifies that the object being |
| 141 | /// returned is of the correct type. |
| 142 | template<typename STC> const STC &getSubtarget() const { |
| 143 | const TargetSubtarget *TST = getSubtargetImpl(); |
| 144 | assert(TST && dynamic_cast<const STC*>(TST) && |
| 145 | "Not the right kind of subtarget!"); |
| 146 | return *static_cast<const STC*>(TST); |
| 147 | } |
| 148 | |
| 149 | /// getRegisterInfo - If register information is available, return it. If |
| 150 | /// not, return null. This is kept separate from RegInfo until RegInfo has |
| 151 | /// details of graph coloring register allocation removed from it. |
| 152 | /// |
Dan Gohman | 1e57df3 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 153 | virtual const TargetRegisterInfo *getRegisterInfo() const { return 0; } |
Dale Johannesen | fe5921a | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 154 | |
| 155 | /// getIntrinsicInfo - If intrinsic information is available, return it. If |
| 156 | /// not, return null. |
| 157 | /// |
| 158 | virtual const TargetIntrinsicInfo *getIntrinsicInfo() const { return 0; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 159 | |
| 160 | /// getJITInfo - If this target supports a JIT, return information for it, |
| 161 | /// otherwise return null. |
| 162 | /// |
| 163 | virtual TargetJITInfo *getJITInfo() { return 0; } |
| 164 | |
| 165 | /// getInstrItineraryData - Returns instruction itinerary data for the target |
| 166 | /// or specific subtarget. |
| 167 | /// |
| 168 | virtual const InstrItineraryData getInstrItineraryData() const { |
| 169 | return InstrItineraryData(); |
| 170 | } |
| 171 | |
| 172 | /// getMachOWriterInfo - If this target supports a Mach-O writer, return |
| 173 | /// information for it, otherwise return null. |
| 174 | /// |
| 175 | virtual const TargetMachOWriterInfo *getMachOWriterInfo() const { return 0; } |
| 176 | |
| 177 | /// getELFWriterInfo - If this target supports an ELF writer, return |
| 178 | /// information for it, otherwise return null. |
| 179 | /// |
| 180 | virtual const TargetELFWriterInfo *getELFWriterInfo() const { return 0; } |
| 181 | |
| 182 | /// getRelocationModel - Returns the code generation relocation model. The |
| 183 | /// choices are static, PIC, and dynamic-no-pic, and target default. |
| 184 | static Reloc::Model getRelocationModel(); |
| 185 | |
| 186 | /// setRelocationModel - Sets the code generation relocation model. |
Evan Cheng | 42ceb47 | 2009-03-25 01:47:28 +0000 | [diff] [blame] | 187 | /// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 188 | static void setRelocationModel(Reloc::Model Model); |
| 189 | |
| 190 | /// getCodeModel - Returns the code model. The choices are small, kernel, |
| 191 | /// medium, large, and target default. |
| 192 | static CodeModel::Model getCodeModel(); |
| 193 | |
| 194 | /// setCodeModel - Sets the code model. |
Evan Cheng | 42ceb47 | 2009-03-25 01:47:28 +0000 | [diff] [blame] | 195 | /// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 196 | static void setCodeModel(CodeModel::Model Model); |
| 197 | |
Evan Cheng | 42ceb47 | 2009-03-25 01:47:28 +0000 | [diff] [blame] | 198 | /// getAsmVerbosityDefault - Returns the default value of asm verbosity. |
| 199 | /// |
| 200 | static bool getAsmVerbosityDefault(); |
| 201 | |
| 202 | /// setAsmVerbosityDefault - Set the default value of asm verbosity. Default |
| 203 | /// is false. |
| 204 | static void setAsmVerbosityDefault(bool); |
| 205 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 206 | /// CodeGenFileType - These enums are meant to be passed into |
| 207 | /// addPassesToEmitFile to indicate what type of file to emit. |
| 208 | enum CodeGenFileType { |
| 209 | AssemblyFile, ObjectFile, DynamicLibrary |
| 210 | }; |
| 211 | |
| 212 | /// getEnableTailMergeDefault - the default setting for -enable-tail-merge |
| 213 | /// on this target. User flag overrides. |
Dan Gohman | 62ea18a | 2007-11-19 20:46:23 +0000 | [diff] [blame] | 214 | virtual bool getEnableTailMergeDefault() const { return true; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 215 | |
| 216 | /// addPassesToEmitFile - Add passes to the specified pass manager to get the |
| 217 | /// specified file emitted. Typically this will involve several steps of code |
| 218 | /// generation. If Fast is set to true, the code generator should emit code |
Dan Gohman | 96b02c2 | 2007-07-30 15:04:59 +0000 | [diff] [blame] | 219 | /// as fast as possible, though the generated code may be less efficient. |
| 220 | /// This method should return FileModel::Error if emission of this file type |
| 221 | /// is not supported. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 222 | /// |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 223 | virtual FileModel::Model addPassesToEmitFile(PassManagerBase &, |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 224 | raw_ostream &, |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 225 | CodeGenFileType, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 226 | CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 227 | return FileModel::None; |
| 228 | } |
| 229 | |
| 230 | /// addPassesToEmitFileFinish - If the passes to emit the specified file had |
| 231 | /// to be split up (e.g., to add an object writer pass), this method can be |
| 232 | /// used to finish up adding passes to emit the file, if necessary. |
| 233 | /// |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 234 | virtual bool addPassesToEmitFileFinish(PassManagerBase &, |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 235 | MachineCodeEmitter *, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 236 | CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 237 | return true; |
| 238 | } |
| 239 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 240 | /// addPassesToEmitFileFinish - If the passes to emit the specified file had |
| 241 | /// to be split up (e.g., to add an object writer pass), this method can be |
| 242 | /// used to finish up adding passes to emit the file, if necessary. |
| 243 | /// |
| 244 | virtual bool addPassesToEmitFileFinish(PassManagerBase &, |
| 245 | JITCodeEmitter *, |
| 246 | CodeGenOpt::Level) { |
| 247 | return true; |
| 248 | } |
| 249 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 250 | /// addPassesToEmitMachineCode - Add passes to the specified pass manager to |
| 251 | /// get machine code emitted. This uses a MachineCodeEmitter object to handle |
| 252 | /// actually outputting the machine code and resolving things like the address |
| 253 | /// of functions. This method returns true if machine code emission is |
| 254 | /// not supported. |
| 255 | /// |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 256 | virtual bool addPassesToEmitMachineCode(PassManagerBase &, |
| 257 | MachineCodeEmitter &, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 258 | CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 259 | return true; |
| 260 | } |
| 261 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 262 | /// addPassesToEmitMachineCode - Add passes to the specified pass manager to |
| 263 | /// get machine code emitted. This uses a MachineCodeEmitter object to handle |
| 264 | /// actually outputting the machine code and resolving things like the address |
| 265 | /// of functions. This method returns true if machine code emission is |
| 266 | /// not supported. |
| 267 | /// |
| 268 | virtual bool addPassesToEmitMachineCode(PassManagerBase &, |
| 269 | JITCodeEmitter &, |
| 270 | CodeGenOpt::Level) { |
| 271 | return true; |
| 272 | } |
| 273 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 274 | /// addPassesToEmitWholeFile - This method can be implemented by targets that |
| 275 | /// require having the entire module at once. This is not recommended, do not |
| 276 | /// use this. |
| 277 | virtual bool WantsWholeFile() const { return false; } |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 278 | virtual bool addPassesToEmitWholeFile(PassManager &, raw_ostream &, |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 279 | CodeGenFileType, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 280 | CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 281 | return true; |
| 282 | } |
| 283 | }; |
| 284 | |
| 285 | /// LLVMTargetMachine - This class describes a target machine that is |
| 286 | /// implemented with the LLVM target-independent code generator. |
| 287 | /// |
| 288 | class LLVMTargetMachine : public TargetMachine { |
| 289 | protected: // Can only create subclasses. |
Dan Gohman | 7e71ccf | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 290 | LLVMTargetMachine() { } |
| 291 | |
| 292 | /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for |
| 293 | /// both emitting to assembly files or machine code output. |
| 294 | /// |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 295 | bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level); |
Dan Gohman | 7e71ccf | 2008-09-25 00:37:07 +0000 | [diff] [blame] | 296 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 297 | public: |
| 298 | |
| 299 | /// addPassesToEmitFile - Add passes to the specified pass manager to get the |
| 300 | /// specified file emitted. Typically this will involve several steps of code |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 301 | /// generation. If OptLevel is None, the code generator should emit code as fast |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 302 | /// as possible, though the generated code may be less efficient. This method |
| 303 | /// should return FileModel::Error if emission of this file type is not |
| 304 | /// supported. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 305 | /// |
| 306 | /// The default implementation of this method adds components from the |
| 307 | /// LLVM retargetable code generator, invoking the methods below to get |
| 308 | /// target-specific passes in standard locations. |
| 309 | /// |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 310 | virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM, |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 311 | raw_ostream &Out, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 312 | CodeGenFileType FileType, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 313 | CodeGenOpt::Level); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 314 | |
| 315 | /// addPassesToEmitFileFinish - If the passes to emit the specified file had |
| 316 | /// to be split up (e.g., to add an object writer pass), this method can be |
| 317 | /// used to finish up adding passes to emit the file, if necessary. |
| 318 | /// |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 319 | virtual bool addPassesToEmitFileFinish(PassManagerBase &PM, |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 320 | MachineCodeEmitter *MCE, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 321 | CodeGenOpt::Level); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 322 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 323 | /// addPassesToEmitFileFinish - If the passes to emit the specified file had |
| 324 | /// to be split up (e.g., to add an object writer pass), this method can be |
| 325 | /// used to finish up adding passes to emit the file, if necessary. |
| 326 | /// |
| 327 | virtual bool addPassesToEmitFileFinish(PassManagerBase &PM, |
| 328 | JITCodeEmitter *MCE, |
| 329 | CodeGenOpt::Level); |
| 330 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 331 | /// addPassesToEmitMachineCode - Add passes to the specified pass manager to |
| 332 | /// get machine code emitted. This uses a MachineCodeEmitter object to handle |
| 333 | /// actually outputting the machine code and resolving things like the address |
| 334 | /// of functions. This method returns true if machine code emission is |
| 335 | /// not supported. |
| 336 | /// |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 337 | virtual bool addPassesToEmitMachineCode(PassManagerBase &PM, |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 338 | MachineCodeEmitter &MCE, |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 339 | CodeGenOpt::Level); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 340 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 341 | /// addPassesToEmitMachineCode - Add passes to the specified pass manager to |
| 342 | /// get machine code emitted. This uses a MachineCodeEmitter object to handle |
| 343 | /// actually outputting the machine code and resolving things like the address |
| 344 | /// of functions. This method returns true if machine code emission is |
| 345 | /// not supported. |
| 346 | /// |
| 347 | virtual bool addPassesToEmitMachineCode(PassManagerBase &PM, |
| 348 | JITCodeEmitter &MCE, |
| 349 | CodeGenOpt::Level); |
| 350 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 351 | /// Target-Independent Code Generator Pass Configuration Options. |
| 352 | |
| 353 | /// addInstSelector - This method should add any "last minute" LLVM->LLVM |
| 354 | /// passes, then install an instruction selector pass, which converts from |
| 355 | /// LLVM code to machine instructions. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 356 | virtual bool addInstSelector(PassManagerBase &, CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 357 | return true; |
| 358 | } |
Anton Korobeynikov | 339d245 | 2008-04-23 18:22:28 +0000 | [diff] [blame] | 359 | |
| 360 | /// addPreRegAllocPasses - This method may be implemented by targets that want |
| 361 | /// to run passes immediately before register allocation. This should return |
| 362 | /// true if -print-machineinstrs should print after these passes. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 363 | virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level) { |
Anton Korobeynikov | 339d245 | 2008-04-23 18:22:28 +0000 | [diff] [blame] | 364 | return false; |
| 365 | } |
| 366 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 367 | /// addPostRegAllocPasses - This method may be implemented by targets that |
| 368 | /// want to run passes after register allocation but before prolog-epilog |
| 369 | /// insertion. This should return true if -print-machineinstrs should print |
| 370 | /// after these passes. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 371 | virtual bool addPostRegAlloc(PassManagerBase &, CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 372 | return false; |
| 373 | } |
| 374 | |
| 375 | /// addPreEmitPass - This pass may be implemented by targets that want to run |
| 376 | /// passes immediately before machine code is emitted. This should return |
| 377 | /// true if -print-machineinstrs should print out the code after the passes. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 378 | virtual bool addPreEmitPass(PassManagerBase &, CodeGenOpt::Level) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 379 | return false; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | /// addAssemblyEmitter - This pass should be overridden by the target to add |
| 384 | /// the asmprinter, if asm emission is supported. If this is not supported, |
| 385 | /// 'true' should be returned. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 386 | virtual bool addAssemblyEmitter(PassManagerBase &, CodeGenOpt::Level, |
Evan Cheng | 42ceb47 | 2009-03-25 01:47:28 +0000 | [diff] [blame] | 387 | bool /* VerboseAsmDefault */, raw_ostream &) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 388 | return true; |
| 389 | } |
| 390 | |
| 391 | /// addCodeEmitter - This pass should be overridden by the target to add a |
| 392 | /// code emitter, if supported. If this is not supported, 'true' should be |
Evan Cheng | 7754721 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 393 | /// returned. If DumpAsm is true, the generated assembly is printed to cerr. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 394 | virtual bool addCodeEmitter(PassManagerBase &, CodeGenOpt::Level, |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 395 | bool /*DumpAsm*/, MachineCodeEmitter &) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 396 | return true; |
| 397 | } |
| 398 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 399 | /// addCodeEmitter - This pass should be overridden by the target to add a |
| 400 | /// code emitter, if supported. If this is not supported, 'true' should be |
| 401 | /// returned. If DumpAsm is true, the generated assembly is printed to cerr. |
| 402 | virtual bool addCodeEmitter(PassManagerBase &, CodeGenOpt::Level, |
| 403 | bool /*DumpAsm*/, JITCodeEmitter &) { |
| 404 | return true; |
| 405 | } |
| 406 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 407 | /// addSimpleCodeEmitter - This pass should be overridden by the target to add |
| 408 | /// a code emitter (without setting flags), if supported. If this is not |
Evan Cheng | 7754721 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 409 | /// supported, 'true' should be returned. If DumpAsm is true, the generated |
| 410 | /// assembly is printed to cerr. |
Bill Wendling | 5ed22ac | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 411 | virtual bool addSimpleCodeEmitter(PassManagerBase &, CodeGenOpt::Level, |
Bill Wendling | 51bacec | 2008-05-19 20:15:12 +0000 | [diff] [blame] | 412 | bool /*DumpAsm*/, MachineCodeEmitter &) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 413 | return true; |
| 414 | } |
| 415 | |
Bruno Cardoso Lopes | 1ea31ff | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 416 | /// addSimpleCodeEmitter - This pass should be overridden by the target to add |
| 417 | /// a code emitter (without setting flags), if supported. If this is not |
| 418 | /// supported, 'true' should be returned. If DumpAsm is true, the generated |
| 419 | /// assembly is printed to cerr. |
| 420 | virtual bool addSimpleCodeEmitter(PassManagerBase &, CodeGenOpt::Level, |
| 421 | bool /*DumpAsm*/, JITCodeEmitter &) { |
| 422 | return true; |
| 423 | } |
| 424 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 425 | /// getEnableTailMergeDefault - the default setting for -enable-tail-merge |
| 426 | /// on this target. User flag overrides. |
Dan Gohman | 62ea18a | 2007-11-19 20:46:23 +0000 | [diff] [blame] | 427 | virtual bool getEnableTailMergeDefault() const { return true; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 428 | }; |
| 429 | |
| 430 | } // End llvm namespace |
| 431 | |
| 432 | #endif |