Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:51

0001 //===-------------------- VTuneSharedStructs.h ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Structs and serialization to share VTune-related information
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
0014 #define LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
0015 
0016 #include "ExecutorAddress.h"
0017 #include <utility>
0018 #include <vector>
0019 
0020 namespace llvm {
0021 namespace orc {
0022 
0023 using VTuneLineTable = std::vector<std::pair<unsigned, unsigned>>;
0024 
0025 // SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table.
0026 // SI == 0 means replace with nullptr.
0027 
0028 // MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table.
0029 // MI == 0 means this is a parent method and was not inlined.
0030 
0031 struct VTuneMethodInfo {
0032   VTuneLineTable LineTable;
0033   ExecutorAddr LoadAddr;
0034   uint64_t LoadSize;
0035   uint64_t MethodID;
0036   uint32_t NameSI;
0037   uint32_t ClassFileSI;
0038   uint32_t SourceFileSI;
0039   uint32_t ParentMI;
0040 };
0041 
0042 using VTuneMethodTable = std::vector<VTuneMethodInfo>;
0043 using VTuneStringTable = std::vector<std::string>;
0044 
0045 struct VTuneMethodBatch {
0046   VTuneMethodTable Methods;
0047   VTuneStringTable Strings;
0048 };
0049 
0050 using VTuneUnloadedMethodIDs = SmallVector<std::pair<uint64_t, uint64_t>>;
0051 
0052 namespace shared {
0053 
0054 using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t, uint32_t>>;
0055 using SPSVTuneMethodInfo =
0056     SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t, uint64_t, uint32_t,
0057              uint32_t, uint32_t, uint32_t>;
0058 using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>;
0059 using SPSVTuneStringTable = SPSSequence<SPSString>;
0060 using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>;
0061 using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t, uint64_t>>;
0062 
0063 template <> class SPSSerializationTraits<SPSVTuneMethodInfo, VTuneMethodInfo> {
0064 public:
0065   static size_t size(const VTuneMethodInfo &MI) {
0066     return SPSVTuneMethodInfo::AsArgList::size(
0067         MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
0068         MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
0069   }
0070 
0071   static bool deserialize(SPSInputBuffer &IB, VTuneMethodInfo &MI) {
0072     return SPSVTuneMethodInfo::AsArgList::deserialize(
0073         IB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
0074         MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
0075   }
0076 
0077   static bool serialize(SPSOutputBuffer &OB, const VTuneMethodInfo &MI) {
0078     return SPSVTuneMethodInfo::AsArgList::serialize(
0079         OB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
0080         MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
0081   }
0082 };
0083 
0084 template <>
0085 class SPSSerializationTraits<SPSVTuneMethodBatch, VTuneMethodBatch> {
0086 public:
0087   static size_t size(const VTuneMethodBatch &MB) {
0088     return SPSVTuneMethodBatch::AsArgList::size(MB.Methods, MB.Strings);
0089   }
0090 
0091   static bool deserialize(SPSInputBuffer &IB, VTuneMethodBatch &MB) {
0092     return SPSVTuneMethodBatch::AsArgList::deserialize(IB, MB.Methods,
0093                                                        MB.Strings);
0094   }
0095 
0096   static bool serialize(SPSOutputBuffer &OB, const VTuneMethodBatch &MB) {
0097     return SPSVTuneMethodBatch::AsArgList::serialize(OB, MB.Methods,
0098                                                      MB.Strings);
0099   }
0100 };
0101 
0102 } // end namespace shared
0103 } // end namespace orc
0104 } // end namespace llvm
0105 
0106 #endif