1 //===--- AMDGPUHSAMetadataStreamer.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 /// AMDGPU HSA Metadata Streamer.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
17 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
20 #include "AMDKernelCodeT.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/AMDGPUMetadata.h"
37 class MetadataStreamer final {
42 void dump(StringRef HSAMetadataString) const;
44 void verify(StringRef HSAMetadataString) 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;
59 Kernel::CodeProps::Metadata getHSACodeProps(
60 const MachineFunction &MF,
61 const SIProgramInfo &ProgramInfo) const;
62 Kernel::DebugProps::Metadata getHSADebugProps(
63 const MachineFunction &MF,
64 const SIProgramInfo &ProgramInfo) const;
68 void emitPrintf(const Module &Mod);
70 void emitKernelLanguage(const Function &Func);
72 void emitKernelAttrs(const Function &Func);
74 void emitKernelArgs(const Function &Func);
76 void emitKernelArg(const Argument &Arg);
78 void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
79 unsigned PointeeAlign = 0,
80 StringRef Name = "", StringRef TypeName = "",
81 StringRef BaseTypeName = "", StringRef AccQual = "",
82 StringRef TypeQual = "");
84 void emitHiddenKernelArgs(const Function &Func);
87 MetadataStreamer() = default;
88 ~MetadataStreamer() = default;
90 const Metadata &getHSAMetadata() const {
94 void begin(const Module &Mod);
98 void emitKernel(const MachineFunction &MF, const SIProgramInfo &ProgramInfo);
101 } // end namespace HSAMD
102 } // end namespace AMDGPU
103 } // end namespace llvm
105 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H