LLVM  13.0.0git
AMDGPUTargetMachine.h
Go to the documentation of this file.
1 //===-- AMDGPUTargetMachine.h - AMDGPU TargetMachine Interface --*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// The AMDGPU TargetMachine interface definition for hw codgen targets.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
16 
17 #include "GCNSubtarget.h"
18 #include "R600Subtarget.h"
20 
21 namespace llvm {
22 
23 //===----------------------------------------------------------------------===//
24 // AMDGPU Target Machine (R600+)
25 //===----------------------------------------------------------------------===//
26 
28 protected:
29  std::unique_ptr<TargetLoweringObjectFile> TLOF;
30 
31  StringRef getGPUName(const Function &F) const;
32  StringRef getFeatureString(const Function &F) const;
33 
34 public:
36  static bool EnableFunctionCalls;
38  static bool EnableLowerModuleLDS;
39 
40  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
44  ~AMDGPUTargetMachine() override;
45 
47  const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override = 0;
48 
50  return TLOF.get();
51  }
52 
53  void adjustPassManager(PassManagerBuilder &) override;
54 
56  bool DebugPassManager) override;
57  void registerDefaultAliasAnalyses(AAManager &) override;
58 
59  /// Get the integer value of a null pointer in the given address space.
60  static int64_t getNullPointerValue(unsigned AddrSpace);
61 
62  bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
63 
64  unsigned getAssumedAddrSpace(const Value *V) const override;
65 };
66 
67 //===----------------------------------------------------------------------===//
68 // R600 Target Machine (R600 -> Cayman)
69 //===----------------------------------------------------------------------===//
70 
71 class R600TargetMachine final : public AMDGPUTargetMachine {
72 private:
73  mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
74 
75 public:
76  R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
79  CodeGenOpt::Level OL, bool JIT);
80 
82 
83  const R600Subtarget *getSubtargetImpl(const Function &) const override;
84 
86 
87  bool isMachineVerifierClean() const override {
88  return false;
89  }
90 };
91 
92 //===----------------------------------------------------------------------===//
93 // GCN Target Machine (SI+)
94 //===----------------------------------------------------------------------===//
95 
96 class GCNTargetMachine final : public AMDGPUTargetMachine {
97 private:
98  mutable StringMap<std::unique_ptr<GCNSubtarget>> SubtargetMap;
99 
100 public:
101  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
104  CodeGenOpt::Level OL, bool JIT);
105 
107 
108  const GCNSubtarget *getSubtargetImpl(const Function &) const override;
109 
111 
112  bool useIPRA() const override {
113  return true;
114  }
115 
118  convertFuncInfoToYAML(const MachineFunction &MF) const override;
122  SMRange &SourceRange) const override;
123 };
124 
125 } // end namespace llvm
126 
127 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1221
llvm::AMDGPUTargetMachine::EnableFixedFunctionABI
static bool EnableFixedFunctionABI
Definition: AMDGPUTargetMachine.h:37
llvm
Definition: AllocatorList.h:23
llvm::AMDGPUTargetMachine::registerDefaultAliasAnalyses
void registerDefaultAliasAnalyses(AAManager &) override
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
Definition: AMDGPUTargetMachine.cpp:484
llvm::GCNTargetMachine::convertFuncInfoToYAML
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
Definition: AMDGPUTargetMachine.cpp:1238
llvm::TargetOptions
Definition: TargetOptions.h:119
llvm::Function
Definition: Function.h:61
llvm::yaml::MachineFunctionInfo
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
Definition: MIRYamlMapping.h:626
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:124
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:167
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::AMDGPUTargetMachine::TLOF
std::unique_ptr< TargetLoweringObjectFile > TLOF
Definition: AMDGPUTargetMachine.h:29
llvm::TargetMachine::RM
Reloc::Model RM
Definition: TargetMachine.h:100
llvm::Optional< Reloc::Model >
llvm::R600TargetMachine
Definition: AMDGPUTargetMachine.h:71
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::GCNSubtarget
Definition: GCNSubtarget.h:38
llvm::X86AS::FS
@ FS
Definition: X86.h:183
llvm::GCNTargetMachine::parseMachineFunctionInfo
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
Definition: AMDGPUTargetMachine.cpp:1244
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::TargetLoweringObjectFile
Definition: TargetLoweringObjectFile.h:43
llvm::GCNTargetMachine::GCNTargetMachine
GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Definition: AMDGPUTargetMachine.cpp:698
llvm::AMDGPUTargetMachine
Definition: AMDGPUTargetMachine.h:27
TargetMachine.h
llvm::R600TargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: AMDGPUTargetMachine.cpp:690
GCNSubtarget.h
llvm::PassBuilder
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:139
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:251
llvm::AMDGPUTargetMachine::getNullPointerValue
static int64_t getNullPointerValue(unsigned AddrSpace)
Get the integer value of a null pointer in the given address space.
Definition: AMDGPUTargetMachine.cpp:656
llvm::AMDGPUTargetMachine::~AMDGPUTargetMachine
~AMDGPUTargetMachine() override
llvm::AMDGPUTargetMachine::getSubtargetImpl
const TargetSubtargetInfo * getSubtargetImpl() const
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:108
llvm::PassManagerBuilder
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
Definition: PassManagerBuilder.h:59
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::AMDGPUTargetMachine::getFeatureString
StringRef getFeatureString(const Function &F) const
Definition: AMDGPUTargetMachine.cpp:404
llvm::R600Subtarget
Definition: R600Subtarget.h:36
llvm::R600TargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: AMDGPUTargetMachine.cpp:1019
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:525
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:115
llvm::AMDGPUTargetMachine::EnableLowerModuleLDS
static bool EnableLowerModuleLDS
Definition: AMDGPUTargetMachine.h:38
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::GCNTargetMachine
Definition: AMDGPUTargetMachine.h:96
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::GCNTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: AMDGPUTargetMachine.cpp:728
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::AMDGPUTargetMachine::getObjFileLowering
TargetLoweringObjectFile * getObjFileLowering() const override
Definition: AMDGPUTargetMachine.h:49
llvm::TargetSubtargetInfo
TargetSubtargetInfo - Generic base class for all target subtargets.
Definition: TargetSubtargetInfo.h:59
llvm::GCNTargetMachine::createPassConfig
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: AMDGPUTargetMachine.cpp:1229
llvm::PerFunctionMIParsingState
Definition: MIParser.h:160
llvm::R600TargetMachine::R600TargetMachine
R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT)
Definition: AMDGPUTargetMachine.cpp:621
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::AMDGPUTargetMachine::isNoopAddrSpaceCast
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
Definition: AMDGPUTargetMachine.cpp:664
R600Subtarget.h
llvm::AMDGPUTargetMachine::adjustPassManager
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
Definition: AMDGPUTargetMachine.cpp:419
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:386
llvm::AMDGPUTargetMachine::EnableFunctionCalls
static bool EnableFunctionCalls
Definition: AMDGPUTargetMachine.h:36
llvm::AMDGPUTargetMachine::getAssumedAddrSpace
unsigned getAssumedAddrSpace(const Value *V) const override
If the specified generic pointer could be assumed as a pointer to a specific address space,...
Definition: AMDGPUTargetMachine.cpp:670
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::AMDGPUTargetMachine::getGPUName
StringRef getGPUName(const Function &F) const
Definition: AMDGPUTargetMachine.cpp:399
llvm::GCNTargetMachine::useIPRA
bool useIPRA() const override
True if the target wants to use interprocedural register allocation by default.
Definition: AMDGPUTargetMachine.h:112
llvm::R600TargetMachine::isMachineVerifierClean
bool isMachineVerifierClean() const override
Returns true if the target is expected to pass all machine verifier checks.
Definition: AMDGPUTargetMachine.h:87
llvm::AMDGPUTargetMachine::AMDGPUTargetMachine
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL)
Definition: AMDGPUTargetMachine.cpp:373
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AMDGPUTargetMachine::EnableLateStructurizeCFG
static bool EnableLateStructurizeCFG
Definition: AMDGPUTargetMachine.h:35
llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks
void registerPassBuilderCallbacks(PassBuilder &PB, bool DebugPassManager) override
Allow the target to modify the pass pipeline with New Pass Manager (similar to adjustPassManager for ...
Definition: AMDGPUTargetMachine.cpp:488
llvm::GCNTargetMachine::createDefaultFuncInfoYAML
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
Definition: AMDGPUTargetMachine.cpp:1233