Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 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 "AMDGPUCodeObjectMetadata.h" |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 20 | #include "AMDKernelCodeT.h" |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/StringRef.h" |
| 22 | #include "llvm/Support/ErrorOr.h" |
| 23 | |
| 24 | namespace llvm { |
| 25 | |
| 26 | class Argument; |
| 27 | class DataLayout; |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 28 | class Function; |
| 29 | class MDNode; |
| 30 | class Module; |
| 31 | class Type; |
| 32 | |
| 33 | namespace AMDGPU { |
| 34 | namespace CodeObject { |
| 35 | |
| 36 | class MetadataStreamer final { |
| 37 | private: |
| 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 Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 59 | 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 Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 73 | |
| 74 | void emitKernelCodeProps(const amd_kernel_code_t &KernelCode); |
| 75 | |
Konstantin Zhuravlyov | a780ffa | 2017-03-22 23:10:46 +0000 | [diff] [blame] | 76 | void emitKernelDebugProps(const amd_kernel_code_t &KernelCode); |
| 77 | |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 78 | public: |
| 79 | MetadataStreamer() = default; |
| 80 | ~MetadataStreamer() = default; |
| 81 | |
Konstantin Zhuravlyov | 4cbb689 | 2017-03-22 23:27:09 +0000 | [diff] [blame^] | 82 | void begin(const Module &Mod); |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 83 | |
| 84 | void end() {} |
| 85 | |
Konstantin Zhuravlyov | ca0e7f6 | 2017-03-22 22:54:39 +0000 | [diff] [blame] | 86 | void emitKernel(const Function &Func, const amd_kernel_code_t &KernelCode); |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 87 | |
| 88 | ErrorOr<std::string> toYamlString(); |
| 89 | |
Konstantin Zhuravlyov | 4cbb689 | 2017-03-22 23:27:09 +0000 | [diff] [blame^] | 90 | ErrorOr<std::string> toYamlString(StringRef YamlString); |
Konstantin Zhuravlyov | 7498cd6 | 2017-03-22 22:32:22 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // end namespace CodeObject |
| 94 | } // end namespace AMDGPU |
| 95 | } // end namespace llvm |
| 96 | |
| 97 | #endif // LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUCODEOBJECTMETADATASTREAMER_H |