blob: 5fbcf735b48f2f53155ec73079f9702f12970949 [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
Justin Holewinski49683f32012-05-04 20:18:50 +000014#ifndef NVPTX_TARGETMACHINE_H
15#define NVPTX_TARGETMACHINE_H
16
Chandler Carrutha1514e22012-12-04 07:12:27 +000017#include "ManagedStringPool.h"
18#include "NVPTXFrameLowering.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000019#include "NVPTXISelLowering.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000020#include "NVPTXInstrInfo.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000021#include "NVPTXRegisterInfo.h"
22#include "NVPTXSubtarget.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000023#include "llvm/IR/DataLayout.h"
Justin Holewinski49683f32012-05-04 20:18:50 +000024#include "llvm/Target/TargetFrameLowering.h"
25#include "llvm/Target/TargetMachine.h"
26#include "llvm/Target/TargetSelectionDAGInfo.h"
27
28namespace llvm {
29
30/// NVPTXTargetMachine
31///
32class NVPTXTargetMachine : public LLVMTargetMachine {
Justin Holewinski3639ce22013-03-30 14:29:21 +000033 NVPTXSubtarget Subtarget;
34 const DataLayout DL; // Calculates type size & alignment
35 NVPTXInstrInfo InstrInfo;
36 NVPTXTargetLowering TLInfo;
37 TargetSelectionDAGInfo TSInfo;
Justin Holewinski49683f32012-05-04 20:18:50 +000038
39 // NVPTX does not have any call stack frame, but need a NVPTX specific
40 // FrameLowering class because TargetFrameLowering is abstract.
Justin Holewinski3639ce22013-03-30 14:29:21 +000041 NVPTXFrameLowering FrameLowering;
Justin Holewinski49683f32012-05-04 20:18:50 +000042
43 // Hold Strings that can be free'd all together with NVPTXTargetMachine
Justin Holewinski3639ce22013-03-30 14:29:21 +000044 ManagedStringPool ManagedStrPool;
Justin Holewinski49683f32012-05-04 20:18:50 +000045
46 //bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
47 // bool DisableVerify, MCContext *&OutCtx);
48
49public:
Justin Holewinski3639ce22013-03-30 14:29:21 +000050 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);
Justin Holewinski49683f32012-05-04 20:18:50 +000053
54 virtual const TargetFrameLowering *getFrameLowering() const {
55 return &FrameLowering;
56 }
Justin Holewinski3639ce22013-03-30 14:29:21 +000057 virtual const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
58 virtual const DataLayout *getDataLayout() const { return &DL; }
59 virtual const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
Justin Holewinski49683f32012-05-04 20:18:50 +000060
61 virtual const NVPTXRegisterInfo *getRegisterInfo() const {
62 return &(InstrInfo.getRegisterInfo());
63 }
64
65 virtual NVPTXTargetLowering *getTargetLowering() const {
Justin Holewinski3639ce22013-03-30 14:29:21 +000066 return const_cast<NVPTXTargetLowering *>(&TLInfo);
Justin Holewinski49683f32012-05-04 20:18:50 +000067 }
68
69 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
70 return &TSInfo;
71 }
Justin Holewinski49683f32012-05-04 20:18:50 +000072
73 //virtual bool addInstSelector(PassManagerBase &PM,
74 // CodeGenOpt::Level OptLevel);
75
76 //virtual bool addPreRegAlloc(PassManagerBase &, CodeGenOpt::Level);
77
78 ManagedStringPool *getManagedStrPool() const {
Justin Holewinski3639ce22013-03-30 14:29:21 +000079 return const_cast<ManagedStringPool *>(&ManagedStrPool);
Justin Holewinski49683f32012-05-04 20:18:50 +000080 }
81
82 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
83
84 // Emission of machine code through JITCodeEmitter is not supported.
Justin Holewinski3639ce22013-03-30 14:29:21 +000085 virtual bool addPassesToEmitMachineCode(PassManagerBase &, JITCodeEmitter &,
Justin Holewinski49683f32012-05-04 20:18:50 +000086 bool = true) {
87 return true;
88 }
89
90 // Emission of machine code through MCJIT is not supported.
Justin Holewinski3639ce22013-03-30 14:29:21 +000091 virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_ostream &,
Justin Holewinski49683f32012-05-04 20:18:50 +000092 bool = true) {
93 return true;
94 }
95
96}; // NVPTXTargetMachine.
97
98class NVPTXTargetMachine32 : public NVPTXTargetMachine {
99 virtual void anchor();
100public:
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);
105};
106
107class NVPTXTargetMachine64 : public NVPTXTargetMachine {
108 virtual void anchor();
109public:
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);
114};
115
Justin Holewinski49683f32012-05-04 20:18:50 +0000116} // end namespace llvm
117
118#endif