Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 1 | //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===// |
| 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 |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the ARM specific subclass of TargetMachine. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef ARMTARGETMACHINE_H |
| 15 | #define ARMTARGETMACHINE_H |
| 16 | |
| 17 | #include "llvm/Target/TargetMachine.h" |
| 18 | #include "llvm/Target/TargetData.h" |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 19 | #include "ARMInstrInfo.h" |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 20 | #include "ARMFrameInfo.h" |
Evan Cheng | 148b6a4 | 2007-07-05 21:15:40 +0000 | [diff] [blame] | 21 | #include "ARMJITInfo.h" |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 22 | #include "ARMSubtarget.h" |
Evan Cheng | e8308df | 2007-03-13 01:20:42 +0000 | [diff] [blame] | 23 | #include "ARMISelLowering.h" |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 24 | #include "Thumb1InstrInfo.h" |
| 25 | #include "Thumb2InstrInfo.h" |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 26 | |
| 27 | namespace llvm { |
| 28 | |
| 29 | class Module; |
| 30 | |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 31 | class ARMBaseTargetMachine : public LLVMTargetMachine { |
| 32 | protected: |
Evan Cheng | 8557c2b | 2009-06-19 01:51:50 +0000 | [diff] [blame] | 33 | ARMSubtarget Subtarget; |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 34 | |
| 35 | private: |
Evan Cheng | 8557c2b | 2009-06-19 01:51:50 +0000 | [diff] [blame] | 36 | ARMFrameInfo FrameInfo; |
| 37 | ARMJITInfo JITInfo; |
Evan Cheng | 8557c2b | 2009-06-19 01:51:50 +0000 | [diff] [blame] | 38 | InstrItineraryData InstrItins; |
| 39 | Reloc::Model DefRelocModel; // Reloc model before it's overridden. |
Evan Cheng | e8308df | 2007-03-13 01:20:42 +0000 | [diff] [blame] | 40 | |
Anton Korobeynikov | 0bd8971 | 2008-08-17 13:55:10 +0000 | [diff] [blame] | 41 | protected: |
| 42 | // To avoid having target depend on the asmprinter stuff libraries, asmprinter |
| 43 | // set this functions to ctor pointer at startup time if they are linked in. |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame^] | 44 | typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o, |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 45 | ARMBaseTargetMachine &tm, |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 46 | bool verbose); |
Anton Korobeynikov | 0bd8971 | 2008-08-17 13:55:10 +0000 | [diff] [blame] | 47 | static AsmPrinterCtorFn AsmPrinterCtor; |
| 48 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 49 | public: |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 50 | ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb); |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 51 | |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 52 | virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; } |
| 53 | virtual ARMJITInfo *getJITInfo() { return &JITInfo; } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 54 | virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; } |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 55 | virtual const InstrItineraryData getInstrItineraryData() const { |
Evan Cheng | 8557c2b | 2009-06-19 01:51:50 +0000 | [diff] [blame] | 56 | return InstrItins; |
| 57 | } |
Anton Korobeynikov | 0bd8971 | 2008-08-17 13:55:10 +0000 | [diff] [blame] | 58 | |
| 59 | static void registerAsmPrinter(AsmPrinterCtorFn F) { |
| 60 | AsmPrinterCtor = F; |
| 61 | } |
| 62 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 63 | static unsigned getModuleMatchQuality(const Module &M); |
Evan Cheng | 148b6a4 | 2007-07-05 21:15:40 +0000 | [diff] [blame] | 64 | static unsigned getJITMatchQuality(); |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 65 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 66 | virtual const TargetAsmInfo *createTargetAsmInfo() const; |
Anton Korobeynikov | 0bd8971 | 2008-08-17 13:55:10 +0000 | [diff] [blame] | 67 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 68 | // Pass Pipeline Configuration |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 69 | virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
Evan Cheng | e7d6df7 | 2009-06-13 09:12:55 +0000 | [diff] [blame] | 70 | virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 71 | virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
| 72 | virtual bool addAssemblyEmitter(PassManagerBase &PM, |
| 73 | CodeGenOpt::Level OptLevel, |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame^] | 74 | bool Verbose, formatted_raw_ostream &Out); |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 75 | virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, |
Evan Cheng | 8bd6035 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 76 | bool DumpAsm, MachineCodeEmitter &MCE); |
Bruno Cardoso Lopes | a3f99f9 | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 77 | virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, |
| 78 | bool DumpAsm, JITCodeEmitter &MCE); |
Bruno Cardoso Lopes | ac57e6e | 2009-07-06 05:09:34 +0000 | [diff] [blame] | 79 | virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, |
| 80 | bool DumpAsm, ObjectCodeEmitter &OCE); |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 81 | virtual bool addSimpleCodeEmitter(PassManagerBase &PM, |
| 82 | CodeGenOpt::Level OptLevel, |
| 83 | bool DumpAsm, |
| 84 | MachineCodeEmitter &MCE); |
Bruno Cardoso Lopes | a3f99f9 | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 85 | virtual bool addSimpleCodeEmitter(PassManagerBase &PM, |
| 86 | CodeGenOpt::Level OptLevel, |
| 87 | bool DumpAsm, |
| 88 | JITCodeEmitter &MCE); |
Bruno Cardoso Lopes | ac57e6e | 2009-07-06 05:09:34 +0000 | [diff] [blame] | 89 | virtual bool addSimpleCodeEmitter(PassManagerBase &PM, |
| 90 | CodeGenOpt::Level OptLevel, |
| 91 | bool DumpAsm, |
| 92 | ObjectCodeEmitter &OCE); |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 95 | /// ARMTargetMachine - ARM target machine. |
| 96 | /// |
| 97 | class ARMTargetMachine : public ARMBaseTargetMachine { |
| 98 | ARMInstrInfo InstrInfo; |
| 99 | const TargetData DataLayout; // Calculates type size & alignment |
| 100 | ARMTargetLowering TLInfo; |
| 101 | public: |
| 102 | ARMTargetMachine(const Module &M, const std::string &FS); |
| 103 | |
| 104 | virtual const ARMRegisterInfo *getRegisterInfo() const { |
| 105 | return &InstrInfo.getRegisterInfo(); |
| 106 | } |
| 107 | |
| 108 | virtual ARMTargetLowering *getTargetLowering() const { |
| 109 | return const_cast<ARMTargetLowering*>(&TLInfo); |
| 110 | } |
| 111 | |
| 112 | virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; } |
| 113 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 114 | |
| 115 | static unsigned getJITMatchQuality(); |
| 116 | static unsigned getModuleMatchQuality(const Module &M); |
| 117 | }; |
| 118 | |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 119 | /// ThumbTargetMachine - Thumb target machine. |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 120 | /// Due to the way architectures are handled, this represents both |
| 121 | /// Thumb-1 and Thumb-2. |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 122 | /// |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 123 | class ThumbTargetMachine : public ARMBaseTargetMachine { |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 124 | ARMBaseInstrInfo *InstrInfo; // either Thumb1InstrInfo or Thumb2InstrInfo |
| 125 | const TargetData DataLayout; // Calculates type size & alignment |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 126 | ARMTargetLowering TLInfo; |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 127 | public: |
| 128 | ThumbTargetMachine(const Module &M, const std::string &FS); |
| 129 | |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 130 | /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo |
| 131 | virtual const ARMBaseRegisterInfo *getRegisterInfo() const { |
| 132 | return &InstrInfo->getRegisterInfo(); |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 133 | } |
| 134 | |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 135 | virtual ARMTargetLowering *getTargetLowering() const { |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 136 | return const_cast<ARMTargetLowering*>(&TLInfo); |
| 137 | } |
| 138 | |
David Goodwin | b50ea5c | 2009-07-02 22:18:33 +0000 | [diff] [blame] | 139 | /// returns either Thumb1InstrInfo or Thumb2InstrInfo |
| 140 | virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; } |
Anton Korobeynikov | d49ea77 | 2009-06-26 21:28:53 +0000 | [diff] [blame] | 141 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 142 | |
Evan Cheng | 148b6a4 | 2007-07-05 21:15:40 +0000 | [diff] [blame] | 143 | static unsigned getJITMatchQuality(); |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 144 | static unsigned getModuleMatchQuality(const Module &M); |
| 145 | }; |
| 146 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 147 | } // end namespace llvm |
| 148 | |
| 149 | #endif |