1 //===-- AMDGPUTargetMachine.h - AMDGPU TargetMachine Interface --*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// The AMDGPU TargetMachine interface definition for hw codgen targets.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
17 #include "GCNSubtarget.h"
18 #include "R600Subtarget.h"
19 #include "llvm/Target/TargetMachine.h"
23 //===----------------------------------------------------------------------===//
24 // AMDGPU Target Machine (R600+)
25 //===----------------------------------------------------------------------===//
27 class AMDGPUTargetMachine
: public LLVMTargetMachine
{
29 std::unique_ptr
<TargetLoweringObjectFile
> TLOF
;
31 StringRef
getGPUName(const Function
&F
) const;
32 StringRef
getFeatureString(const Function
&F
) const;
35 static bool EnableLateStructurizeCFG
;
36 static bool EnableFunctionCalls
;
37 static bool EnableFixedFunctionABI
;
38 static bool EnableLowerModuleLDS
;
40 AMDGPUTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
41 StringRef FS
, TargetOptions Options
,
42 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
43 CodeGenOpt::Level OL
);
44 ~AMDGPUTargetMachine() override
;
46 const TargetSubtargetInfo
*getSubtargetImpl() const;
47 const TargetSubtargetInfo
*getSubtargetImpl(const Function
&) const override
= 0;
49 TargetLoweringObjectFile
*getObjFileLowering() const override
{
53 void adjustPassManager(PassManagerBuilder
&) override
;
55 void registerPassBuilderCallbacks(PassBuilder
&PB
) override
;
56 void registerDefaultAliasAnalyses(AAManager
&) override
;
58 /// Get the integer value of a null pointer in the given address space.
59 static int64_t getNullPointerValue(unsigned AddrSpace
);
61 bool isNoopAddrSpaceCast(unsigned SrcAS
, unsigned DestAS
) const override
;
63 unsigned getAssumedAddrSpace(const Value
*V
) const override
;
66 //===----------------------------------------------------------------------===//
67 // R600 Target Machine (R600 -> Cayman)
68 //===----------------------------------------------------------------------===//
70 class R600TargetMachine final
: public AMDGPUTargetMachine
{
72 mutable StringMap
<std::unique_ptr
<R600Subtarget
>> SubtargetMap
;
75 R600TargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
76 StringRef FS
, TargetOptions Options
,
77 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
78 CodeGenOpt::Level OL
, bool JIT
);
80 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
82 const R600Subtarget
*getSubtargetImpl(const Function
&) const override
;
84 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) override
;
86 bool isMachineVerifierClean() const override
{
91 //===----------------------------------------------------------------------===//
92 // GCN Target Machine (SI+)
93 //===----------------------------------------------------------------------===//
95 class GCNTargetMachine final
: public AMDGPUTargetMachine
{
97 mutable StringMap
<std::unique_ptr
<GCNSubtarget
>> SubtargetMap
;
100 GCNTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
101 StringRef FS
, TargetOptions Options
,
102 Optional
<Reloc::Model
> RM
, Optional
<CodeModel::Model
> CM
,
103 CodeGenOpt::Level OL
, bool JIT
);
105 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
107 const GCNSubtarget
*getSubtargetImpl(const Function
&) const override
;
109 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) override
;
111 bool useIPRA() const override
{
115 yaml::MachineFunctionInfo
*createDefaultFuncInfoYAML() const override
;
116 yaml::MachineFunctionInfo
*
117 convertFuncInfoToYAML(const MachineFunction
&MF
) const override
;
118 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo
&,
119 PerFunctionMIParsingState
&PFS
,
121 SMRange
&SourceRange
) const override
;
124 } // end namespace llvm
126 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H