LLVM  8.0.0svn
AMDGPUHSAMetadataStreamer.h
Go to the documentation of this file.
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 /// 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"
23 
24 namespace llvm {
25 
26 class Argument;
27 class DataLayout;
28 class Function;
29 class MDNode;
30 class Module;
31 struct SIProgramInfo;
32 class Type;
33 
34 namespace AMDGPU {
35 namespace HSAMD {
36 
37 class MetadataStreamer final {
38 private:
39  Metadata HSAMetadata;
40  AMDGPUAS AMDGPUASI;
41 
42  void dump(StringRef HSAMetadataString) const;
43 
44  void verify(StringRef HSAMetadataString) 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  Kernel::CodeProps::Metadata getHSACodeProps(
60  const MachineFunction &MF,
61  const SIProgramInfo &ProgramInfo) const;
62  Kernel::DebugProps::Metadata getHSADebugProps(
63  const MachineFunction &MF,
64  const SIProgramInfo &ProgramInfo) const;
65 
66  void emitVersion();
67 
68  void emitPrintf(const Module &Mod);
69 
70  void emitKernelLanguage(const Function &Func);
71 
72  void emitKernelAttrs(const Function &Func);
73 
74  void emitKernelArgs(const Function &Func);
75 
76  void emitKernelArg(const Argument &Arg);
77 
78  void emitKernelArg(const DataLayout &DL, Type *Ty, ValueKind ValueKind,
79  unsigned PointeeAlign = 0,
80  StringRef Name = "", StringRef TypeName = "",
81  StringRef BaseTypeName = "", StringRef AccQual = "",
82  StringRef TypeQual = "");
83 
84  void emitHiddenKernelArgs(const Function &Func);
85 
86 public:
87  MetadataStreamer() = default;
88  ~MetadataStreamer() = default;
89 
90  const Metadata &getHSAMetadata() const {
91  return HSAMetadata;
92  }
93 
94  void begin(const Module &Mod);
95 
96  void end();
97 
98  void emitKernel(const MachineFunction &MF, const SIProgramInfo &ProgramInfo);
99 };
100 
101 } // end namespace HSAMD
102 } // end namespace AMDGPU
103 } // end namespace llvm
104 
105 #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUHSAMETADATASTREAMER_H
In-memory representation of HSA metadata.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This class represents an incoming formal argument to a Function.
Definition: Argument.h:30
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
void emitKernel(const MachineFunction &MF, const SIProgramInfo &ProgramInfo)
constexpr char PointeeAlign[]
Key for Kernel::Arg::Metadata::mPointeeAlign.
Metadata node.
Definition: Metadata.h:862
Track resource usage for kernels / entry functions.
Definition: SIProgramInfo.h:22
In-memory representation of kernel debug properties metadata.
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
Definition: AMDGPU.h:224
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
ValueKind
Value kinds.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
AccessQualifier
Access qualifiers.
AddressSpace
Definition: NVPTXBaseInfo.h:22
ValueType
Value types.
The access may modify the value stored in memory.
amdgpu Simplify well known AMD library false Value Value * Arg
AddressSpaceQualifier
Address space qualifiers.
constexpr char AccQual[]
Key for Kernel::Arg::Metadata::mAccQual.
In-memory representation of kernel code properties metadata.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
AMDGPU metadata definitions and in-memory representations.