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
{
41 void dump(StringRef HSAMetadataString
) const;
43 void verify(StringRef HSAMetadataString
) const;
45 AccessQualifier
getAccessQualifier(StringRef AccQual
) const;
47 AddressSpaceQualifier
getAddressSpaceQualifer(unsigned AddressSpace
) const;
49 ValueKind
getValueKind(Type
*Ty
, StringRef TypeQual
,
50 StringRef BaseTypeName
) const;
52 ValueType
getValueType(Type
*Ty
, StringRef TypeName
) const;
54 std::string
getTypeName(Type
*Ty
, bool Signed
) const;
56 std::vector
<uint32_t> getWorkGroupDimensions(MDNode
*Node
) const;
58 Kernel::CodeProps::Metadata
getHSACodeProps(
59 const MachineFunction
&MF
,
60 const SIProgramInfo
&ProgramInfo
) const;
61 Kernel::DebugProps::Metadata
getHSADebugProps(
62 const MachineFunction
&MF
,
63 const SIProgramInfo
&ProgramInfo
) const;
67 void emitPrintf(const Module
&Mod
);
69 void emitKernelLanguage(const Function
&Func
);
71 void emitKernelAttrs(const Function
&Func
);
73 void emitKernelArgs(const Function
&Func
);
75 void emitKernelArg(const Argument
&Arg
);
77 void emitKernelArg(const DataLayout
&DL
, Type
*Ty
, ValueKind ValueKind
,
78 unsigned PointeeAlign
= 0,
79 StringRef Name
= "", StringRef TypeName
= "",
80 StringRef BaseTypeName
= "", StringRef AccQual
= "",
81 StringRef TypeQual
= "");
83 void emitHiddenKernelArgs(const Function
&Func
);
86 MetadataStreamer() = default;
87 ~MetadataStreamer() = default;
89 const Metadata
&getHSAMetadata() const {
93 void begin(const Module
&Mod
);
97 void emitKernel(const MachineFunction
&MF
, const SIProgramInfo
&ProgramInfo
);
100 } // end namespace HSAMD
101 } // end namespace AMDGPU
102 } // end namespace llvm
104 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H