blob: d5726b9866b7faa8fae1aea50f25cbac63162203 [file] [log] [blame]
Nick Lewyckyf7a3c502010-09-07 18:14:24 +00001//===-- PTXTargetMachine.h - Define TargetMachine for PTX -------*- 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 PTX specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef PTX_TARGET_MACHINE_H
15#define PTX_TARGET_MACHINE_H
16
Eric Christopher50880d02010-09-18 18:52:28 +000017#include "PTXISelLowering.h"
18#include "PTXInstrInfo.h"
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000019#include "PTXFrameLowering.h"
Eric Christopher50880d02010-09-18 18:52:28 +000020#include "PTXSubtarget.h"
21#include "llvm/Target/TargetData.h"
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000022#include "llvm/Target/TargetFrameLowering.h"
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000023#include "llvm/Target/TargetMachine.h"
24
25namespace llvm {
Eric Christopher50880d02010-09-18 18:52:28 +000026class PTXTargetMachine : public LLVMTargetMachine {
27 private:
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000028 const TargetData DataLayout;
Che-Liang Chiou31c488c2011-03-02 07:58:46 +000029 PTXSubtarget Subtarget; // has to be initialized before FrameLowering
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000030 PTXFrameLowering FrameLowering;
31 PTXInstrInfo InstrInfo;
Eric Christopher50880d02010-09-18 18:52:28 +000032 PTXTargetLowering TLInfo;
Eric Christopher50880d02010-09-18 18:52:28 +000033
34 public:
Evan Cheng43966132011-07-19 06:37:02 +000035 PTXTargetMachine(const Target &T, StringRef TT,
Evan Cheng34ad6db2011-07-20 07:51:56 +000036 StringRef CPU, StringRef FS,
37 Reloc::Model RM, CodeModel::Model CM,
Evan Cheng276365d2011-06-30 01:53:36 +000038 bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000039
40 virtual const TargetData *getTargetData() const { return &DataLayout; }
41
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000042 virtual const TargetFrameLowering *getFrameLowering() const {
43 return &FrameLowering;
44 }
Eric Christopher50880d02010-09-18 18:52:28 +000045
46 virtual const PTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
47 virtual const TargetRegisterInfo *getRegisterInfo() const {
48 return &InstrInfo.getRegisterInfo(); }
49
50 virtual const PTXTargetLowering *getTargetLowering() const {
51 return &TLInfo; }
52
53 virtual const PTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
54
55 virtual bool addInstSelector(PassManagerBase &PM,
56 CodeGenOpt::Level OptLevel);
Che-Liang Chiouad83c1d2011-01-01 10:50:37 +000057 virtual bool addPostRegAlloc(PassManagerBase &PM,
58 CodeGenOpt::Level OptLevel);
Justin Holewinski40466cc2011-09-22 16:45:37 +000059
60 // We override this method to supply our own set of codegen passes.
61 virtual bool addPassesToEmitFile(PassManagerBase &,
62 formatted_raw_ostream &,
63 CodeGenFileType,
64 CodeGenOpt::Level,
65 bool = true);
66
67 // Emission of machine code through JITCodeEmitter is not supported.
68 virtual bool addPassesToEmitMachineCode(PassManagerBase &,
69 JITCodeEmitter &,
70 CodeGenOpt::Level,
71 bool = true) {
72 return true;
73 }
74
75 // Emission of machine code through MCJIT is not supported.
76 virtual bool addPassesToEmitMC(PassManagerBase &,
77 MCContext *&,
78 raw_ostream &,
79 CodeGenOpt::Level,
80 bool = true) {
81 return true;
82 }
83
84 private:
85
86 bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
87 bool DisableVerify, MCContext *&OutCtx);
Eric Christopher50880d02010-09-18 18:52:28 +000088}; // class PTXTargetMachine
Justin Holewinskie1fee482011-04-20 15:37:17 +000089
90
91class PTX32TargetMachine : public PTXTargetMachine {
92public:
93
Evan Cheng43966132011-07-19 06:37:02 +000094 PTX32TargetMachine(const Target &T, StringRef TT,
Evan Cheng34ad6db2011-07-20 07:51:56 +000095 StringRef CPU, StringRef FS,
96 Reloc::Model RM, CodeModel::Model CM);
Justin Holewinskie1fee482011-04-20 15:37:17 +000097}; // class PTX32TargetMachine
98
99class PTX64TargetMachine : public PTXTargetMachine {
100public:
101
Evan Cheng43966132011-07-19 06:37:02 +0000102 PTX64TargetMachine(const Target &T, StringRef TT,
Evan Cheng34ad6db2011-07-20 07:51:56 +0000103 StringRef CPU, StringRef FS,
104 Reloc::Model RM, CodeModel::Model CM);
Justin Holewinskie1fee482011-04-20 15:37:17 +0000105}; // class PTX32TargetMachine
106
Nick Lewyckyf7a3c502010-09-07 18:14:24 +0000107} // namespace llvm
108
109#endif // PTX_TARGET_MACHINE_H