LLVM  14.0.0git
AMDGPUMetadataVerifier.h
Go to the documentation of this file.
1 //===- AMDGPUMetadataVerifier.h - MsgPack Types -----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// This is a verifier for AMDGPU HSA metadata, which can verify both
11 /// well-typed metadata and untyped metadata. When verifying in the non-strict
12 /// mode, untyped metadata is coerced into the correct type if possible.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
17 #define LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
18 
20 
21 namespace llvm {
22 namespace AMDGPU {
23 namespace HSAMD {
24 namespace V3 {
25 
26 /// Verifier for AMDGPU HSA metadata.
27 ///
28 /// Operates in two modes:
29 ///
30 /// In strict mode, metadata must already be well-typed.
31 ///
32 /// In non-strict mode, metadata is coerced into expected types when possible.
34  bool Strict;
35 
36  bool verifyScalar(msgpack::DocNode &Node, msgpack::Type SKind,
37  function_ref<bool(msgpack::DocNode &)> verifyValue = {});
38  bool verifyInteger(msgpack::DocNode &Node);
39  bool verifyArray(msgpack::DocNode &Node,
40  function_ref<bool(msgpack::DocNode &)> verifyNode,
42  bool verifyEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
43  function_ref<bool(msgpack::DocNode &)> verifyNode);
44  bool
45  verifyScalarEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
46  msgpack::Type SKind,
47  function_ref<bool(msgpack::DocNode &)> verifyValue = {});
48  bool verifyIntegerEntry(msgpack::MapDocNode &MapNode, StringRef Key,
49  bool Required);
50  bool verifyKernelArgs(msgpack::DocNode &Node);
51  bool verifyKernel(msgpack::DocNode &Node);
52 
53 public:
54  /// Construct a MetadataVerifier, specifying whether it will operate in \p
55  /// Strict mode.
56  MetadataVerifier(bool Strict) : Strict(Strict) {}
57 
58  /// Verify given HSA metadata.
59  ///
60  /// \returns True when successful, false when metadata is invalid.
61  bool verify(msgpack::DocNode &HSAMetadataRoot);
62 };
63 
64 } // end namespace V3
65 } // end namespace HSAMD
66 } // end namespace AMDGPU
67 } // end namespace llvm
68 
69 #endif // LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::Optional< size_t >
llvm::msgpack::DocNode
A node in a MsgPack Document.
Definition: MsgPackDocument.h:38
llvm::cl::Required
@ Required
Definition: CommandLine.h:121
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
llvm::None
const NoneType None
Definition: None.h:23
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::msgpack::MapDocNode
A DocNode that is a map.
Definition: MsgPackDocument.h:219
llvm::AMDGPU::HSAMD::V3::MetadataVerifier
Verifier for AMDGPU HSA metadata.
Definition: AMDGPUMetadataVerifier.h:33
MsgPackDocument.h
llvm::AMDGPU::HSAMD::V3::MetadataVerifier::MetadataVerifier
MetadataVerifier(bool Strict)
Construct a MetadataVerifier, specifying whether it will operate in Strict mode.
Definition: AMDGPUMetadataVerifier.h:56
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
Node
Definition: ItaniumDemangle.h:235
llvm::AMDGPU::HSAMD::V3::MetadataVerifier::verify
bool verify(msgpack::DocNode &HSAMetadataRoot)
Verify given HSA metadata.
Definition: AMDGPUMetadataVerifier.cpp:266
llvm::msgpack::Type
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49