blob: e1b7b0c0bab2c7744b432845bced71bc1fb39d77 [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"
Justin Holewinskibc97f442011-09-26 18:57:27 +000020#include "PTXSelectionDAGInfo.h"
Eric Christopher50880d02010-09-18 18:52:28 +000021#include "PTXSubtarget.h"
22#include "llvm/Target/TargetData.h"
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000023#include "llvm/Target/TargetFrameLowering.h"
Nick Lewyckyf7a3c502010-09-07 18:14:24 +000024#include "llvm/Target/TargetMachine.h"
25
26namespace llvm {
Eric Christopher50880d02010-09-18 18:52:28 +000027class PTXTargetMachine : public LLVMTargetMachine {
28 private:
Justin Holewinskibc97f442011-09-26 18:57:27 +000029 const TargetData DataLayout;
30 PTXSubtarget Subtarget; // has to be initialized before FrameLowering
31 PTXFrameLowering FrameLowering;
32 PTXInstrInfo InstrInfo;
33 PTXSelectionDAGInfo TSInfo;
34 PTXTargetLowering TLInfo;
Eric Christopher50880d02010-09-18 18:52:28 +000035
36 public:
Evan Cheng43966132011-07-19 06:37:02 +000037 PTXTargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000038 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Cheng34ad6db2011-07-20 07:51:56 +000039 Reloc::Model RM, CodeModel::Model CM,
Evan Chengb95fc312011-11-16 08:38:26 +000040 CodeGenOpt::Level OL,
Evan Cheng276365d2011-06-30 01:53:36 +000041 bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000042
43 virtual const TargetData *getTargetData() const { return &DataLayout; }
44
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000045 virtual const TargetFrameLowering *getFrameLowering() const {
46 return &FrameLowering;
47 }
Eric Christopher50880d02010-09-18 18:52:28 +000048
49 virtual const PTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
50 virtual const TargetRegisterInfo *getRegisterInfo() const {
51 return &InstrInfo.getRegisterInfo(); }
52
53 virtual const PTXTargetLowering *getTargetLowering() const {
54 return &TLInfo; }
55
Justin Holewinskibc97f442011-09-26 18:57:27 +000056 virtual const PTXSelectionDAGInfo* getSelectionDAGInfo() const {
57 return &TSInfo;
58 }
59
Eric Christopher50880d02010-09-18 18:52:28 +000060 virtual const PTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
61
Justin Holewinski40466cc2011-09-22 16:45:37 +000062 // We override this method to supply our own set of codegen passes.
63 virtual bool addPassesToEmitFile(PassManagerBase &,
64 formatted_raw_ostream &,
65 CodeGenFileType,
Justin Holewinski40466cc2011-09-22 16:45:37 +000066 bool = true);
67
68 // Emission of machine code through JITCodeEmitter is not supported.
69 virtual bool addPassesToEmitMachineCode(PassManagerBase &,
70 JITCodeEmitter &,
Justin Holewinski40466cc2011-09-22 16:45:37 +000071 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 &,
Justin Holewinski40466cc2011-09-22 16:45:37 +000079 bool = true) {
80 return true;
81 }
82
Andrew Trick843ee2e2012-02-03 05:12:41 +000083 // Pass Pipeline Configuration
Andrew Trick061efcf2012-02-04 02:56:59 +000084 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
Eric Christopher50880d02010-09-18 18:52:28 +000085}; // class PTXTargetMachine
Justin Holewinskie1fee482011-04-20 15:37:17 +000086
87
88class PTX32TargetMachine : public PTXTargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +000089 virtual void anchor();
Justin Holewinskie1fee482011-04-20 15:37:17 +000090public:
91
Evan Cheng43966132011-07-19 06:37:02 +000092 PTX32TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000093 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +000094 Reloc::Model RM, CodeModel::Model CM,
95 CodeGenOpt::Level OL);
Justin Holewinskie1fee482011-04-20 15:37:17 +000096}; // class PTX32TargetMachine
97
98class PTX64TargetMachine : public PTXTargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +000099 virtual void anchor();
Justin Holewinskie1fee482011-04-20 15:37:17 +0000100public:
101
Evan Cheng43966132011-07-19 06:37:02 +0000102 PTX64TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +0000103 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +0000104 Reloc::Model RM, CodeModel::Model CM,
105 CodeGenOpt::Level OL);
Justin Holewinskie1fee482011-04-20 15:37:17 +0000106}; // class PTX32TargetMachine
107
Nick Lewyckyf7a3c502010-09-07 18:14:24 +0000108} // namespace llvm
109
110#endif // PTX_TARGET_MACHINE_H