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 {
21namespace xray {
22
30
43
46 std::vector<YAMLXRayRecord> Records;
47};
48
49} // namespace xray
50
51namespace yaml {
52
53// YAML Traits
54// -----------
55template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
57 IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
58 IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
59 IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
60 IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
63 }
64};
65
66template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
67 static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
68 IO.mapRequired("version", Header.Version);
69 IO.mapRequired("type", Header.Type);
70 IO.mapRequired("constant-tsc", Header.ConstantTSC);
71 IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
72 IO.mapRequired("cycle-frequency", Header.CycleFrequency);
73 }
74};
75
76template <> struct MappingTraits<xray::YAMLXRayRecord> {
78 IO.mapRequired("type", Record.RecordType);
79 IO.mapOptional("func-id", Record.FuncId);
80 IO.mapOptional("function", Record.Function);
81 IO.mapOptional("args", Record.CallArgs);
82 IO.mapRequired("cpu", Record.CPU);
83 IO.mapOptional("thread", Record.TId, 0U);
84 IO.mapOptional("process", Record.PId, 0U);
85 IO.mapRequired("kind", Record.Type);
86 IO.mapRequired("tsc", Record.TSC);
87 IO.mapOptional("data", Record.Data);
88 }
89
90 static constexpr bool flow = true;
91};
92
93template <> struct MappingTraits<xray::YAMLXRayTrace> {
95 // A trace file contains two parts, the header and the list of all the
96 // trace records.
97 IO.mapRequired("header", Trace.Header);
98 IO.mapRequired("records", Trace.Records);
99 }
100};
101
102} // namespace yaml
103} // namespace llvm
104
105LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
106
107#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 mapOptional(const char *Key, T &Val)
Definition YAMLTraits.h:810
void mapRequired(const char *Key, T &Val)
Definition YAMLTraits.h:800
void enumCase(T &Val, const char *Str, const T ConstVal)
Definition YAMLTraits.h:745
RecordTypes
Determines the supported types of records that could be seen in XRay traces.
Definition XRayRecord.h:57
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::YAMLXRayFileHeader &Header)
static void mapping(IO &IO, xray::YAMLXRayRecord &Record)
static void mapping(IO &IO, xray::YAMLXRayTrace &Trace)
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