1
+ // ===-------------------- VTuneSharedStructs.h ------------------*- 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
+ // Structs and serialization to share VTune-related information
10
+ //
11
+ // ===----------------------------------------------------------------------===//
12
+
13
+ #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
14
+ #define LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
15
+
16
+ namespace llvm {
17
+ namespace orc {
18
+
19
+ typedef std::vector<std::pair<unsigned , unsigned >> VTuneLineTable;
20
+
21
+ // SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table.
22
+ // SI == 0 means replace with nullptr.
23
+
24
+ // MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table.
25
+ // MI == 0 means this is a parent method and was not inlined.
26
+
27
+ struct VTuneMethodInfo {
28
+ VTuneLineTable LineTable;
29
+ ExecutorAddr LoadAddr;
30
+ uint64_t LoadSize;
31
+ uint64_t MethodID;
32
+ uint32_t NameSI;
33
+ uint32_t ClassFileSI;
34
+ uint32_t SourceFileSI;
35
+ uint32_t ParentMI;
36
+ };
37
+
38
+ typedef std::vector<VTuneMethodInfo> VTuneMethodTable;
39
+ typedef std::vector<std::string> VTuneStringTable;
40
+
41
+ struct VTuneMethodBatch {
42
+ VTuneMethodTable Methods;
43
+ VTuneStringTable Strings;
44
+ };
45
+
46
+ typedef std::vector<std::pair<uint64_t , uint64_t >> VTuneUnloadedMethodIDs;
47
+
48
+ namespace shared {
49
+
50
+ using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t , uint32_t >>;
51
+ using SPSVTuneMethodInfo =
52
+ SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t , uint64_t , uint32_t ,
53
+ uint32_t , uint32_t , uint32_t >;
54
+ using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>;
55
+ using SPSVTuneStringTable = SPSSequence<SPSString>;
56
+ using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>;
57
+ using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t , uint64_t >>;
58
+
59
+ template <> class SPSSerializationTraits <SPSVTuneMethodInfo, VTuneMethodInfo> {
60
+ public:
61
+ static size_t size (const VTuneMethodInfo &MI) {
62
+ return SPSVTuneMethodInfo::AsArgList::size (
63
+ MI.LineTable , MI.LoadAddr , MI.LoadSize , MI.MethodID , MI.NameSI ,
64
+ MI.ClassFileSI , MI.SourceFileSI , MI.ParentMI );
65
+ }
66
+
67
+ static bool deserialize (SPSInputBuffer &IB, VTuneMethodInfo &MI) {
68
+ return SPSVTuneMethodInfo::AsArgList::deserialize (
69
+ IB, MI.LineTable , MI.LoadAddr , MI.LoadSize , MI.MethodID , MI.NameSI ,
70
+ MI.ClassFileSI , MI.SourceFileSI , MI.ParentMI );
71
+ }
72
+
73
+ static bool serialize (SPSOutputBuffer &OB, const VTuneMethodInfo &MI) {
74
+ return SPSVTuneMethodInfo::AsArgList::serialize (
75
+ OB, MI.LineTable , MI.LoadAddr , MI.LoadSize , MI.MethodID , MI.NameSI ,
76
+ MI.ClassFileSI , MI.SourceFileSI , MI.ParentMI );
77
+ }
78
+ };
79
+
80
+ template <>
81
+ class SPSSerializationTraits <SPSVTuneMethodBatch, VTuneMethodBatch> {
82
+ public:
83
+ static size_t size (const VTuneMethodBatch &MB) {
84
+ return SPSVTuneMethodBatch::AsArgList::size (MB.Methods , MB.Strings );
85
+ }
86
+
87
+ static bool deserialize (SPSInputBuffer &IB, VTuneMethodBatch &MB) {
88
+ return SPSVTuneMethodBatch::AsArgList::deserialize (IB, MB.Methods ,
89
+ MB.Strings );
90
+ }
91
+
92
+ static bool serialize (SPSOutputBuffer &OB, const VTuneMethodBatch &MB) {
93
+ return SPSVTuneMethodBatch::AsArgList::serialize (OB, MB.Methods ,
94
+ MB.Strings );
95
+ }
96
+ };
97
+
98
+ } // end namespace shared
99
+ } // end namespace orc
100
+ } // end namespace llvm
101
+
102
+ #endif
0 commit comments