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