LLVM 18.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;
33class GCNSubtarget;
34
35namespace AMDGPU {
36
37namespace IsaInfo {
38class AMDGPUTargetID;
39}
40
41namespace HSAMD {
42
44public:
45 virtual ~MetadataStreamer() = default;
46
47 virtual bool emitTo(AMDGPUTargetStreamer &TargetStreamer) = 0;
48
49 virtual void begin(const Module &Mod,
50 const IsaInfo::AMDGPUTargetID &TargetID) = 0;
51
52 virtual void end() = 0;
53
54 virtual void emitKernel(const MachineFunction &MF,
55 const SIProgramInfo &ProgramInfo) = 0;
56
57protected:
58 virtual void emitVersion() = 0;
59 virtual void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
60 msgpack::ArrayDocNode Args) = 0;
61 virtual void emitKernelAttrs(const Function &Func,
62 msgpack::MapDocNode Kern) = 0;
63};
64
66protected:
67 std::unique_ptr<msgpack::Document> HSAMetadataDoc =
68 std::make_unique<msgpack::Document>();
69
70 void dump(StringRef HSAMetadataString) const;
71
72 void verify(StringRef HSAMetadataString) const;
73
74 std::optional<StringRef> getAccessQualifier(StringRef AccQual) const;
75
76 std::optional<StringRef>
78
80 StringRef BaseTypeName) const;
81
82 std::string getTypeName(Type *Ty, bool Signed) const;
83
85
87 const SIProgramInfo &ProgramInfo,
88 unsigned CodeObjectVersion) const;
89
90 void emitVersion() override;
91
92 void emitTargetID(const IsaInfo::AMDGPUTargetID &TargetID);
93
94 void emitPrintf(const Module &Mod);
95
96 void emitKernelLanguage(const Function &Func, msgpack::MapDocNode Kern);
97
98 void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override;
99
101
102 void emitKernelArg(const Argument &Arg, unsigned &Offset,
104
105 void emitKernelArg(const DataLayout &DL, Type *Ty, Align Alignment,
106 StringRef ValueKind, unsigned &Offset,
108 MaybeAlign PointeeAlign = std::nullopt,
109 StringRef Name = "", StringRef TypeName = "",
110 StringRef BaseTypeName = "", StringRef ActAccQual = "",
111 StringRef AccQual = "", StringRef TypeQual = "");
112
113 void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
114 msgpack::ArrayDocNode Args) override;
115
117 return HSAMetadataDoc->getRoot().getMap(/*Convert=*/true)[Key];
118 }
119
121 return HSAMetadataDoc->getRoot();
122 }
123
124public:
127
128 bool emitTo(AMDGPUTargetStreamer &TargetStreamer) override;
129
130 void begin(const Module &Mod,
131 const IsaInfo::AMDGPUTargetID &TargetID) override;
132
133 void end() override;
134
135 void emitKernel(const MachineFunction &MF,
136 const SIProgramInfo &ProgramInfo) override;
137};
138
140protected:
141 void emitVersion() override;
142 void emitHiddenKernelArgs(const MachineFunction &MF, unsigned &Offset,
143 msgpack::ArrayDocNode Args) override;
144 void emitKernelAttrs(const Function &Func, msgpack::MapDocNode Kern) override;
145
146public:
149};
150
151} // end namespace HSAMD
152} // end namespace AMDGPU
153} // end namespace llvm
154
155#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:1037
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:440
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:25