LLVM  9.0.0svn
AMDGPUTargetStreamer.h
Go to the documentation of this file.
1 //===-- AMDGPUTargetStreamer.h - AMDGPU Target Streamer --------*- 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 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUTARGETSTREAMER_H
10 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUTARGETSTREAMER_H
11 
12 #include "AMDKernelCodeT.h"
14 #include "llvm/MC/MCStreamer.h"
18 
19 namespace llvm {
20 #include "AMDGPUPTNote.h"
21 
22 class DataLayout;
23 class Function;
24 class MCELFStreamer;
25 class MCSymbol;
26 class MDNode;
27 class Module;
28 class Type;
29 
31 protected:
32  MCContext &getContext() const { return Streamer.getContext(); }
33 
34 public:
36 
37  virtual void EmitDirectiveAMDGCNTarget(StringRef Target) = 0;
38 
40  uint32_t Minor) = 0;
41 
42  virtual void EmitDirectiveHSACodeObjectISA(uint32_t Major, uint32_t Minor,
43  uint32_t Stepping,
44  StringRef VendorName,
45  StringRef ArchName) = 0;
46 
47  virtual void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) = 0;
48 
49  virtual void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) = 0;
50 
51  /// \returns True on success, false on failure.
52  virtual bool EmitISAVersion(StringRef IsaVersionString) = 0;
53 
54  /// \returns True on success, false on failure.
55  virtual bool EmitHSAMetadataV2(StringRef HSAMetadataString);
56 
57  /// \returns True on success, false on failure.
58  virtual bool EmitHSAMetadataV3(StringRef HSAMetadataString);
59 
60  /// Emit HSA Metadata
61  ///
62  /// When \p Strict is true, known metadata elements must already be
63  /// well-typed. When \p Strict is false, known types are inferred and
64  /// the \p HSAMetadata structure is updated with the correct types.
65  ///
66  /// \returns True on success, false on failure.
67  virtual bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) = 0;
68 
69  /// \returns True on success, false on failure.
70  virtual bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) = 0;
71 
72  /// \returns True on success, false on failure.
73  virtual bool EmitPALMetadata(const AMDGPU::PALMD::Metadata &PALMetadata) = 0;
74 
75  virtual void EmitAmdhsaKernelDescriptor(
76  const MCSubtargetInfo &STI, StringRef KernelName,
77  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
78  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
79  bool ReserveXNACK) = 0;
80 
81  static StringRef getArchNameFromElfMach(unsigned ElfMach);
82  static unsigned getElfMach(StringRef GPU);
83 };
84 
87 public:
89 
91 
93  uint32_t Minor) override;
94 
96  uint32_t Stepping, StringRef VendorName,
97  StringRef ArchName) override;
98 
99  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
100 
101  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
102 
103  /// \returns True on success, false on failure.
104  bool EmitISAVersion(StringRef IsaVersionString) override;
105 
106  /// \returns True on success, false on failure.
107  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
108 
109  /// \returns True on success, false on failure.
110  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
111 
112  /// \returns True on success, false on failure.
113  bool EmitPALMetadata(const AMDGPU::PALMD::Metadata &PALMetadata) override;
114 
116  const MCSubtargetInfo &STI, StringRef KernelName,
117  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
118  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
119  bool ReserveXNACK) override;
120 };
121 
124 
125  void EmitNote(StringRef Name, const MCExpr *DescSize, unsigned NoteType,
126  function_ref<void(MCELFStreamer &)> EmitDesc);
127 
128 public:
130 
132 
134 
136  uint32_t Minor) override;
137 
139  uint32_t Stepping, StringRef VendorName,
140  StringRef ArchName) override;
141 
142  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
143 
144  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
145 
146  /// \returns True on success, false on failure.
147  bool EmitISAVersion(StringRef IsaVersionString) override;
148 
149  /// \returns True on success, false on failure.
150  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
151 
152  /// \returns True on success, false on failure.
153  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
154 
155  /// \returns True on success, false on failure.
156  bool EmitPALMetadata(const AMDGPU::PALMD::Metadata &PALMetadata) override;
157 
159  const MCSubtargetInfo &STI, StringRef KernelName,
160  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
161  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
162  bool ReserveXNACK) override;
163 };
164 
165 }
166 #endif
In-memory representation of HSA metadata.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:48
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target specific streamer interface.
Definition: MCStreamer.h:83
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:116
virtual void EmitAmdhsaKernelDescriptor(const MCSubtargetInfo &STI, StringRef KernelName, const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR, uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr, bool ReserveXNACK)=0
virtual bool EmitHSAMetadataV2(StringRef HSAMetadataString)
virtual void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type)=0
virtual bool EmitHSAMetadataV3(StringRef HSAMetadataString)
MCContext & getContext() const
Definition: MCStreamer.h:250
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
AMD Kernel Code Object (amd_kernel_code_t).
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
static StringRef getArchNameFromElfMach(unsigned ElfMach)
virtual bool EmitPALMetadata(const AMDGPU::PALMD::Metadata &PALMetadata)=0
Context object for machine code objects.
Definition: MCContext.h:62
Streaming machine code generation interface.
Definition: MCStreamer.h:188
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
static unsigned getElfMach(StringRef GPU)
virtual void EmitDirectiveHSACodeObjectISA(uint32_t Major, uint32_t Minor, uint32_t Stepping, StringRef VendorName, StringRef ArchName)=0
AMDHSA kernel descriptor definitions.
Enums and constants for AMDGPU PT_NOTE sections.
MCStreamer & getStreamer()
Definition: MCStreamer.h:91
MCContext & getContext() const
MCStreamer & Streamer
Definition: MCStreamer.h:85
virtual void EmitAMDKernelCodeT(const amd_kernel_code_t &Header)=0
Target - Wrapper for Target specific information.
virtual void EmitDirectiveHSACodeObjectVersion(uint32_t Major, uint32_t Minor)=0
Simple in-memory representation of a document of msgpack objects with ability to find and create arra...
virtual bool EmitISAVersion(StringRef IsaVersionString)=0
virtual void EmitDirectiveAMDGCNTarget(StringRef Target)=0
Generic base class for all target subtargets.
virtual bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict)=0
Emit HSA Metadata.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
AMDGPU metadata definitions and in-memory representations.
std::vector< uint32_t > Metadata
PAL metadata represented as a vector.