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 //===----------------------------------------------------------------------===//
15 #ifndef NVPTX_TARGETMACHINE_H
16 #define NVPTX_TARGETMACHINE_H
18 #include "ManagedStringPool.h"
19 #include "NVPTXFrameLowering.h"
20 #include "NVPTXISelLowering.h"
21 #include "NVPTXInstrInfo.h"
22 #include "NVPTXRegisterInfo.h"
23 #include "NVPTXSubtarget.h"
24 #include "llvm/IR/DataLayout.h"
25 #include "llvm/Target/TargetFrameLowering.h"
26 #include "llvm/Target/TargetMachine.h"
27 #include "llvm/Target/TargetSelectionDAGInfo.h"
31 /// NVPTXTargetMachine
33 class NVPTXTargetMachine : public LLVMTargetMachine {
34 NVPTXSubtarget Subtarget;
35 const DataLayout DL; // Calculates type size & alignment
36 NVPTXInstrInfo InstrInfo;
37 NVPTXTargetLowering TLInfo;
38 TargetSelectionDAGInfo TSInfo;
40 // NVPTX does not have any call stack frame, but need a NVPTX specific
41 // FrameLowering class because TargetFrameLowering is abstract.
42 NVPTXFrameLowering FrameLowering;
44 // Hold Strings that can be free'd all together with NVPTXTargetMachine
45 ManagedStringPool ManagedStrPool;
47 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
48 // bool DisableVerify, MCContext *&OutCtx);
51 NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU,
52 StringRef FS, const TargetOptions &Options,
53 Reloc::Model RM, CodeModel::Model CM,
57 virtual const TargetFrameLowering *getFrameLowering() const {
58 return &FrameLowering;
60 virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
61 virtual const DataLayout *getDataLayout() const { return &DL;}
62 virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget;}
64 virtual const NVPTXRegisterInfo *getRegisterInfo() const {
65 return &(InstrInfo.getRegisterInfo());
68 virtual NVPTXTargetLowering *getTargetLowering() const {
69 return const_cast<NVPTXTargetLowering*>(&TLInfo);
72 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
76 //virtual bool addInstSelector(PassManagerBase &PM,
77 // CodeGenOpt::Level OptLevel);
79 //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level);
81 ManagedStringPool *getManagedStrPool() const {
82 return const_cast<ManagedStringPool*>(&ManagedStrPool);
85 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
87 // Emission of machine code through JITCodeEmitter is not supported.
88 virtual bool addPassesToEmitMachineCode(PassManagerBase &,
94 // Emission of machine code through MCJIT is not supported.
95 virtual bool addPassesToEmitMC(PassManagerBase &,
102 }; // NVPTXTargetMachine.
104 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
105 virtual void anchor();
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);
113 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
114 virtual void anchor();
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);
123 } // end namespace llvm