LLVM 19.0.0git
AMDGPUHSAMetadataStreamer.h
Go to the documentation of this file.
1//===--- AMDGPUHSAMetadataStreamer.h ----------------------------*- 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/// AMDGPU HSA Metadata Streamer.
11///
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
16#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
17
21
22namespace llvm {
23
24class AMDGPUTargetStreamer;
25class Argument;
26class DataLayout;
27class Function;
28class MachineFunction;
29class MDNode;
30class Module;
31struct SIProgramInfo;
32class Type;
33
34namespace AMDGPU {
35
36namespace IsaInfo {
37class AMDGPUTargetID;
38}
39
40namespace HSAMD {
41
43public:
44 virtual ~MetadataStreamer() = default;
45
46 virtual bool emitTo(AMDGPUTargetStreamer &TargetStreamer) = 0;
47
48 virtual void begin(const Module &Mod,
49 const IsaInfo::AMDGPUTargetID &TargetID) = 0;
50
51 virtual void end() = 0;
52
53 virtual void emitKernel(const MachineFunction &MF,
54 const SIProgramInfo &ProgramInfo) = 0;
55
56protected:
57 virtual void emitVersion() = 0;
58 virtual void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
59 msgpack::ArrayDocNode Args) = 0;
60 virtual void emitKernelAttrs(const Function &Func,
61 msgpack::MapDocNode Kern) = 0;
62};
63
65protected:
66 std::unique_ptr<msgpack::Document> HSAMetadataDoc =
67 std::make_unique<msgpack::Document>();
68
69 void dump(StringRef HSAMetadataString) const;
70
71 void verify(StringRef HSAMetadataString) const;
72
73 std::optional<StringRef> getAccessQualifier(StringRef AccQual) const;
74
75 std::optional<StringRef>
77
79 StringRef BaseTypeName) const;
80
81 std::string getTypeName(Type *Ty, bool Signed) const;
82
84
86 const SIProgramInfo &ProgramInfo,
87 unsigned CodeObjectVersion) const;
88
89 void emitVersion() override;
90
91 void emitTargetID(const IsaInfo::AMDGPUTargetID &TargetID);
92
93 void emitPrintf(const Module &Mod);
94
95 void emitKernelLanguage(const Function &Func, msgpack::MapDocNode Kern);
96
97 void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override;
98
100
101 void emitKernelArg(const Argument &Arg, unsigned &Offset,
103
104 void emitKernelArg(const DataLayout &DL, Type *Ty, Align Alignment,
105 StringRef ValueKind, unsigned &Offset,
107 MaybeAlign PointeeAlign = std::nullopt,
108 StringRef Name = "", StringRef TypeName = "",
109 StringRef BaseTypeName = "", StringRef ActAccQual = "",
110 StringRef AccQual = "", StringRef TypeQual = "");
111
112 void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
113 msgpack::ArrayDocNode Args) override;
114
116 return HSAMetadataDoc->getRoot().getMap(/*Convert=*/true)[Key];
117 }
118
120 return HSAMetadataDoc->getRoot();
121 }
122
123public:
126
127 bool emitTo(AMDGPUTargetStreamer &TargetStreamer) override;
128
129 void begin(const Module &Mod,
130 const IsaInfo::AMDGPUTargetID &TargetID) override;
131
132 void end() override;
133
134 void emitKernel(const MachineFunction &MF,
135 const SIProgramInfo &ProgramInfo) override;
136};
137
139protected:
140 void emitVersion() override;
141 void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
142 msgpack::ArrayDocNode Args) override;
143 void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override;
144
145public:
148};
149
151protected:
152 void emitVersion() override;
153
154public:
157};
158
159} // end namespace HSAMD
160} // end namespace AMDGPU
161} // end namespace llvm
162
163#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
AMDGPU metadata definitions and in-memory representations.
RelocType Type
Definition: COFFYAML.cpp:391
std::string Name
Machine Check Debug Module
This file declares a class that exposes a simple in-memory representation of a document of MsgPack ob...
ppc ctr loops verify
std::optional< StringRef > getAddressSpaceQualifier(unsigned AddressSpace) const
msgpack::ArrayDocNode getWorkGroupDimensions(MDNode *Node) const
std::optional< StringRef > getAccessQualifier(StringRef AccQual) const
void emitKernelLanguage(const Function &Func, msgpack::MapDocNode Kern)
msgpack::MapDocNode getHSAKernelProps(const MachineFunction &MF, const SIProgramInfo &ProgramInfo, unsigned CodeObjectVersion) const
void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override
std::unique_ptr< msgpack::Document > HSAMetadataDoc
bool emitTo(AMDGPUTargetStreamer &TargetStreamer) override
void emitKernelArgs(const MachineFunction &MF, msgpack::MapDocNode Kern)
void dump(StringRef HSAMetadataString) const
void begin(const Module &Mod, const IsaInfo::AMDGPUTargetID &TargetID) override
void emitKernelArg(const Argument &Arg, unsigned &Offset, msgpack::ArrayDocNode Args)
void emitTargetID(const IsaInfo::AMDGPUTargetID &TargetID)
StringRef getValueKind(Type *Ty, StringRef TypeQual, StringRef BaseTypeName) const
void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset, msgpack::ArrayDocNode Args) override
void emitKernel(const MachineFunction &MF, const SIProgramInfo &ProgramInfo) override
void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset, msgpack::ArrayDocNode Args) override
void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override
virtual void emitKernel(const MachineFunction &MF, const SIProgramInfo &ProgramInfo)=0
virtual void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset, msgpack::ArrayDocNode Args)=0
virtual void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern)=0
virtual bool emitTo(AMDGPUTargetStreamer &TargetStreamer)=0
virtual void begin(const Module &Mod, const IsaInfo::AMDGPUTargetID &TargetID)=0
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Metadata node.
Definition: Metadata.h:1067
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A DocNode that is an array.
A node in a MsgPack Document.
A DocNode that is a map.
ValueKind
Value kinds.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
AddressSpace
Definition: NVPTXBaseInfo.h:21
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
Definition: TypeName.h:27
@ Mod
The access may modify the value stored in memory.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
Track resource usage for kernels / entry functions.
Definition: SIProgramInfo.h:27