Line data Source code
1 : //===--- AMDGPUCodeObjectMetadataStreamer.h ---------------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : //
10 : /// \file
11 : /// \brief AMDGPU Code Object Metadata Streamer.
12 : ///
13 : //
14 : //===----------------------------------------------------------------------===//
15 :
16 : #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
17 : #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
18 :
19 : #include "AMDGPU.h"
20 : #include "AMDKernelCodeT.h"
21 : #include "llvm/ADT/StringRef.h"
22 : #include "llvm/Support/AMDGPUCodeObjectMetadata.h"
23 : #include "llvm/Support/ErrorOr.h"
24 :
25 : namespace llvm {
26 :
27 : class Argument;
28 : class DataLayout;
29 : class Function;
30 : class MDNode;
31 : class Module;
32 : class Type;
33 :
34 : namespace AMDGPU {
35 : namespace CodeObject {
36 :
37 : class MetadataStreamer final {
38 : private:
39 : Metadata CodeObjectMetadata;
40 : AMDGPUAS AMDGPUASI;
41 :
42 : void dump(StringRef YamlString) const;
43 :
44 : void verify(StringRef YamlString) const;
45 :
46 : AccessQualifier getAccessQualifier(StringRef AccQual) const;
47 :
48 : AddressSpaceQualifier getAddressSpaceQualifer(unsigned AddressSpace) const;
49 :
50 : ValueKind getValueKind(Type *Ty, StringRef TypeQual,
51 : StringRef BaseTypeName) const;
52 :
53 : ValueType getValueType(Type *Ty, StringRef TypeName) const;
54 :
55 : std::string getTypeName(Type *Ty, bool Signed) const;
56 :
57 : std::vector<uint32_t> getWorkGroupDimensions(MDNode *Node) const;
58 :
59 : void emitVersion();
60 :
61 : void emitPrintf(const Module &Mod);
62 :
63 : void emitKernelLanguage(const Function &Func);
64 :
65 : void emitKernelAttrs(const Function &Func);
66 :
67 : void emitKernelArgs(const Function &Func);
68 :
69 : void emitKernelArg(const Argument &Arg);
70 :
71 : void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
72 : StringRef TypeQual = "", StringRef BaseTypeName = "",
73 : StringRef AccQual = "", StringRef Name = "",
74 : StringRef TypeName = "");
75 :
76 : void emitKernelCodeProps(const amd_kernel_code_t &KernelCode);
77 :
78 : void emitKernelDebugProps(const amd_kernel_code_t &KernelCode);
79 :
80 : public:
81 3528 : MetadataStreamer() = default;
82 1755 : ~MetadataStreamer() = default;
83 :
84 : void begin(const Module &Mod);
85 :
86 : void end() {}
87 :
88 : void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode);
89 :
90 : ErrorOr<std::string> toYamlString();
91 :
92 : ErrorOr<std::string> toYamlString(StringRef YamlString);
93 : };
94 :
95 : } // end namespace CodeObject
96 : } // end namespace AMDGPU
97 : } // end namespace llvm
98 :
99 : #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
|