blob: 4d86d0184f182166f1df9259c6f101cd5fddbb2e [file] [log] [blame]
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +00001//===--- 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 "AMDGPUCodeObjectMetadata.h"
Konstantin Zhuravlyovca0e7f62017-03-22 22:54:39 +000020#include "AMDKernelCodeT.h"
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000021#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/ErrorOr.h"
23
24namespace llvm {
25
26class Argument;
27class DataLayout;
28class FeatureBitset;
29class Function;
30class MDNode;
31class Module;
32class Type;
33
34namespace AMDGPU {
35namespace CodeObject {
36
37class MetadataStreamer final {
38private:
39 Metadata CodeObjectMetadata;
40
41 void dump(StringRef YamlString) const;
42
43 void verify(StringRef YamlString) const;
44
45 AccessQualifier getAccessQualifier(StringRef AccQual) const;
46
47 AddressSpaceQualifier getAddressSpaceQualifer(unsigned AddressSpace) const;
48
49 ValueKind getValueKind(Type *Ty, StringRef TypeQual,
50 StringRef BaseTypeName) const;
51
52 ValueType getValueType(Type *Ty, StringRef TypeName) const;
53
54 std::string getTypeName(Type *Ty, bool Signed) const;
55
56 std::vector<uint32_t> getWorkGroupDimensions(MDNode *Node) const;
57
58 void emitVersion();
59
60 void emitIsa(const FeatureBitset &Features);
61
62 void emitPrintf(const Module &Mod);
63
64 void emitKernelLanguage(const Function &Func);
65
66 void emitKernelAttrs(const Function &Func);
67
68 void emitKernelArgs(const Function &Func);
69
70 void emitKernelArg(const Argument &Arg);
71
72 void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
73 StringRef TypeQual = "", StringRef BaseTypeName = "",
74 StringRef AccQual = "", StringRef Name = "",
75 StringRef TypeName = "");
Konstantin Zhuravlyovca0e7f62017-03-22 22:54:39 +000076
77 void emitKernelCodeProps(const amd_kernel_code_t &KernelCode);
78
Konstantin Zhuravlyova780ffa2017-03-22 23:10:46 +000079 void emitKernelDebugProps(const amd_kernel_code_t &KernelCode);
80
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000081public:
82 MetadataStreamer() = default;
83 ~MetadataStreamer() = default;
84
85 void begin(const FeatureBitset &Features, const Module &Mod);
86
87 void end() {}
88
Konstantin Zhuravlyovca0e7f62017-03-22 22:54:39 +000089 void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode);
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000090
91 ErrorOr<std::string> toYamlString();
92
93 ErrorOr<std::string> toYamlString(const FeatureBitset &Features,
94 StringRef YamlString);
95};
96
97} // end namespace CodeObject
98} // end namespace AMDGPU
99} // end namespace llvm
100
101#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H