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