]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUHSAMetadataStreamer.h
MFV r328229:
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / MCTargetDesc / AMDGPUHSAMetadataStreamer.h
1 //===--- AMDGPUHSAMetadataStreamer.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 HSA Metadata Streamer.
12 ///
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
17 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
18
19 #include "AMDGPU.h"
20 #include "AMDKernelCodeT.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Support/AMDGPUMetadata.h"
23
24 namespace llvm {
25
26 class Argument;
27 class DataLayout;
28 class Function;
29 class MDNode;
30 class Module;
31 class Type;
32
33 namespace AMDGPU {
34 namespace HSAMD {
35
36 class MetadataStreamer final {
37 private:
38   Metadata HSAMetadata;
39   AMDGPUAS AMDGPUASI;
40
41   void dump(StringRef HSAMetadataString) const;
42
43   void verify(StringRef HSAMetadataString) 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 emitPrintf(const Module &Mod);
61
62   void emitKernelLanguage(const Function &Func);
63
64   void emitKernelAttrs(const Function &Func);
65
66   void emitKernelArgs(const Function &Func);
67
68   void emitKernelArg(const Argument &Arg);
69
70   void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
71                      StringRef Name = "", StringRef TypeName = "",
72                      StringRef BaseTypeName = "", StringRef AccQual = "",
73                      StringRef TypeQual = "");
74
75 public:
76   MetadataStreamer() = default;
77   ~MetadataStreamer() = default;
78
79   const Metadata &getHSAMetadata() const {
80     return HSAMetadata;
81   }
82
83   void begin(const Module &Mod);
84
85   void end();
86
87   void emitKernel(const Function &Func,
88                   const Kernel::CodeProps::Metadata &CodeProps,
89                   const Kernel::DebugProps::Metadata &DebugProps);
90 };
91
92 } // end namespace HSAMD
93 } // end namespace AMDGPU
94 } // end namespace llvm
95
96 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H