1 /** 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PGO_HEADER_H 17 #define PGO_HEADER_H 18 19 #include <array> 20 #include <cstdint> 21 22 namespace ark::pgo { 23 24 constexpr uint32_t PGO_HEADER_MAGIC_SIZE = 4; 25 constexpr uint32_t PGO_HEADER_VERSION_SIZE = 4; 26 27 struct PgoHeader { 28 alignas(alignof(uint32_t)) std::array<char, PGO_HEADER_MAGIC_SIZE> magic; 29 alignas(alignof(uint32_t)) std::array<char, PGO_HEADER_VERSION_SIZE> version; 30 uint32_t versionProfileType; 31 uint32_t savedProfileType; 32 uint32_t headerSize; 33 uint32_t withCha; 34 }; 35 36 static_assert((sizeof(PgoHeader) % sizeof(uint32_t)) == 0); 37 static_assert(alignof(PgoHeader) == alignof(uint32_t)); 38 39 struct PandaFilesSectionHeader { 40 uint32_t numberOfFiles; 41 uint32_t sectionSize; 42 }; 43 44 struct PandaFileInfoHeader { 45 uint32_t type; 46 uint32_t fileNameLen; 47 }; 48 49 struct SectionsInfoSectionHeader { 50 uint32_t sectionNumber; 51 uint32_t sectionSize; 52 }; 53 54 struct SectionInfo { 55 uint32_t checkSum; 56 uint32_t zippedSize; 57 uint32_t unzippedSize; 58 uint32_t sectionType; 59 int32_t pandaFileIdx; 60 }; 61 62 struct MethodsHeader { 63 uint32_t numberOfMethods; 64 int32_t pandaFileIdx; 65 }; 66 67 struct MethodDataHeader { 68 uint32_t methodIdx; 69 uint32_t classIdx; 70 uint32_t savedType; 71 uint32_t chunkSize; 72 }; 73 74 struct AotProfileDataHeader { 75 uint32_t profType; 76 uint32_t numberOfRecords; 77 uint32_t chunkSize; 78 }; 79 80 } // namespace ark::pgo 81 82 #endif // PGO_HEADER_H 83