1d82e5c6770be9e8e6cf84c2da239e0bebc6aea8
[oota-llvm.git] / lib / Target / NVPTX / NVPTXTargetMachine.h
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
29 namespace llvm {
30
31 /// NVPTXTargetMachine
32 ///
33 class 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
50 public:
51   //virtual bool addPassesToEmitFile(PassManagerBase &PM,
52   //                                 formatted_raw_ostream &Out,
53   //                                 CodeGenFileType FileType,
54   //                                 CodeGenOpt::Level OptLevel,
55   //                                 bool DisableVerify = true) ;
56
57   NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU,
58                      StringRef FS, const TargetOptions &Options,
59                      Reloc::Model RM, CodeModel::Model CM,
60                      CodeGenOpt::Level OP,
61                      bool is64bit);
62
63   virtual const TargetFrameLowering *getFrameLowering() const {
64     return &FrameLowering;
65   }
66   virtual const NVPTXInstrInfo *getInstrInfo() const  { return &InstrInfo; }
67   virtual const TargetData *getTargetData() const     { return &DataLayout;}
68   virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget;}
69
70   virtual const NVPTXRegisterInfo *getRegisterInfo() const {
71     return &(InstrInfo.getRegisterInfo());
72   }
73
74   virtual NVPTXTargetLowering *getTargetLowering() const {
75     return const_cast<NVPTXTargetLowering*>(&TLInfo);
76   }
77
78   virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
79     return &TSInfo;
80   }
81
82   //virtual bool addInstSelector(PassManagerBase &PM,
83   //                             CodeGenOpt::Level OptLevel);
84
85   //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level);
86
87   ManagedStringPool *getManagedStrPool() const {
88     return const_cast<ManagedStringPool*>(&ManagedStrPool);
89   }
90
91   virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
92
93   // Emission of machine code through JITCodeEmitter is not supported.
94   virtual bool addPassesToEmitMachineCode(PassManagerBase &,
95                                           JITCodeEmitter &,
96                                           bool = true) {
97     return true;
98   }
99
100   // Emission of machine code through MCJIT is not supported.
101   virtual bool addPassesToEmitMC(PassManagerBase &,
102                                  MCContext *&,
103                                  raw_ostream &,
104                                  bool = true) {
105     return true;
106   }
107
108 }; // NVPTXTargetMachine.
109
110 class NVPTXTargetMachine32 : public NVPTXTargetMachine {
111   virtual void anchor();
112 public:
113   NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
114                        StringRef FS, const TargetOptions &Options,
115                        Reloc::Model RM, CodeModel::Model CM,
116                        CodeGenOpt::Level OL);
117 };
118
119 class NVPTXTargetMachine64 : public NVPTXTargetMachine {
120   virtual void anchor();
121 public:
122   NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
123                        StringRef FS, const TargetOptions &Options,
124                        Reloc::Model RM, CodeModel::Model CM,
125                        CodeGenOpt::Level OL);
126 };
127
128
129 } // end namespace llvm
130
131 #endif