blob: ca540b8e0389c5f386db69d33ca0bf6d31517f73 [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"
David Blaikie1be62f02017-11-03 22:32:11 +000020#include "llvm/CodeGen/TargetFrameLowering.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000021#include "llvm/Target/TargetMachine.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000022
23namespace llvm {
24
25/// NVPTXTargetMachine
26///
Matthias Braunbb8507e2017-10-12 22:57:28 +000027class NVPTXTargetMachine : public LLVMTargetMachine {
Eric Christopher6aad8b12015-02-19 00:08:14 +000028 bool is64bit;
Artem Belevich2f348ea2018-05-09 23:46:19 +000029 // Use 32-bit pointers for accessing const/local/short AS.
30 bool UseShortPointers;
Aditya Nandakumara2719322014-11-13 09:26:31 +000031 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christopher6aad8b12015-02-19 00:08:14 +000032 NVPTX::DrvInterface drvInterface;
Justin Holewinski0497ab12013-03-30 14:29:21 +000033 NVPTXSubtarget Subtarget;
Justin Holewinskiae556d32012-05-04 20:18:50 +000034
35 // Hold Strings that can be free'd all together with NVPTXTargetMachine
Justin Holewinski0497ab12013-03-30 14:29:21 +000036 ManagedStringPool ManagedStrPool;
Justin Holewinskiae556d32012-05-04 20:18:50 +000037
Justin Holewinskiae556d32012-05-04 20:18:50 +000038public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000039 NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
40 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000041 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000042 CodeGenOpt::Level OP, bool is64bit);
Justin Holewinskiae556d32012-05-04 20:18:50 +000043
Reid Kleckner357600e2014-11-20 23:37:18 +000044 ~NVPTXTargetMachine() override;
Eric Christopher4d0f35a2015-03-21 04:22:23 +000045 const NVPTXSubtarget *getSubtargetImpl(const Function &) const override {
46 return &Subtarget;
47 }
48 const NVPTXSubtarget *getSubtargetImpl() const { return &Subtarget; }
Eric Christopher6aad8b12015-02-19 00:08:14 +000049 bool is64Bit() const { return is64bit; }
Artem Belevich2f348ea2018-05-09 23:46:19 +000050 bool useShortPointers() const { return UseShortPointers; }
Eric Christopher6aad8b12015-02-19 00:08:14 +000051 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
Justin Holewinskiae556d32012-05-04 20:18:50 +000052 ManagedStringPool *getManagedStrPool() const {
Justin Holewinski0497ab12013-03-30 14:29:21 +000053 return const_cast<ManagedStringPool *>(&ManagedStrPool);
Justin Holewinskiae556d32012-05-04 20:18:50 +000054 }
55
Craig Topper2865c982014-04-29 07:57:44 +000056 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Justin Holewinskiae556d32012-05-04 20:18:50 +000057
Justin Holewinskiae556d32012-05-04 20:18:50 +000058 // Emission of machine code through MCJIT is not supported.
Rafael Espindola5560a4c2015-04-14 22:14:34 +000059 bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &,
Craig Topper2865c982014-04-29 07:57:44 +000060 bool = true) override {
Justin Holewinskiae556d32012-05-04 20:18:50 +000061 return true;
62 }
Aditya Nandakumara2719322014-11-13 09:26:31 +000063 TargetLoweringObjectFile *getObjFileLowering() const override {
64 return TLOF.get();
65 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000066
Stanislav Mekhanoshin81598112017-01-26 16:49:08 +000067 void adjustPassManager(PassManagerBuilder &) override;
68
Sanjoy Das26d11ca2017-12-22 18:21:59 +000069 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Jingyue Wu0c981bd2014-11-10 18:38:25 +000070
Matthias Braund6a36ae2017-05-31 18:41:23 +000071 bool isMachineVerifierClean() const override {
72 return false;
73 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000074}; // NVPTXTargetMachine.
75
76class NVPTXTargetMachine32 : public NVPTXTargetMachine {
77 virtual void anchor();
78public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000079 NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000080 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000081 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
82 CodeGenOpt::Level OL, bool JIT);
Justin Holewinskiae556d32012-05-04 20:18:50 +000083};
84
85class NVPTXTargetMachine64 : public NVPTXTargetMachine {
86 virtual void anchor();
87public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000088 NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU,
Justin Holewinskiae556d32012-05-04 20:18:50 +000089 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000090 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
91 CodeGenOpt::Level OL, bool JIT);
Justin Holewinskiae556d32012-05-04 20:18:50 +000092};
93
Justin Holewinskiae556d32012-05-04 20:18:50 +000094} // end namespace llvm
95
96#endif