100f41216SHongyu Chen //===-------------------- VTuneSharedStructs.h ------------------*- C++ -*-===// 200f41216SHongyu Chen // 300f41216SHongyu Chen // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 400f41216SHongyu Chen // See https://llvm.org/LICENSE.txt for license information. 500f41216SHongyu Chen // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 600f41216SHongyu Chen // 700f41216SHongyu Chen //===----------------------------------------------------------------------===// 800f41216SHongyu Chen // 900f41216SHongyu Chen // Structs and serialization to share VTune-related information 1000f41216SHongyu Chen // 1100f41216SHongyu Chen //===----------------------------------------------------------------------===// 1200f41216SHongyu Chen 1300f41216SHongyu Chen #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H 1400f41216SHongyu Chen #define LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H 1500f41216SHongyu Chen 16*7459f724SAdrian Prantl #include "ExecutorAddress.h" 17*7459f724SAdrian Prantl #include <utility> 18*7459f724SAdrian Prantl #include <vector> 19*7459f724SAdrian Prantl 2000f41216SHongyu Chen namespace llvm { 2100f41216SHongyu Chen namespace orc { 2200f41216SHongyu Chen 2300f41216SHongyu Chen using VTuneLineTable = std::vector<std::pair<unsigned, unsigned>>; 2400f41216SHongyu Chen 2500f41216SHongyu Chen // SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table. 2600f41216SHongyu Chen // SI == 0 means replace with nullptr. 2700f41216SHongyu Chen 2800f41216SHongyu Chen // MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table. 2900f41216SHongyu Chen // MI == 0 means this is a parent method and was not inlined. 3000f41216SHongyu Chen 3100f41216SHongyu Chen struct VTuneMethodInfo { 3200f41216SHongyu Chen VTuneLineTable LineTable; 3300f41216SHongyu Chen ExecutorAddr LoadAddr; 3400f41216SHongyu Chen uint64_t LoadSize; 3500f41216SHongyu Chen uint64_t MethodID; 3600f41216SHongyu Chen uint32_t NameSI; 3700f41216SHongyu Chen uint32_t ClassFileSI; 3800f41216SHongyu Chen uint32_t SourceFileSI; 3900f41216SHongyu Chen uint32_t ParentMI; 4000f41216SHongyu Chen }; 4100f41216SHongyu Chen 4200f41216SHongyu Chen using VTuneMethodTable = std::vector<VTuneMethodInfo>; 4300f41216SHongyu Chen using VTuneStringTable = std::vector<std::string>; 4400f41216SHongyu Chen 4500f41216SHongyu Chen struct VTuneMethodBatch { 4600f41216SHongyu Chen VTuneMethodTable Methods; 4700f41216SHongyu Chen VTuneStringTable Strings; 4800f41216SHongyu Chen }; 4900f41216SHongyu Chen 5000f41216SHongyu Chen using VTuneUnloadedMethodIDs = SmallVector<std::pair<uint64_t, uint64_t>>; 5100f41216SHongyu Chen 5200f41216SHongyu Chen namespace shared { 5300f41216SHongyu Chen 5400f41216SHongyu Chen using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t, uint32_t>>; 5500f41216SHongyu Chen using SPSVTuneMethodInfo = 5600f41216SHongyu Chen SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t, uint64_t, uint32_t, 5700f41216SHongyu Chen uint32_t, uint32_t, uint32_t>; 5800f41216SHongyu Chen using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>; 5900f41216SHongyu Chen using SPSVTuneStringTable = SPSSequence<SPSString>; 6000f41216SHongyu Chen using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>; 6100f41216SHongyu Chen using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t, uint64_t>>; 6200f41216SHongyu Chen 6300f41216SHongyu Chen template <> class SPSSerializationTraits<SPSVTuneMethodInfo, VTuneMethodInfo> { 6400f41216SHongyu Chen public: size(const VTuneMethodInfo & MI)6500f41216SHongyu Chen static size_t size(const VTuneMethodInfo &MI) { 6600f41216SHongyu Chen return SPSVTuneMethodInfo::AsArgList::size( 6700f41216SHongyu Chen MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI, 6800f41216SHongyu Chen MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI); 6900f41216SHongyu Chen } 7000f41216SHongyu Chen deserialize(SPSInputBuffer & IB,VTuneMethodInfo & MI)7100f41216SHongyu Chen static bool deserialize(SPSInputBuffer &IB, VTuneMethodInfo &MI) { 7200f41216SHongyu Chen return SPSVTuneMethodInfo::AsArgList::deserialize( 7300f41216SHongyu Chen IB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI, 7400f41216SHongyu Chen MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI); 7500f41216SHongyu Chen } 7600f41216SHongyu Chen serialize(SPSOutputBuffer & OB,const VTuneMethodInfo & MI)7700f41216SHongyu Chen static bool serialize(SPSOutputBuffer &OB, const VTuneMethodInfo &MI) { 7800f41216SHongyu Chen return SPSVTuneMethodInfo::AsArgList::serialize( 7900f41216SHongyu Chen OB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI, 8000f41216SHongyu Chen MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI); 8100f41216SHongyu Chen } 8200f41216SHongyu Chen }; 8300f41216SHongyu Chen 8400f41216SHongyu Chen template <> 8500f41216SHongyu Chen class SPSSerializationTraits<SPSVTuneMethodBatch, VTuneMethodBatch> { 8600f41216SHongyu Chen public: size(const VTuneMethodBatch & MB)8700f41216SHongyu Chen static size_t size(const VTuneMethodBatch &MB) { 8800f41216SHongyu Chen return SPSVTuneMethodBatch::AsArgList::size(MB.Methods, MB.Strings); 8900f41216SHongyu Chen } 9000f41216SHongyu Chen deserialize(SPSInputBuffer & IB,VTuneMethodBatch & MB)9100f41216SHongyu Chen static bool deserialize(SPSInputBuffer &IB, VTuneMethodBatch &MB) { 9200f41216SHongyu Chen return SPSVTuneMethodBatch::AsArgList::deserialize(IB, MB.Methods, 9300f41216SHongyu Chen MB.Strings); 9400f41216SHongyu Chen } 9500f41216SHongyu Chen serialize(SPSOutputBuffer & OB,const VTuneMethodBatch & MB)9600f41216SHongyu Chen static bool serialize(SPSOutputBuffer &OB, const VTuneMethodBatch &MB) { 9700f41216SHongyu Chen return SPSVTuneMethodBatch::AsArgList::serialize(OB, MB.Methods, 9800f41216SHongyu Chen MB.Strings); 9900f41216SHongyu Chen } 10000f41216SHongyu Chen }; 10100f41216SHongyu Chen 10200f41216SHongyu Chen } // end namespace shared 10300f41216SHongyu Chen } // end namespace orc 10400f41216SHongyu Chen } // end namespace llvm 10500f41216SHongyu Chen 10600f41216SHongyu Chen #endif 107