| 1 | //===----------------------------------------------------------------------===// |
| 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 | /// \file |
| 10 | /// This file defines the YAMLIO mappings for the format-agnostic BB address |
| 11 | /// map YAML types declared in BBAddrMapYAML.h. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/ObjectYAML/BBAddrMapYAML.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | namespace yaml { |
| 19 | |
| 20 | void MappingTraits<BBAddrMapYAML::BBAddrMapEntry>::mapping( |
| 21 | IO &IO, BBAddrMapYAML::BBAddrMapEntry &E) { |
| 22 | assert(IO.getContext() && "The IO context is not initialized" ); |
| 23 | IO.mapRequired(Key: "Version" , Val&: E.Version); |
| 24 | IO.mapOptional(Key: "Feature" , Val&: E.Feature, Default: Hex16(0)); |
| 25 | IO.mapOptional(Key: "NumBBRanges" , Val&: E.NumBBRanges); |
| 26 | IO.mapOptional(Key: "BBRanges" , Val&: E.BBRanges); |
| 27 | } |
| 28 | |
| 29 | void MappingTraits<BBAddrMapYAML::BBAddrMapEntry::BBRangeEntry>::mapping( |
| 30 | IO &IO, BBAddrMapYAML::BBAddrMapEntry::BBRangeEntry &E) { |
| 31 | IO.mapOptional(Key: "BaseAddress" , Val&: E.BaseAddress, Default: Hex64(0)); |
| 32 | IO.mapOptional(Key: "NumBlocks" , Val&: E.NumBlocks); |
| 33 | IO.mapOptional(Key: "BBEntries" , Val&: E.BBEntries); |
| 34 | } |
| 35 | |
| 36 | void MappingTraits<BBAddrMapYAML::BBAddrMapEntry::BBEntry>::mapping( |
| 37 | IO &IO, BBAddrMapYAML::BBAddrMapEntry::BBEntry &E) { |
| 38 | assert(IO.getContext() && "The IO context is not initialized" ); |
| 39 | IO.mapOptional(Key: "ID" , Val&: E.ID); |
| 40 | IO.mapRequired(Key: "AddressOffset" , Val&: E.AddressOffset); |
| 41 | IO.mapRequired(Key: "Size" , Val&: E.Size); |
| 42 | IO.mapRequired(Key: "Metadata" , Val&: E.Metadata); |
| 43 | IO.mapOptional(Key: "CallsiteEndOffsets" , Val&: E.CallsiteEndOffsets); |
| 44 | IO.mapOptional(Key: "Hash" , Val&: E.Hash); |
| 45 | } |
| 46 | |
| 47 | void MappingTraits<BBAddrMapYAML::PGOAnalysisMapEntry>::mapping( |
| 48 | IO &IO, BBAddrMapYAML::PGOAnalysisMapEntry &E) { |
| 49 | assert(IO.getContext() && "The IO context is not initialized" ); |
| 50 | IO.mapOptional(Key: "FuncEntryCount" , Val&: E.FuncEntryCount); |
| 51 | IO.mapOptional(Key: "PGOBBEntries" , Val&: E.PGOBBEntries); |
| 52 | } |
| 53 | |
| 54 | void MappingTraits<BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry>::mapping( |
| 55 | IO &IO, BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry &E) { |
| 56 | assert(IO.getContext() && "The IO context is not initialized" ); |
| 57 | IO.mapOptional(Key: "BBFreq" , Val&: E.BBFreq); |
| 58 | IO.mapOptional(Key: "PostLinkBBFreq" , Val&: E.PostLinkBBFreq); |
| 59 | IO.mapOptional(Key: "Successors" , Val&: E.Successors); |
| 60 | } |
| 61 | |
| 62 | void MappingTraits< |
| 63 | BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry>:: |
| 64 | mapping(IO &IO, |
| 65 | BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry &E) { |
| 66 | assert(IO.getContext() && "The IO context is not initialized" ); |
| 67 | IO.mapRequired(Key: "ID" , Val&: E.ID); |
| 68 | IO.mapRequired(Key: "BrProb" , Val&: E.BrProb); |
| 69 | IO.mapOptional(Key: "PostLinkBrFreq" , Val&: E.PostLinkBrFreq); |
| 70 | } |
| 71 | |
| 72 | } // end namespace yaml |
| 73 | } // end namespace llvm |
| 74 | |