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