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
17
18namespace llvm::xray {
19
27
40
43 std::vector<YAMLXRayRecord> Records;
44};
45
46} // namespace llvm::xray
47
48namespace llvm {
49// YAML Traits
50// -----------
51template <> struct yaml::ScalarEnumerationTraits<xray::RecordTypes> {
53 IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
54 IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
55 IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
56 IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
59 }
60};
61
62template <> struct yaml::MappingTraits<xray::YAMLXRayFileHeader> {
63 static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
64 IO.mapRequired("version", Header.Version);
65 IO.mapRequired("type", Header.Type);
66 IO.mapRequired("constant-tsc", Header.ConstantTSC);
67 IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
68 IO.mapRequired("cycle-frequency", Header.CycleFrequency);
69 }
70};
71
72template <> struct yaml::MappingTraits<xray::YAMLXRayRecord> {
74 IO.mapRequired("type", Record.RecordType);
75 IO.mapOptional("func-id", Record.FuncId);
76 IO.mapOptional("function", Record.Function);
77 IO.mapOptional("args", Record.CallArgs);
78 IO.mapRequired("cpu", Record.CPU);
79 IO.mapOptional("thread", Record.TId, 0U);
80 IO.mapOptional("process", Record.PId, 0U);
81 IO.mapRequired("kind", Record.Type);
82 IO.mapRequired("tsc", Record.TSC);
83 IO.mapOptional("data", Record.Data);
84 }
85
86 static constexpr bool flow = true;
87};
88
91 // A trace file contains two parts, the header and the list of all the
92 // trace records.
93 IO.mapRequired("header", Trace.Header);
94 IO.mapRequired("records", Trace.Records);
95 }
96};
97} // namespace llvm
98
99LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
100
101#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