blob: 3c1e51e92714dd977521bfaf91e61e0a5eea6f3e [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"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/ErrorOr.h"
22
23namespace llvm {
24
25class Argument;
26class DataLayout;
27class FeatureBitset;
28class Function;
29class MDNode;
30class Module;
31class Type;
32
33namespace AMDGPU {
34namespace CodeObject {
35
36class MetadataStreamer final {
37private:
38 Metadata CodeObjectMetadata;
39
40 void dump(StringRef YamlString) const;
41
42 void verify(StringRef YamlString) const;
43
44 AccessQualifier getAccessQualifier(StringRef AccQual) const;
45
46 AddressSpaceQualifier getAddressSpaceQualifer(unsigned AddressSpace) const;
47
48 ValueKind getValueKind(Type *Ty, StringRef TypeQual,
49 StringRef BaseTypeName) const;
50
51 ValueType getValueType(Type *Ty, StringRef TypeName) const;
52
53 std::string getTypeName(Type *Ty, bool Signed) const;
54
55 std::vector<uint32_t> getWorkGroupDimensions(MDNode *Node) const;
56
57 void emitVersion();
58
59 void emitIsa(const FeatureBitset &Features);
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 = "");
75public:
76 MetadataStreamer() = default;
77 ~MetadataStreamer() = default;
78
79 void begin(const FeatureBitset &Features, const Module &Mod);
80
81 void end() {}
82
83 void emitKernel(const Function &Func);
84
85 ErrorOr<std::string> toYamlString();
86
87 ErrorOr<std::string> toYamlString(const FeatureBitset &Features,
88 StringRef YamlString);
89};
90
91} // end namespace CodeObject
92} // end namespace AMDGPU
93} // end namespace llvm
94
95#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H