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"
15 #include "llvm/MC/MCStreamer.h"
19 
20 namespace llvm {
21 #include "AMDGPUPTNote.h"
22 
23 class DataLayout;
24 class Function;
25 class MCELFStreamer;
26 class MCSymbol;
27 class MDNode;
28 class Module;
29 class Type;
30 
32  AMDGPUPALMetadata PALMetadata;
33 
34 protected:
35  MCContext &getContext() const { return Streamer.getContext(); }
36 
37 public:
39 
40  AMDGPUPALMetadata *getPALMetadata() { return &PALMetadata; }
41 
42  virtual void EmitDirectiveAMDGCNTarget(StringRef Target) = 0;
43 
45  uint32_t Minor) = 0;
46 
47  virtual void EmitDirectiveHSACodeObjectISA(uint32_t Major, uint32_t Minor,
48  uint32_t Stepping,
49  StringRef VendorName,
50  StringRef ArchName) = 0;
51 
52  virtual void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) = 0;
53 
54  virtual void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) = 0;
55 
56  /// \returns True on success, false on failure.
57  virtual bool EmitISAVersion(StringRef IsaVersionString) = 0;
58 
59  /// \returns True on success, false on failure.
60  virtual bool EmitHSAMetadataV2(StringRef HSAMetadataString);
61 
62  /// \returns True on success, false on failure.
63  virtual bool EmitHSAMetadataV3(StringRef HSAMetadataString);
64 
65  /// Emit HSA Metadata
66  ///
67  /// When \p Strict is true, known metadata elements must already be
68  /// well-typed. When \p Strict is false, known types are inferred and
69  /// the \p HSAMetadata structure is updated with the correct types.
70  ///
71  /// \returns True on success, false on failure.
72  virtual bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) = 0;
73 
74  /// \returns True on success, false on failure.
75  virtual bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) = 0;
76 
77  /// \returns True on success, false on failure.
78  virtual bool EmitCodeEnd() = 0;
79 
80  virtual void EmitAmdhsaKernelDescriptor(
81  const MCSubtargetInfo &STI, StringRef KernelName,
82  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
83  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
84  bool ReserveXNACK) = 0;
85 
86  static StringRef getArchNameFromElfMach(unsigned ElfMach);
87  static unsigned getElfMach(StringRef GPU);
88 };
89 
92 public:
94 
95  void finish() override;
96 
98 
100  uint32_t Minor) override;
101 
103  uint32_t Stepping, StringRef VendorName,
104  StringRef ArchName) override;
105 
106  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
107 
108  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
109 
110  /// \returns True on success, false on failure.
111  bool EmitISAVersion(StringRef IsaVersionString) override;
112 
113  /// \returns True on success, false on failure.
114  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
115 
116  /// \returns True on success, false on failure.
117  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
118 
119  /// \returns True on success, false on failure.
120  bool EmitCodeEnd() override;
121 
123  const MCSubtargetInfo &STI, StringRef KernelName,
124  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
125  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
126  bool ReserveXNACK) override;
127 };
128 
131 
132  void EmitNote(StringRef Name, const MCExpr *DescSize, unsigned NoteType,
133  function_ref<void(MCELFStreamer &)> EmitDesc);
134 
135 public:
137 
139 
140  void finish() override;
141 
143 
145  uint32_t Minor) override;
146 
148  uint32_t Stepping, StringRef VendorName,
149  StringRef ArchName) override;
150 
151  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
152 
153  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
154 
155  /// \returns True on success, false on failure.
156  bool EmitISAVersion(StringRef IsaVersionString) override;
157 
158  /// \returns True on success, false on failure.
159  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
160 
161  /// \returns True on success, false on failure.
162  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
163 
164  /// \returns True on success, false on failure.
165  bool EmitCodeEnd() override;
166 
168  const MCSubtargetInfo &STI, StringRef KernelName,
169  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
170  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
171  bool ReserveXNACK) override;
172 };
173 
174 }
175 #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)
Context object for machine code objects.
Definition: MCContext.h:62
virtual bool EmitCodeEnd()=0
virtual void finish()
Definition: MCStreamer.cpp:50
Streaming machine code generation interface.
Definition: MCStreamer.h:188
AMDGPUPALMetadata * getPALMetadata()
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)
PAL metadata handling.
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.