LLVM  14.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"
20 
21 namespace llvm {
22 
23 class ScheduleDAGMILive;
24 
25 //===----------------------------------------------------------------------===//
26 // AMDGPU Target Machine (R600+)
27 //===----------------------------------------------------------------------===//
28 
30 protected:
31  std::unique_ptr<TargetLoweringObjectFile> TLOF;
32 
33  StringRef getGPUName(const Function &F) const;
34  StringRef getFeatureString(const Function &F) const;
35 
36 public:
38  static bool EnableFunctionCalls;
40  static bool EnableLowerModuleLDS;
41 
42  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
46  ~AMDGPUTargetMachine() override;
47 
49  const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override = 0;
50 
52  return TLOF.get();
53  }
54 
55  void adjustPassManager(PassManagerBuilder &) override;
56 
58  void registerDefaultAliasAnalyses(AAManager &) override;
59 
60  /// Get the integer value of a null pointer in the given address space.
61  static int64_t getNullPointerValue(unsigned AddrSpace);
62 
63  bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
64 
65  unsigned getAssumedAddrSpace(const Value *V) const override;
66 };
67 
68 //===----------------------------------------------------------------------===//
69 // GCN Target Machine (SI+)
70 //===----------------------------------------------------------------------===//
71 
72 class GCNTargetMachine final : public AMDGPUTargetMachine {
73 private:
74  mutable StringMap<std::unique_ptr<GCNSubtarget>> SubtargetMap;
75 
76 public:
77  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
80  CodeGenOpt::Level OL, bool JIT);
81 
83 
84  const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override;
85 
87 
88  bool useIPRA() const override {
89  return true;
90  }
91 
94  convertFuncInfoToYAML(const MachineFunction &MF) const override;
98  SMRange &SourceRange) const override;
99 };
100 
101 //===----------------------------------------------------------------------===//
102 // AMDGPU Pass Setup
103 //===----------------------------------------------------------------------===//
104 
106 public:
108 
110  return getTM<AMDGPUTargetMachine>();
111  }
112 
115 
116  void addEarlyCSEOrGVNPass();
118  void addIRPasses() override;
119  void addCodeGenPrepare() override;
120  bool addPreISel() override;
121  bool addInstSelector() override;
122  bool addGCPasses() override;
123 
124  std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
125 
126  /// Check if a pass is enabled given \p Opt option. The option always
127  /// overrides defaults if explicitly used. Otherwise its default will
128  /// be used given that a pass shall work at an optimization \p Level
129  /// minimum.
130  bool isPassEnabled(const cl::opt<bool> &Opt,
132  if (Opt.getNumOccurrences())
133  return Opt;
134  if (TM->getOptLevel() < Level)
135  return false;
136  return Opt;
137  }
138 };
139 
140 } // end namespace llvm
141 
142 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
llvm::TargetMachine::getOptLevel
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Definition: TargetMachine.cpp:185
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1288
llvm::AMDGPUTargetMachine::EnableFixedFunctionABI
static bool EnableFixedFunctionABI
Definition: AMDGPUTargetMachine.h:39
llvm
---------------------— PointerInfo ------------------------------------—
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:591
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:1341
llvm::TargetOptions
Definition: TargetOptions.h:124
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:673
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:168
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:31
llvm::AMDGPUPassConfig
Definition: AMDGPUTargetMachine.h:105
llvm::TargetMachine::RM
Reloc::Model RM
Definition: TargetMachine.h:102
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
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:1347
llvm::AMDGPUPassConfig::addGCPasses
bool addGCPasses() override
addGCPasses - Add late codegen passes that analyze code for garbage collection.
Definition: AMDGPUTargetMachine.cpp:1026
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::TargetLoweringObjectFile
Definition: TargetLoweringObjectFile.h:43
llvm::AMDGPUPassConfig::addIRPasses
void addIRPasses() override
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
Definition: AMDGPUTargetMachine.cpp:895
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:759
llvm::TargetPassConfig::TM
LLVMTargetMachine * TM
Definition: TargetPassConfig.h:122
llvm::AMDGPUTargetMachine
Definition: AMDGPUTargetMachine.h:29
TargetMachine.h
GCNSubtarget.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::PassBuilder
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:84
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:722
llvm::cl::Option::getNumOccurrences
int getNumOccurrences() const
Definition: CommandLine.h:404
llvm::AMDGPUPassConfig::addCodeGenPrepare
void addCodeGenPrepare() override
Add pass to prepare the LLVM IR for code generation.
Definition: AMDGPUTargetMachine.cpp:989
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::AMDGPUPassConfig::addInstSelector
bool addInstSelector() override
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
Definition: AMDGPUTargetMachine.cpp:1020
PB
PassBuilder PB(Machine, PassOpts->PTO, None, &PIC)
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:510
llvm::cl::opt< bool >
llvm::CodeGenOpt::Default
@ Default
Definition: CodeGen.h:55
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:524
llvm::MachineSchedContext
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
Definition: MachineScheduler.h:120
llvm::AMDGPUPassConfig::createMachineScheduler
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
Definition: AMDGPUTargetMachine.cpp:1032
TargetPassConfig.h
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:120
llvm::AMDGPUPassConfig::addStraightLineScalarOptimizationPasses
void addStraightLineScalarOptimizationPasses()
Definition: AMDGPUTargetMachine.cpp:878
llvm::AMDGPUPassConfig::getAMDGPUTargetMachine
AMDGPUTargetMachine & getAMDGPUTargetMachine() const
Definition: AMDGPUTargetMachine.h:109
llvm::AMDGPUPassConfig::AMDGPUPassConfig
AMDGPUPassConfig(LLVMTargetMachine &TM, PassManagerBase &PM)
Definition: AMDGPUTargetMachine.cpp:860
llvm::AMDGPUTargetMachine::EnableLowerModuleLDS
static bool EnableLowerModuleLDS
Definition: AMDGPUTargetMachine.h:40
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::GCNTargetMachine
Definition: AMDGPUTargetMachine.h:72
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::GCNTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Definition: AMDGPUTargetMachine.cpp:790
llvm::AMDGPUPassConfig::addPreISel
bool addPreISel() override
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
Definition: AMDGPUTargetMachine.cpp:1014
llvm::PICLevel::Level
Level
Definition: CodeGen.h:33
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::AMDGPUPassConfig::getCSEConfig
std::unique_ptr< CSEConfigBase > getCSEConfig() const override
Returns the CSEConfig object to use for the current optimization level.
Definition: AMDGPUTargetMachine.cpp:798
llvm::AMDGPUTargetMachine::getObjFileLowering
TargetLoweringObjectFile * getObjFileLowering() const override
Definition: AMDGPUTargetMachine.h:51
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:1332
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::AMDGPUTargetMachine::registerPassBuilderCallbacks
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline with New Pass Manager (similar to adjustPassManager for ...
Definition: AMDGPUTargetMachine.cpp:595
llvm::AMDGPUPassConfig::addEarlyCSEOrGVNPass
void addEarlyCSEOrGVNPass()
Definition: AMDGPUTargetMachine.cpp:871
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::X86AS::FS
@ FS
Definition: X86.h:188
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:730
llvm::AMDGPUTargetMachine::adjustPassManager
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
Definition: AMDGPUTargetMachine.cpp:526
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:393
llvm::AMDGPUPassConfig::isPassEnabled
bool isPassEnabled(const cl::opt< bool > &Opt, CodeGenOpt::Level Level=CodeGenOpt::Default) const
Check if a pass is enabled given Opt option.
Definition: AMDGPUTargetMachine.h:130
llvm::AMDGPUTargetMachine::EnableFunctionCalls
static bool EnableFunctionCalls
Definition: AMDGPUTargetMachine.h:38
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:736
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:505
llvm::GCNTargetMachine::useIPRA
bool useIPRA() const override
True if the target wants to use interprocedural register allocation by default.
Definition: AMDGPUTargetMachine.h:88
llvm::ScheduleDAGInstrs
A ScheduleDAG for scheduling lists of MachineInstr.
Definition: ScheduleDAGInstrs.h:119
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:479
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AMDGPUTargetMachine::EnableLateStructurizeCFG
static bool EnableLateStructurizeCFG
Definition: AMDGPUTargetMachine.h:37
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:1336