blob: c8b7f21e11c90ffcfd5a59f550d03b3f4a9db9a8 [file] [log] [blame]
Justin Holewinski49683f32012-05-04 20:18:50 +00001//===-- 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
Chandler Carrutha1514e22012-12-04 07:12:27 +000018#include "ManagedStringPool.h"
19#include "NVPTXFrameLowering.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000020#include "NVPTXISelLowering.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000021#include "NVPTXInstrInfo.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000022#include "NVPTXRegisterInfo.h"
23#include "NVPTXSubtarget.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000024#include "llvm/IR/DataLayout.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000025#include "llvm/Target/TargetFrameLowering.h"
26#include "llvm/Target/TargetMachine.h"
27#include "llvm/Target/TargetSelectionDAGInfo.h"
Nadav Rotemcbd9a192012-10-18 23:22:48 +000028#include "llvm/Target/TargetTransformImpl.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000029
30namespace llvm {
31
32/// NVPTXTargetMachine
33///
34class NVPTXTargetMachine : public LLVMTargetMachine {
35 NVPTXSubtarget Subtarget;
Micah Villmow3574eca2012-10-08 16:38:25 +000036 const DataLayout DL; // Calculates type size & alignment
Justin Holewinski49683f32012-05-04 20:18:50 +000037 NVPTXInstrInfo InstrInfo;
38 NVPTXTargetLowering TLInfo;
39 TargetSelectionDAGInfo TSInfo;
40
41 // NVPTX does not have any call stack frame, but need a NVPTX specific
42 // FrameLowering class because TargetFrameLowering is abstract.
43 NVPTXFrameLowering FrameLowering;
44
45 // Hold Strings that can be free'd all together with NVPTXTargetMachine
46 ManagedStringPool ManagedStrPool;
47
Nadav Rotemcbd9a192012-10-18 23:22:48 +000048 ScalarTargetTransformImpl STTI;
49 VectorTargetTransformImpl VTTI;
50
Justin Holewinski49683f32012-05-04 20:18:50 +000051 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
52 // bool DisableVerify, MCContext *&OutCtx);
53
54public:
Justin Holewinski49683f32012-05-04 20:18:50 +000055 NVPTXTargetMachine(const Target &T, StringRef TT, StringRef CPU,
56 StringRef FS, const TargetOptions &Options,
57 Reloc::Model RM, CodeModel::Model CM,
58 CodeGenOpt::Level OP,
59 bool is64bit);
60
61 virtual const TargetFrameLowering *getFrameLowering() const {
62 return &FrameLowering;
63 }
64 virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
Micah Villmow3574eca2012-10-08 16:38:25 +000065 virtual const DataLayout *getDataLayout() const { return &DL;}
Justin Holewinski49683f32012-05-04 20:18:50 +000066 virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget;}
67
68 virtual const NVPTXRegisterInfo *getRegisterInfo() const {
69 return &(InstrInfo.getRegisterInfo());
70 }
71
72 virtual NVPTXTargetLowering *getTargetLowering() const {
73 return const_cast<NVPTXTargetLowering*>(&TLInfo);
74 }
75
76 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
77 return &TSInfo;
78 }
Nadav Rotemcbd9a192012-10-18 23:22:48 +000079 virtual const ScalarTargetTransformInfo *getScalarTargetTransformInfo()const {
80 return &STTI;
81 }
82 virtual const VectorTargetTransformInfo *getVectorTargetTransformInfo()const {
83 return &VTTI;
84 }
Justin Holewinski49683f32012-05-04 20:18:50 +000085
86 //virtual bool addInstSelector(PassManagerBase &PM,
87 // CodeGenOpt::Level OptLevel);
88
89 //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level);
90
91 ManagedStringPool *getManagedStrPool() const {
92 return const_cast<ManagedStringPool*>(&ManagedStrPool);
93 }
94
95 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
96
97 // Emission of machine code through JITCodeEmitter is not supported.
98 virtual bool addPassesToEmitMachineCode(PassManagerBase &,
99 JITCodeEmitter &,
100 bool = true) {
101 return true;
102 }
103
104 // Emission of machine code through MCJIT is not supported.
105 virtual bool addPassesToEmitMC(PassManagerBase &,
106 MCContext *&,
107 raw_ostream &,
108 bool = true) {
109 return true;
110 }
111
112}; // NVPTXTargetMachine.
113
114class NVPTXTargetMachine32 : public NVPTXTargetMachine {
115 virtual void anchor();
116public:
117 NVPTXTargetMachine32(const Target &T, StringRef TT, StringRef CPU,
118 StringRef FS, const TargetOptions &Options,
119 Reloc::Model RM, CodeModel::Model CM,
120 CodeGenOpt::Level OL);
121};
122
123class NVPTXTargetMachine64 : public NVPTXTargetMachine {
124 virtual void anchor();
125public:
126 NVPTXTargetMachine64(const Target &T, StringRef TT, StringRef CPU,
127 StringRef FS, const TargetOptions &Options,
128 Reloc::Model RM, CodeModel::Model CM,
129 CodeGenOpt::Level OL);
130};
131
132
133} // end namespace llvm
134
135#endif