1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef NVPTX_TARGETMACHINE_H
15 #define NVPTX_TARGETMACHINE_H
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"
30 /// NVPTXTargetMachine
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;
39 // NVPTX does not have any call stack frame, but need a NVPTX specific
40 // FrameLowering class because TargetFrameLowering is abstract.
41 NVPTXFrameLowering FrameLowering;
43 // Hold Strings that can be free'd all together with NVPTXTargetMachine
44 ManagedStringPool ManagedStrPool;
46 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
47 // bool DisableVerify, MCContext *&OutCtx);
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);
54 virtual const TargetFrameLowering *getFrameLowering() const {
55 return &FrameLowering;
57 virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
58 virtual const DataLayout *getDataLayout() const { return &DL; }
59 virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
61 virtual const NVPTXRegisterInfo *getRegisterInfo() const {
62 return &(InstrInfo.getRegisterInfo());
65 virtual NVPTXTargetLowering *getTargetLowering() const {
66 return const_cast<NVPTXTargetLowering *>(&TLInfo);
69 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
73 //virtual bool addInstSelector(PassManagerBase &PM,
74 // CodeGenOpt::Level OptLevel);
76 //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level);
78 ManagedStringPool *getManagedStrPool() const {
79 return const_cast<ManagedStringPool *>(&ManagedStrPool);
82 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
84 // Emission of machine code through JITCodeEmitter is not supported.
85 virtual bool addPassesToEmitMachineCode(PassManagerBase &, JITCodeEmitter &,
90 // Emission of machine code through MCJIT is not supported.
91 virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
96 }; // NVPTXTargetMachine.
98 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
99 virtual void anchor();
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);
107 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
108 virtual void anchor();
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);
116 } // end namespace llvm