Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 1 | //===-- PTXTargetMachine.h - Define TargetMachine for PTX -------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the PTX specific subclass of TargetMachine. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PTX_TARGET_MACHINE_H |
| 15 | #define PTX_TARGET_MACHINE_H |
| 16 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 17 | #include "PTXISelLowering.h" |
| 18 | #include "PTXInstrInfo.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 19 | #include "PTXFrameLowering.h" |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 20 | #include "PTXSelectionDAGInfo.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 21 | #include "PTXSubtarget.h" |
| 22 | #include "llvm/Target/TargetData.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetFrameLowering.h" |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 24 | #include "llvm/Target/TargetMachine.h" |
| 25 | |
| 26 | namespace llvm { |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 27 | class PTXTargetMachine : public LLVMTargetMachine { |
| 28 | private: |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 29 | const TargetData DataLayout; |
| 30 | PTXSubtarget Subtarget; // has to be initialized before FrameLowering |
| 31 | PTXFrameLowering FrameLowering; |
| 32 | PTXInstrInfo InstrInfo; |
| 33 | PTXSelectionDAGInfo TSInfo; |
| 34 | PTXTargetLowering TLInfo; |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 35 | |
| 36 | public: |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 37 | PTXTargetMachine(const Target &T, StringRef TT, |
Nick Lewycky | 8a8d479 | 2011-12-02 22:16:29 +0000 | [diff] [blame] | 38 | StringRef CPU, StringRef FS, const TargetOptions &Options, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 39 | Reloc::Model RM, CodeModel::Model CM, |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame] | 40 | CodeGenOpt::Level OL, |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 41 | bool is64Bit); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 42 | |
| 43 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 44 | |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 45 | virtual const TargetFrameLowering *getFrameLowering() const { |
| 46 | return &FrameLowering; |
| 47 | } |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 48 | |
| 49 | virtual const PTXInstrInfo *getInstrInfo() const { return &InstrInfo; } |
| 50 | virtual const TargetRegisterInfo *getRegisterInfo() const { |
| 51 | return &InstrInfo.getRegisterInfo(); } |
| 52 | |
| 53 | virtual const PTXTargetLowering *getTargetLowering() const { |
| 54 | return &TLInfo; } |
| 55 | |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 56 | virtual const PTXSelectionDAGInfo* getSelectionDAGInfo() const { |
| 57 | return &TSInfo; |
| 58 | } |
| 59 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 60 | virtual const PTXSubtarget *getSubtargetImpl() const { return &Subtarget; } |
| 61 | |
Justin Holewinski | 40466cc | 2011-09-22 16:45:37 +0000 | [diff] [blame] | 62 | // We override this method to supply our own set of codegen passes. |
| 63 | virtual bool addPassesToEmitFile(PassManagerBase &, |
| 64 | formatted_raw_ostream &, |
| 65 | CodeGenFileType, |
Justin Holewinski | 40466cc | 2011-09-22 16:45:37 +0000 | [diff] [blame] | 66 | bool = true); |
| 67 | |
| 68 | // Emission of machine code through JITCodeEmitter is not supported. |
| 69 | virtual bool addPassesToEmitMachineCode(PassManagerBase &, |
| 70 | JITCodeEmitter &, |
Justin Holewinski | 40466cc | 2011-09-22 16:45:37 +0000 | [diff] [blame] | 71 | bool = true) { |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | // Emission of machine code through MCJIT is not supported. |
| 76 | virtual bool addPassesToEmitMC(PassManagerBase &, |
| 77 | MCContext *&, |
| 78 | raw_ostream &, |
Justin Holewinski | 40466cc | 2011-09-22 16:45:37 +0000 | [diff] [blame] | 79 | bool = true) { |
| 80 | return true; |
| 81 | } |
| 82 | |
Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 83 | // Pass Pipeline Configuration |
Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame^] | 84 | virtual TargetPassConfig *createPassConfig(PassManagerBase &PM); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 85 | }; // class PTXTargetMachine |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 86 | |
| 87 | |
| 88 | class PTX32TargetMachine : public PTXTargetMachine { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 89 | virtual void anchor(); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 90 | public: |
| 91 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 92 | PTX32TargetMachine(const Target &T, StringRef TT, |
Nick Lewycky | 8a8d479 | 2011-12-02 22:16:29 +0000 | [diff] [blame] | 93 | StringRef CPU, StringRef FS, const TargetOptions &Options, |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame] | 94 | Reloc::Model RM, CodeModel::Model CM, |
| 95 | CodeGenOpt::Level OL); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 96 | }; // class PTX32TargetMachine |
| 97 | |
| 98 | class PTX64TargetMachine : public PTXTargetMachine { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 99 | virtual void anchor(); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 100 | public: |
| 101 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 102 | PTX64TargetMachine(const Target &T, StringRef TT, |
Nick Lewycky | 8a8d479 | 2011-12-02 22:16:29 +0000 | [diff] [blame] | 103 | StringRef CPU, StringRef FS, const TargetOptions &Options, |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame] | 104 | Reloc::Model RM, CodeModel::Model CM, |
| 105 | CodeGenOpt::Level OL); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 106 | }; // class PTX32TargetMachine |
| 107 | |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 108 | } // namespace llvm |
| 109 | |
| 110 | #endif // PTX_TARGET_MACHINE_H |