LLVM  5.0.0
AMDGPUCodeObjectMetadataStreamer.h
Go to the documentation of this file.
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"
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  MetadataStreamer() = default;
82  ~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 
91 
93 };
94 
95 } // end namespace CodeObject
96 } // end namespace AMDGPU
97 } // end namespace llvm
98 
99 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
Represents either an error or a value T.
Definition: ErrorOr.h:69
This class represents an incoming formal argument to a Function.
Definition: Argument.h:30
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
DataLayout DL
Metadata node.
Definition: Metadata.h:862
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
Definition: AMDGPU.h:164
AMD Kernel Code Object (amd_kernel_code_t).
const char * Name
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
AMDGPU Code Object Metadata definitions and in-memory representations.
void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode)
AddressSpace
Definition: NVPTXBaseInfo.h:22
constexpr char AccQual[]
Key for Kernel::Arg::Metadata::mAccQual.
In-memory representation of code object metadata.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
Provides ErrorOr<T> smart pointer.
AddressSpaceQualifier
Address space qualifiers.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49