blob: 12d4c5e5dd59b856887a585b30380c386e2dc6fc [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;
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000028class 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
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000059 void emitPrintf(const Module &Mod);
60
61 void emitKernelLanguage(const Function &Func);
62
63 void emitKernelAttrs(const Function &Func);
64
65 void emitKernelArgs(const Function &Func);
66
67 void emitKernelArg(const Argument &Arg);
68
69 void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
70 StringRef TypeQual = "", StringRef BaseTypeName = "",
71 StringRef AccQual = "", StringRef Name = "",
72 StringRef TypeName = "");
Konstantin Zhuravlyovca0e7f62017-03-22 22:54:39 +000073
74 void emitKernelCodeProps(const amd_kernel_code_t &KernelCode);
75
Konstantin Zhuravlyova780ffa2017-03-22 23:10:46 +000076 void emitKernelDebugProps(const amd_kernel_code_t &KernelCode);
77
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000078public:
79 MetadataStreamer() = default;
80 ~MetadataStreamer() = default;
81
Konstantin Zhuravlyov4cbb6892017-03-22 23:27:09 +000082 void begin(const Module &Mod);
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000083
84 void end() {}
85
Konstantin Zhuravlyovca0e7f62017-03-22 22:54:39 +000086 void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode);
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000087
88 ErrorOr<std::string> toYamlString();
89
Konstantin Zhuravlyov4cbb6892017-03-22 23:27:09 +000090 ErrorOr<std::string> toYamlString(StringRef YamlString);
Konstantin Zhuravlyov7498cd62017-03-22 22:32:22 +000091};
92
93} // end namespace CodeObject
94} // end namespace AMDGPU
95} // end namespace llvm
96
97#endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H