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