blob: da7f62bf9d9b61decec95a10d41c2afa3a8bf13c [file] [log] [blame]
Justin Holewinskiae556d32012-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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
15#define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
Justin Holewinskiae556d32012-05-04 20:18:50 +000016
Eric Christopher493f91b2014-06-27 04:33:14 +000017#include "ManagedStringPool.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000018#include "NVPTXSubtarget.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000019#include "llvm/Target/TargetFrameLowering.h"
20#include "llvm/Target/TargetMachine.h"
21#include "llvm/Target/TargetSelectionDAGInfo.h"
22
23namespace llvm {
24
25/// NVPTXTargetMachine
26///
27class NVPTXTargetMachine : public LLVMTargetMachine {
Eric Christopher6aad8b12015-02-19 00:08:14 +000028 bool is64bit;
Aditya Nandakumara2719322014-11-13 09:26:31 +000029 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christopher6aad8b12015-02-19 00:08:14 +000030 NVPTX::DrvInterface drvInterface;
Justin Holewinski0497ab12013-03-30 14:29:21 +000031 NVPTXSubtarget Subtarget;
Justin Holewinskiae556d32012-05-04 20:18:50 +000032
33 // Hold Strings that can be free'd all together with NVPTXTargetMachine
Justin Holewinski0497ab12013-03-30 14:29:21 +000034 ManagedStringPool ManagedStrPool;
Justin Holewinskiae556d32012-05-04 20:18:50 +000035
Justin Holewinskiae556d32012-05-04 20:18:50 +000036public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000037 NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
38 StringRef FS, const TargetOptions &Options,
39 Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OP,
40 bool is64bit);
Justin Holewinskiae556d32012-05-04 20:18:50 +000041
Reid Kleckner357600e2014-11-20 23:37:18 +000042 ~NVPTXTargetMachine() override;
Eric Christopher4d0f35a2015-03-21 04:22:23 +000043 const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
44 return &Subtarget;
45 }
46 const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
Eric Christopher6aad8b12015-02-19 00:08:14 +000047 bool is64Bit() const { return is64bit; }
48 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
Justin Holewinskiae556d32012-05-04 20:18:50 +000049 ManagedStringPool *getManagedStrPool() const {
Justin Holewinski0497ab12013-03-30 14:29:21 +000050 return const_cast<ManagedStringPool *>(&ManagedStrPool);
Justin Holewinskiae556d32012-05-04 20:18:50 +000051 }
52
Craig Topper2865c982014-04-29 07:57:44 +000053 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Justin Holewinskiae556d32012-05-04 20:18:50 +000054
Justin Holewinskiae556d32012-05-04 20:18:50 +000055 // Emission of machine code through MCJIT is not supported.
Rafael Espindola5560a4c2015-04-14 22:14:34 +000056 bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
Craig Topper2865c982014-04-29 07:57:44 +000057 bool = true) override {
Justin Holewinskiae556d32012-05-04 20:18:50 +000058 return true;
59 }
Aditya Nandakumara2719322014-11-13 09:26:31 +000060 TargetLoweringObjectFile *getObjFileLowering() const override {
61 return TLOF.get();
62 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000063
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000064 TargetIRAnalysis getTargetIRAnalysis() override;
Jingyue Wu0c981bd2014-11-10 18:38:25 +000065
Justin Holewinskiae556d32012-05-04 20:18:50 +000066}; // NVPTXTargetMachine.
67
68class NVPTXTargetMachine32 : public NVPTXTargetMachine {
69 virtual void anchor();
70public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000071 NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000072 StringRef FS, const TargetOptions &Options,
73 Reloc::Model RM, CodeModel::Model CM,
74 CodeGenOpt::Level OL);
75};
76
77class NVPTXTargetMachine64 : public NVPTXTargetMachine {
78 virtual void anchor();
79public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000080 NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000081 StringRef FS, const TargetOptions &Options,
82 Reloc::Model RM, CodeModel::Model CM,
83 CodeGenOpt::Level OL);
84};
85
Justin Holewinskiae556d32012-05-04 20:18:50 +000086} // end namespace llvm
87
88#endif