LLVM  10.0.0svn
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 "AMDGPUSubtarget.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/CodeGen.h"
24 #include <memory>
25 
26 namespace llvm {
27 
28 //===----------------------------------------------------------------------===//
29 // AMDGPU Target Machine (R600+)
30 //===----------------------------------------------------------------------===//
31 
33 protected:
34  std::unique_ptr<TargetLoweringObjectFile> TLOF;
35 
36  StringRef getGPUName(const Function &F) const;
37  StringRef getFeatureString(const Function &F) const;
38 
39 public:
41  static bool EnableFunctionCalls;
42 
43  AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
47  ~AMDGPUTargetMachine() override;
48 
50  const TargetSubtargetInfo *getSubtargetImpl(const Function &) const override = 0;
51 
53  return TLOF.get();
54  }
55 
56  void adjustPassManager(PassManagerBuilder &) override;
57 
58  /// Get the integer value of a null pointer in the given address space.
59  uint64_t getNullPointerValue(unsigned AddrSpace) const {
60  return (AddrSpace == AMDGPUAS::LOCAL_ADDRESS ||
61  AddrSpace == AMDGPUAS::REGION_ADDRESS) ? -1 : 0;
62  }
63 };
64 
65 //===----------------------------------------------------------------------===//
66 // R600 Target Machine (R600 -> Cayman)
67 //===----------------------------------------------------------------------===//
68 
69 class R600TargetMachine final : public AMDGPUTargetMachine {
70 private:
71  mutable StringMap<std::unique_ptr<R600Subtarget>> SubtargetMap;
72 
73 public:
74  R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
77  CodeGenOpt::Level OL, bool JIT);
78 
80 
81  const R600Subtarget *getSubtargetImpl(const Function &) const override;
82 
84 
85  bool isMachineVerifierClean() const override {
86  return false;
87  }
88 };
89 
90 //===----------------------------------------------------------------------===//
91 // GCN Target Machine (SI+)
92 //===----------------------------------------------------------------------===//
93 
94 class GCNTargetMachine final : public AMDGPUTargetMachine {
95 private:
96  mutable StringMap<std::unique_ptr<GCNSubtarget>> SubtargetMap;
97 
98 public:
99  GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
102  CodeGenOpt::Level OL, bool JIT);
103 
105 
106  const GCNSubtarget *getSubtargetImpl(const Function &) const override;
107 
109 
110  bool useIPRA() const override {
111  return true;
112  }
113 
116  convertFuncInfoToYAML(const MachineFunction &MF) const override;
120  SMRange &SourceRange) const override;
121 };
122 
123 } // end namespace llvm
124 
125 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETMACHINE_H
virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const
Parse out the target&#39;s MachineFunctionInfo from the YAML reprsentation.
Represents a range in source code.
Definition: SMLoc.h:48
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
bool useIPRA() const override
True if the target wants to use interprocedural register allocation by default.
F(f)
Address space for region memory. (GDS)
Definition: AMDGPU.h:271
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
StringRef getFeatureString(const Function &F) const
TargetTransformInfo getTargetTransformInfo(const Function &F) override
Get a TargetTransformInfo implementation for the target.
Target-Independent Code Generator Pass Configuration Options.
std::unique_ptr< TargetLoweringObjectFile > TLOF
StringRef getGPUName(const Function &F) const
Address space for local memory.
Definition: AMDGPU.h:274
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
const TargetSubtargetInfo * getSubtargetImpl() const
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
bool isMachineVerifierClean() const override
Returns true if the target is expected to pass all machine verifier checks.
uint64_t getNullPointerValue(unsigned AddrSpace) const
Get the integer value of a null pointer in the given address space.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:242
Target - Wrapper for Target specific information.
virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
TargetSubtargetInfo - Generic base class for all target subtargets.
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
TargetLoweringObjectFile * getObjFileLowering() const override
TargetOptions Options
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
This pass exposes codegen information to IR-level passes.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:261