LLVM 20.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#include "llvm/ADT/StringRef.h"
22
23#include <cstddef>
24#include <optional>
25
26namespace llvm {
27
28namespace msgpack {
29 class DocNode;
30 class MapDocNode;
31}
32
33namespace AMDGPU {
34namespace HSAMD {
35namespace V3 {
36
37/// Verifier for AMDGPU HSA metadata.
38///
39/// Operates in two modes:
40///
41/// In strict mode, metadata must already be well-typed.
42///
43/// In non-strict mode, metadata is coerced into expected types when possible.
45 bool Strict;
46
47 bool verifyScalar(msgpack::DocNode &Node, msgpack::Type SKind,
48 function_ref<bool(msgpack::DocNode &)> verifyValue = {});
49 bool verifyInteger(msgpack::DocNode &Node);
50 bool verifyArray(msgpack::DocNode &Node,
51 function_ref<bool(msgpack::DocNode &)> verifyNode,
52 std::optional<size_t> Size = std::nullopt);
53 bool verifyEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
54 function_ref<bool(msgpack::DocNode &)> verifyNode);
55 bool
56 verifyScalarEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
57 msgpack::Type SKind,
58 function_ref<bool(msgpack::DocNode &)> verifyValue = {});
59 bool verifyIntegerEntry(msgpack::MapDocNode &MapNode, StringRef Key,
60 bool Required);
61 bool verifyKernelArgs(msgpack::DocNode &Node);
62 bool verifyKernel(msgpack::DocNode &Node);
63
64public:
65 /// Construct a MetadataVerifier, specifying whether it will operate in \p
66 /// Strict mode.
67 MetadataVerifier(bool Strict) : Strict(Strict) {}
68
69 /// Verify given HSA metadata.
70 ///
71 /// \returns True when successful, false when metadata is invalid.
72 bool verify(msgpack::DocNode &HSAMetadataRoot);
73};
74
75} // end namespace V3
76} // end namespace HSAMD
77} // end namespace AMDGPU
78} // end namespace llvm
79
80#endif // LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
uint64_t Size
ppc ctr loops verify
MetadataVerifier(bool Strict)
Construct a MetadataVerifier, specifying whether it will operate in Strict mode.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
An efficient, type-erasing, non-owning reference to a callable.
A node in a MsgPack Document.
A DocNode that is a map.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18