LLVM  10.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  virtual void emitAMDGPULDS(MCSymbol *Symbol, unsigned Size,
57  unsigned Align) = 0;
58 
59  /// \returns True on success, false on failure.
60  virtual bool EmitISAVersion(StringRef IsaVersionString) = 0;
61 
62  /// \returns True on success, false on failure.
63  virtual bool EmitHSAMetadataV2(StringRef HSAMetadataString);
64 
65  /// \returns True on success, false on failure.
66  virtual bool EmitHSAMetadataV3(StringRef HSAMetadataString);
67 
68  /// Emit HSA Metadata
69  ///
70  /// When \p Strict is true, known metadata elements must already be
71  /// well-typed. When \p Strict is false, known types are inferred and
72  /// the \p HSAMetadata structure is updated with the correct types.
73  ///
74  /// \returns True on success, false on failure.
75  virtual bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) = 0;
76 
77  /// \returns True on success, false on failure.
78  virtual bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) = 0;
79 
80  /// \returns True on success, false on failure.
81  virtual bool EmitCodeEnd() = 0;
82 
83  virtual void EmitAmdhsaKernelDescriptor(
84  const MCSubtargetInfo &STI, StringRef KernelName,
85  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
86  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
87  bool ReserveXNACK) = 0;
88 
89  static StringRef getArchNameFromElfMach(unsigned ElfMach);
90  static unsigned getElfMach(StringRef GPU);
91 };
92 
95 public:
97 
98  void finish() override;
99 
101 
103  uint32_t Minor) override;
104 
106  uint32_t Stepping, StringRef VendorName,
107  StringRef ArchName) override;
108 
109  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
110 
111  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
112 
113  void emitAMDGPULDS(MCSymbol *Sym, unsigned Size, unsigned Align) override;
114 
115  /// \returns True on success, false on failure.
116  bool EmitISAVersion(StringRef IsaVersionString) override;
117 
118  /// \returns True on success, false on failure.
119  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
120 
121  /// \returns True on success, false on failure.
122  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
123 
124  /// \returns True on success, false on failure.
125  bool EmitCodeEnd() override;
126 
128  const MCSubtargetInfo &STI, StringRef KernelName,
129  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
130  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
131  bool ReserveXNACK) override;
132 };
133 
136 
137  void EmitNote(StringRef Name, const MCExpr *DescSize, unsigned NoteType,
138  function_ref<void(MCELFStreamer &)> EmitDesc);
139 
140 public:
142 
144 
145  void finish() override;
146 
148 
150  uint32_t Minor) override;
151 
153  uint32_t Stepping, StringRef VendorName,
154  StringRef ArchName) override;
155 
156  void EmitAMDKernelCodeT(const amd_kernel_code_t &Header) override;
157 
158  void EmitAMDGPUSymbolType(StringRef SymbolName, unsigned Type) override;
159 
160  void emitAMDGPULDS(MCSymbol *Sym, unsigned Size, unsigned Align) override;
161 
162  /// \returns True on success, false on failure.
163  bool EmitISAVersion(StringRef IsaVersionString) override;
164 
165  /// \returns True on success, false on failure.
166  bool EmitHSAMetadata(msgpack::Document &HSAMetadata, bool Strict) override;
167 
168  /// \returns True on success, false on failure.
169  bool EmitHSAMetadata(const AMDGPU::HSAMD::Metadata &HSAMetadata) override;
170 
171  /// \returns True on success, false on failure.
172  bool EmitCodeEnd() override;
173 
175  const MCSubtargetInfo &STI, StringRef KernelName,
176  const amdhsa::kernel_descriptor_t &KernelDescriptor, uint64_t NextVGPR,
177  uint64_t NextSGPR, bool ReserveVCC, bool ReserveFlatScr,
178  bool ReserveXNACK) override;
179 };
180 
181 }
182 #endif
In-memory representation of HSA metadata.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
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:85
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:104
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:252
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:65
virtual bool EmitCodeEnd()=0
virtual void finish()
Definition: MCStreamer.cpp:52
Streaming machine code generation interface.
Definition: MCStreamer.h:190
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
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
AMDHSA kernel descriptor definitions.
Enums and constants for AMDGPU PT_NOTE sections.
MCStreamer & getStreamer()
Definition: MCStreamer.h:93
MCContext & getContext() const
MCStreamer & Streamer
Definition: MCStreamer.h:87
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.
uint32_t Size
Definition: Profile.cpp:46
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.
virtual void emitAMDGPULDS(MCSymbol *Symbol, unsigned Size, unsigned Align)=0