1 //===--- AMDGPUCodeObjectMetadataStreamer.h ---------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief AMDGPU Code Object Metadata Streamer.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
17 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
20 #include "AMDGPUCodeObjectMetadata.h"
21 #include "AMDKernelCodeT.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/ErrorOr.h"
35 namespace CodeObject {
37 class MetadataStreamer final {
39 Metadata CodeObjectMetadata;
42 void dump(StringRef YamlString) const;
44 void verify(StringRef YamlString) const;
46 AccessQualifier getAccessQualifier(StringRef AccQual) const;
48 AddressSpaceQualifier getAddressSpaceQualifer(unsigned AddressSpace) const;
50 ValueKind getValueKind(Type *Ty, StringRef TypeQual,
51 StringRef BaseTypeName) const;
53 ValueType getValueType(Type *Ty, StringRef TypeName) const;
55 std::string getTypeName(Type *Ty, bool Signed) const;
57 std::vector<uint32_t> getWorkGroupDimensions(MDNode *Node) const;
61 void emitPrintf(const Module &Mod);
63 void emitKernelLanguage(const Function &Func);
65 void emitKernelAttrs(const Function &Func);
67 void emitKernelArgs(const Function &Func);
69 void emitKernelArg(const Argument &Arg);
71 void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
72 StringRef TypeQual = "", StringRef BaseTypeName = "",
73 StringRef AccQual = "", StringRef Name = "",
74 StringRef TypeName = "");
76 void emitKernelCodeProps(const amd_kernel_code_t &KernelCode);
78 void emitKernelDebugProps(const amd_kernel_code_t &KernelCode);
81 MetadataStreamer() = default;
82 ~MetadataStreamer() = default;
84 void begin(const Module &Mod);
88 void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode);
90 ErrorOr<std::string> toYamlString();
92 ErrorOr<std::string> toYamlString(StringRef YamlString);
95 } // end namespace CodeObject
96 } // end namespace AMDGPU
97 } // end namespace llvm
99 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H