blob: 78a053831772d2d0fc3def0aa8df5c506c8594d8 [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"
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000019#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000020#include "llvm/Target/TargetFrameLowering.h"
21#include "llvm/Target/TargetMachine.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000022
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,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000039 Optional<Reloc::Model> RM, CodeModel::Model CM,
40 CodeGenOpt::Level OP, 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
Justin Lebar7cdbce52016-04-27 19:13:37 +000064 void addEarlyAsPossiblePasses(PassManagerBase &PM) override;
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000065 TargetIRAnalysis getTargetIRAnalysis() override;
Jingyue Wu0c981bd2014-11-10 18:38:25 +000066
Justin Holewinskiae556d32012-05-04 20:18:50 +000067}; // NVPTXTargetMachine.
68
69class NVPTXTargetMachine32 : public NVPTXTargetMachine {
70 virtual void anchor();
71public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000072 NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000073 StringRef FS, const TargetOptions &Options,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000074 Optional<Reloc::Model> RM, CodeModel::Model CM,
Justin Holewinskiae556d32012-05-04 20:18:50 +000075 CodeGenOpt::Level OL);
76};
77
78class NVPTXTargetMachine64 : public NVPTXTargetMachine {
79 virtual void anchor();
80public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000081 NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000082 StringRef FS, const TargetOptions &Options,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000083 Optional<Reloc::Model> RM, CodeModel::Model CM,
Justin Holewinskiae556d32012-05-04 20:18:50 +000084 CodeGenOpt::Level OL);
85};
86
Justin Holewinskiae556d32012-05-04 20:18:50 +000087} // end namespace llvm
88
89#endif