Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 1 | //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- 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 NVPTX specific subclass of TargetMachine. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | |
| 15 | #ifndef NVPTX_TARGETMACHINE_H |
| 16 | #define NVPTX_TARGETMACHINE_H |
| 17 | |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 18 | #include "ManagedStringPool.h" |
| 19 | #include "NVPTXFrameLowering.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 20 | #include "NVPTXISelLowering.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 21 | #include "NVPTXInstrInfo.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 22 | #include "NVPTXRegisterInfo.h" |
| 23 | #include "NVPTXSubtarget.h" |
Chandler Carruth | 0b8c9a8 | 2013-01-02 11:36:10 +0000 | [diff] [blame^] | 24 | #include "llvm/IR/DataLayout.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 25 | #include "llvm/Target/TargetFrameLowering.h" |
| 26 | #include "llvm/Target/TargetMachine.h" |
| 27 | #include "llvm/Target/TargetSelectionDAGInfo.h" |
Nadav Rotem | cbd9a19 | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 28 | #include "llvm/Target/TargetTransformImpl.h" |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 29 | |
| 30 | namespace llvm { |
| 31 | |
| 32 | /// NVPTXTargetMachine |
| 33 | /// |
| 34 | class NVPTXTargetMachine : public LLVMTargetMachine { |
| 35 | NVPTXSubtarget Subtarget; |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 36 | const DataLayout DL; // Calculates type size & alignment |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 37 | NVPTXInstrInfo InstrInfo; |
| 38 | NVPTXTargetLowering TLInfo; |
| 39 | TargetSelectionDAGInfo TSInfo; |
| 40 | |
| 41 | // NVPTX does not have any call stack frame, but need a NVPTX specific |
| 42 | // FrameLowering class because TargetFrameLowering is abstract. |
| 43 | NVPTXFrameLowering FrameLowering; |
| 44 | |
| 45 | // Hold Strings that can be free'd all together with NVPTXTargetMachine |
| 46 | ManagedStringPool ManagedStrPool; |
| 47 | |
Nadav Rotem | cbd9a19 | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 48 | ScalarTargetTransformImpl STTI; |
| 49 | VectorTargetTransformImpl VTTI; |
| 50 | |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 51 | //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level, |
| 52 | // bool DisableVerify, MCContext *&OutCtx); |
| 53 | |
| 54 | public: |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 55 | NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU, |
| 56 | StringRef FS, const TargetOptions &Options, |
| 57 | Reloc::Model RM, CodeModel::Model CM, |
| 58 | CodeGenOpt::Level OP, |
| 59 | bool is64bit); |
| 60 | |
| 61 | virtual const TargetFrameLowering *getFrameLowering() const { |
| 62 | return &FrameLowering; |
| 63 | } |
| 64 | virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; } |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 65 | virtual const DataLayout *getDataLayout() const { return &DL;} |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 66 | virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget;} |
| 67 | |
| 68 | virtual const NVPTXRegisterInfo *getRegisterInfo() const { |
| 69 | return &(InstrInfo.getRegisterInfo()); |
| 70 | } |
| 71 | |
| 72 | virtual NVPTXTargetLowering *getTargetLowering() const { |
| 73 | return const_cast<NVPTXTargetLowering*>(&TLInfo); |
| 74 | } |
| 75 | |
| 76 | virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const { |
| 77 | return &TSInfo; |
| 78 | } |
Nadav Rotem | cbd9a19 | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 79 | virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const { |
| 80 | return &STTI; |
| 81 | } |
| 82 | virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const { |
| 83 | return &VTTI; |
| 84 | } |
Justin Holewinski | 49683f3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 85 | |
| 86 | //virtual bool addInstSelector(PassManagerBase &PM, |
| 87 | // CodeGenOpt::Level OptLevel); |
| 88 | |
| 89 | //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level); |
| 90 | |
| 91 | ManagedStringPool *getManagedStrPool() const { |
| 92 | return const_cast<ManagedStringPool*>(&ManagedStrPool); |
| 93 | } |
| 94 | |
| 95 | virtual TargetPassConfig *createPassConfig(PassManagerBase &PM); |
| 96 | |
| 97 | // Emission of machine code through JITCodeEmitter is not supported. |
| 98 | virtual bool addPassesToEmitMachineCode(PassManagerBase &, |
| 99 | JITCodeEmitter &, |
| 100 | bool = true) { |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | // Emission of machine code through MCJIT is not supported. |
| 105 | virtual bool addPassesToEmitMC(PassManagerBase &, |
| 106 | MCContext *&, |
| 107 | raw_ostream &, |
| 108 | bool = true) { |
| 109 | return true; |
| 110 | } |
| 111 | |
| 112 | }; // NVPTXTargetMachine. |
| 113 | |
| 114 | class NVPTXTargetMachine32 : public NVPTXTargetMachine { |
| 115 | virtual void anchor(); |
| 116 | public: |
| 117 | NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU, |
| 118 | StringRef FS, const TargetOptions &Options, |
| 119 | Reloc::Model RM, CodeModel::Model CM, |
| 120 | CodeGenOpt::Level OL); |
| 121 | }; |
| 122 | |
| 123 | class NVPTXTargetMachine64 : public NVPTXTargetMachine { |
| 124 | virtual void anchor(); |
| 125 | public: |
| 126 | NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU, |
| 127 | StringRef FS, const TargetOptions &Options, |
| 128 | Reloc::Model RM, CodeModel::Model CM, |
| 129 | CodeGenOpt::Level OL); |
| 130 | }; |
| 131 | |
| 132 | |
| 133 | } // end namespace llvm |
| 134 | |
| 135 | #endif |