1 //===-- NVPTXTargetMachine.h - Define TargetMachine for NVPTX ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETMACHINE_H
17 #include "ManagedStringPool.h"
18 #include "NVPTXSubtarget.h"
19 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
20 #include "llvm/CodeGen/TargetFrameLowering.h"
21 #include "llvm/Target/TargetMachine.h"
25 /// NVPTXTargetMachine
27 class NVPTXTargetMachine
: public LLVMTargetMachine
{
29 // Use 32-bit pointers for accessing const/local/short AS.
30 bool UseShortPointers
;
31 std::unique_ptr
<TargetLoweringObjectFile
> TLOF
;
32 NVPTX::DrvInterface drvInterface
;
33 NVPTXSubtarget Subtarget
;
35 // Hold Strings that can be free'd all together with NVPTXTargetMachine
36 ManagedStringPool ManagedStrPool
;
39 NVPTXTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
40 StringRef FS
, const TargetOptions
&Options
,
41 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
42 CodeGenOpt::Level OP
, bool is64bit
);
44 ~NVPTXTargetMachine() override
;
45 const NVPTXSubtarget
*getSubtargetImpl(const Function
&) const override
{
48 const NVPTXSubtarget
*getSubtargetImpl() const { return &Subtarget
; }
49 bool is64Bit() const { return is64bit
; }
50 bool useShortPointers() const { return UseShortPointers
; }
51 NVPTX::DrvInterface
getDrvInterface() const { return drvInterface
; }
52 ManagedStringPool
*getManagedStrPool() const {
53 return const_cast<ManagedStringPool
*>(&ManagedStrPool
);
56 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
58 // Emission of machine code through MCJIT is not supported.
59 bool addPassesToEmitMC(PassManagerBase
&, MCContext
*&, raw_pwrite_stream
&,
60 bool = true) override
{
63 TargetLoweringObjectFile
*getObjFileLowering() const override
{
67 void adjustPassManager(PassManagerBuilder
&) override
;
69 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) override
;
71 bool isMachineVerifierClean() const override
{
74 }; // NVPTXTargetMachine.
76 class NVPTXTargetMachine32
: public NVPTXTargetMachine
{
77 virtual void anchor();
79 NVPTXTargetMachine32(const Target
&T
, const Triple
&TT
, StringRef CPU
,
80 StringRef FS
, const TargetOptions
&Options
,
81 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
82 CodeGenOpt::Level OL
, bool JIT
);
85 class NVPTXTargetMachine64
: public NVPTXTargetMachine
{
86 virtual void anchor();
88 NVPTXTargetMachine64(const Target
&T
, const Triple
&TT
, StringRef CPU
,
89 StringRef FS
, const TargetOptions
&Options
,
90 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
91 CodeGenOpt::Level OL
, bool JIT
);
94 } // end namespace llvm