LLVM: lib/XRay/FDRTraceWriter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
13#include
14
15using namespace llvm;
17
18namespace {
19
20template <size_t Index> struct IndexedWriter {
21 template <
22 class Tuple,
23 std::enable_if_t<(Index <
24 std::tuple_size<std::remove_reference_t>::value),
25 int> = 0>
26 static size_t write(support::endian::Writer &OS, Tuple &&T) {
28 return sizeof(std::get(T)) + IndexedWriter<Index + 1>::write(OS, T);
29 }
30
31 template <
32 class Tuple,
33 std::enable_if_t<(Index >=
34 std::tuple_size<std::remove_reference_t>::value),
35 int> = 0>
36 static size_t write(support::endian::Writer &OS, Tuple &&) {
37 return 0;
38 }
39};
40}
41
42template <uint8_t Kind, class... Values>
44
45
47 auto T = std::make_tuple(std::forward(std::move(Ds))...);
48
49 OS.write(FirstByte);
50 auto Bytes = IndexedWriter<0>::write(OS, T);
51 assert(Bytes <= 15 && "Must only ever write at most 16 byte metadata!");
52
53 for (; Bytes < 15; ++Bytes)
56}
57
60
61
63 (H.ConstantTSC ? 0x01 : 0x0) | (H.NonstopTSC ? 0x02 : 0x0);
64
65
66
67 OS.write(H.Version);
68 OS.write(H.Type);
69 OS.write(BitField);
70 OS.write(H.CycleFrequency);
73 OS.write(FreeFormBytes);
74}
75
77
81
85
89
93
96 return E;
97 auto D = R.data();
99 OS.write(Bytes);
101}
102
105 return E;
106 auto D = R.data();
108 OS.write(Bytes);
110}
111
113 if (auto E = writeMetadata<8u>(OS, R.size(), R.delta(), R.eventType()))
114 return E;
115 auto D = R.data();
117 OS.write(Bytes);
119}
120
124
128
132
136
138
140 TypeRecordFuncId <<= 3;
141 TypeRecordFuncId |= static_cast<uint32_t>(R.recordType());
142 TypeRecordFuncId <<= 1;
143 TypeRecordFuncId &= ~uint32_t{0x01};
144 OS.write(TypeRecordFuncId);
145 OS.write(R.delta());
147}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static Error writeMetadata(support::endian::Writer &OS, Values &&...Ds)
Definition FDRTraceWriter.cpp:43
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
This class implements an extremely fast bulk output stream that can only output to a stream.
FDRTraceWriter(raw_ostream &O, const XRayFileHeader &H)
Definition FDRTraceWriter.cpp:58
~FDRTraceWriter() override
Error visit(BufferExtents &) override
Definition FDRTraceWriter.cpp:78
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue, Dwarf64StrOffsetsPromotion StrOffsetsOptValue)
Adapter to write values to a stream in a particular byte order.
void write(ArrayRef< value_type > Val)