LLVM 22.0.0git
YAMLXRayRecord.h
Go to the documentation of this file.
1//===- YAMLXRayRecord.h - XRay Record YAML Support Definitions ------------===//
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// Types and traits specialisations for YAML I/O of XRay log entries.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_XRAY_YAMLXRAYRECORD_H
13#define LLVM_XRAY_YAMLXRAYRECORD_H
14
15#include <type_traits>
16
19
20namespace llvm::xray {
21
29
42
45 std::vector<YAMLXRayRecord> Records;
46};
47
48} // namespace llvm::xray
49
50namespace llvm {
51// YAML Traits
52// -----------
53template <> struct yaml::ScalarEnumerationTraits<xray::RecordTypes> {
55 IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
56 IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
57 IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
58 IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
61 }
62};
63
64template <> struct yaml::MappingTraits<xray::YAMLXRayFileHeader> {
65 static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
66 IO.mapRequired("version", Header.Version);
67 IO.mapRequired("type", Header.Type);
68 IO.mapRequired("constant-tsc", Header.ConstantTSC);
69 IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
70 IO.mapRequired("cycle-frequency", Header.CycleFrequency);
71 }
72};
73
74template <> struct yaml::MappingTraits<xray::YAMLXRayRecord> {
76 IO.mapRequired("type", Record.RecordType);
77 IO.mapOptional("func-id", Record.FuncId);
78 IO.mapOptional("function", Record.Function);
79 IO.mapOptional("args", Record.CallArgs);
80 IO.mapRequired("cpu", Record.CPU);
81 IO.mapOptional("thread", Record.TId, 0U);
82 IO.mapOptional("process", Record.PId, 0U);
83 IO.mapRequired("kind", Record.Type);
84 IO.mapRequired("tsc", Record.TSC);
85 IO.mapOptional("data", Record.Data);
86 }
87
88 static constexpr bool flow = true;
89};
90
93 // A trace file contains two parts, the header and the list of all the
94 // trace records.
95 IO.mapRequired("header", Trace.Header);
96 IO.mapRequired("records", Trace.Records);
97 }
98};
99} // namespace llvm
100
101LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
102
103#endif // LLVM_XRAY_YAMLXRAYRECORD_H
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
void enumCase(T &Val, StringRef Str, const T ConstVal)
Definition YAMLTraits.h:734
void mapOptional(StringRef Key, T &Val)
Definition YAMLTraits.h:799
void mapRequired(StringRef Key, T &Val)
Definition YAMLTraits.h:789
RecordTypes
Determines the supported types of records that could be seen in XRay traces.
Definition XRayRecord.h:56
This is an optimization pass for GlobalISel generic memory operations.
std::vector< uint64_t > CallArgs
std::vector< YAMLXRayRecord > Records
YAMLXRayFileHeader Header
static void mapping(IO &IO, xray::YAMLXRayTrace &Trace)
static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header)
static void mapping(IO &IO, xray::YAMLXRayRecord &Record)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:62
static void enumeration(IO &IO, xray::RecordTypes &Type)
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
Definition YAMLTraits.h:107