LLVM 22.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"
23
24#include <cstddef>
25#include <optional>
26
27namespace llvm {
28
29namespace msgpack {
30 class DocNode;
31 class MapDocNode;
32}
33
34namespace AMDGPU {
35namespace HSAMD {
36namespace V3 {
37
38/// Verifier for AMDGPU HSA metadata.
39///
40/// Operates in two modes:
41///
42/// In strict mode, metadata must already be well-typed.
43///
44/// In non-strict mode, metadata is coerced into expected types when possible.
46 bool Strict;
47
48 bool verifyScalar(msgpack::DocNode &Node, msgpack::Type SKind,
49 function_ref<bool(msgpack::DocNode &)> verifyValue = {});
50 bool verifyInteger(msgpack::DocNode &Node);
51 bool verifyArray(msgpack::DocNode &Node,
52 function_ref<bool(msgpack::DocNode &)> verifyNode,
53 std::optional<size_t> Size = std::nullopt);
54 bool verifyEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
55 function_ref<bool(msgpack::DocNode &)> verifyNode);
56 bool
57 verifyScalarEntry(msgpack::MapDocNode &MapNode, StringRef Key, bool Required,
58 msgpack::Type SKind,
59 function_ref<bool(msgpack::DocNode &)> verifyValue = {});
60 bool verifyIntegerEntry(msgpack::MapDocNode &MapNode, StringRef Key,
61 bool Required);
62 bool verifyKernelArgs(msgpack::DocNode &Node);
63 bool verifyKernel(msgpack::DocNode &Node);
64
65public:
66 /// Construct a MetadataVerifier, specifying whether it will operate in \p
67 /// Strict mode.
68 MetadataVerifier(bool Strict) : Strict(Strict) {}
69
70 /// Verify given HSA metadata.
71 ///
72 /// \returns True when successful, false when metadata is invalid.
73 LLVM_ABI bool verify(msgpack::DocNode &HSAMetadataRoot);
74};
75
76} // end namespace V3
77} // end namespace HSAMD
78} // end namespace AMDGPU
79} // end namespace llvm
80
81#endif // LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
#define LLVM_ABI
Definition Compiler.h:213
This is a MessagePack reader.
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:55
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...
This is an optimization pass for GlobalISel generic memory operations.