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 #ifndef NVPTX_TARGETMACHINE_H 15 #define NVPTX_TARGETMACHINE_H 16 17 #include "ManagedStringPool.h" 18 #include "NVPTXFrameLowering.h" 19 #include "NVPTXISelLowering.h" 20 #include "NVPTXInstrInfo.h" 21 #include "NVPTXRegisterInfo.h" 22 #include "NVPTXSubtarget.h" 23 #include "llvm/IR/DataLayout.h" 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 { 33 NVPTXSubtarget Subtarget; 34 const DataLayout DL; // Calculates type size & alignment 35 NVPTXInstrInfo InstrInfo; 36 NVPTXTargetLowering TLInfo; 37 TargetSelectionDAGInfo TSInfo; 38 39 // NVPTX does not have any call stack frame, but need a NVPTX specific 40 // FrameLowering class because TargetFrameLowering is abstract. 41 NVPTXFrameLowering FrameLowering; 42 43 // Hold Strings that can be free'd all together with NVPTXTargetMachine 44 ManagedStringPool ManagedStrPool; 45 46 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level, 47 // bool DisableVerify, MCContext *&OutCtx); 48 49 public: 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); 53 54 virtual const TargetFrameLowering *getFrameLowering() const { 55 return &FrameLowering; 56 } 57 virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; } 58 virtual const DataLayout *getDataLayout() const { return &DL; } 59 virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; } 60 61 virtual const NVPTXRegisterInfo *getRegisterInfo() const { 62 return &(InstrInfo.getRegisterInfo()); 63 } 64 65 virtual NVPTXTargetLowering *getTargetLowering() const { 66 return const_cast<NVPTXTargetLowering *>(&TLInfo); 67 } 68 69 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const { 70 return &TSInfo; 71 } 72 73 //virtual bool addInstSelector(PassManagerBase &PM, 74 // CodeGenOpt::Level OptLevel); 75 76 //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level); 77 78 ManagedStringPool *getManagedStrPool() const { 79 return const_cast<ManagedStringPool *>(&ManagedStrPool); 80 } 81 82 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM); 83 84 // Emission of machine code through JITCodeEmitter is not supported. 85 virtual bool addPassesToEmitMachineCode(PassManagerBase &, JITCodeEmitter &, 86 bool = true) { 87 return true; 88 } 89 90 // Emission of machine code through MCJIT is not supported. 91 virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &, 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 116 } // end namespace llvm 117 118 #endif 119