LLVM  8.0.1
AMDGPUMetadataVerifier.h
Go to the documentation of this file.
1 //===- AMDGPUMetadataVerifier.h - MsgPack Types -----------------*- 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 /// This is a verifier for AMDGPU HSA metadata, which can verify both
12 /// well-typed metadata and untyped metadata. When verifying in the non-strict
13 /// mode, untyped metadata is coerced into the correct type if possible.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
18 #define LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
19 
21 
22 namespace llvm {
23 namespace AMDGPU {
24 namespace HSAMD {
25 namespace V3 {
26 
27 /// Verifier for AMDGPU HSA metadata.
28 ///
29 /// Operates in two modes:
30 ///
31 /// In strict mode, metadata must already be well-typed.
32 ///
33 /// In non-strict mode, metadata is coerced into expected types when possible.
35  bool Strict;
36 
37  bool verifyScalar(msgpack::Node &Node, msgpack::ScalarNode::ScalarKind SKind,
38  function_ref<bool(msgpack::ScalarNode &)> verifyValue = {});
39  bool verifyInteger(msgpack::Node &Node);
40  bool verifyArray(msgpack::Node &Node,
41  function_ref<bool(msgpack::Node &)> verifyNode,
43  bool verifyEntry(msgpack::MapNode &MapNode, StringRef Key, bool Required,
44  function_ref<bool(msgpack::Node &)> verifyNode);
45  bool
46  verifyScalarEntry(msgpack::MapNode &MapNode, StringRef Key, bool Required,
48  function_ref<bool(msgpack::ScalarNode &)> verifyValue = {});
49  bool verifyIntegerEntry(msgpack::MapNode &MapNode, StringRef Key,
50  bool Required);
51  bool verifyKernelArgs(msgpack::Node &Node);
52  bool verifyKernel(msgpack::Node &Node);
53 
54 public:
55  /// Construct a MetadataVerifier, specifying whether it will operate in \p
56  /// Strict mode.
57  MetadataVerifier(bool Strict) : Strict(Strict) {}
58 
59  /// Verify given HSA metadata.
60  ///
61  /// \returns True when successful, false when metadata is invalid.
62  bool verify(msgpack::Node &HSAMetadataRoot);
63 };
64 
65 } // end namespace V3
66 } // end namespace HSAMD
67 } // end namespace AMDGPU
68 } // end namespace llvm
69 
70 #endif // LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
const NoneType None
Definition: None.h:24
This class represents lattice values for constants.
Definition: AllocatorList.h:24
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:117
Verifier for AMDGPU HSA metadata.
Key
PAL metadata keys.
This is a data structure for representing MessagePack "documents", with methods to go to and from Mes...
bool verify(msgpack::Node &HSAMetadataRoot)
Verify given HSA metadata.
Abstract base-class which can be any MessagePack type.
Definition: MsgPackTypes.h:39
uint32_t Size
Definition: Profile.cpp:47
A MessagePack scalar.
Definition: MsgPackTypes.h:72
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
MetadataVerifier(bool Strict)
Construct a MetadataVerifier, specifying whether it will operate in Strict mode.