Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- StableFunctionMapRecord.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 // This defines the StableFunctionMapRecord structure, which provides
0010 // functionality for managing and serializing a StableFunctionMap. It includes
0011 // methods for serialization to and from raw and YAML streams, as well as
0012 // utilities for merging and finalizing function maps.
0013 //
0014 //===---------------------------------------------------------------------===//
0015 
0016 #ifndef LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
0017 #define LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
0018 
0019 #include "llvm/CGData/StableFunctionMap.h"
0020 #include "llvm/ObjectYAML/YAML.h"
0021 #include "llvm/Support/raw_ostream.h"
0022 
0023 namespace llvm {
0024 
0025 struct StableFunctionMapRecord {
0026   std::unique_ptr<StableFunctionMap> FunctionMap;
0027 
0028   StableFunctionMapRecord() {
0029     FunctionMap = std::make_unique<StableFunctionMap>();
0030   }
0031 
0032   StableFunctionMapRecord(std::unique_ptr<StableFunctionMap> FunctionMap)
0033       : FunctionMap(std::move(FunctionMap)) {}
0034 
0035   /// A static helper function to serialize the stable function map without
0036   /// owning the stable function map.
0037   static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap);
0038 
0039   /// Serialize the stable function map to a raw_ostream.
0040   void serialize(raw_ostream &OS) const;
0041 
0042   /// Deserialize the stable function map from a raw_ostream.
0043   void deserialize(const unsigned char *&Ptr);
0044 
0045   /// Serialize the stable function map to a YAML stream.
0046   void serializeYAML(yaml::Output &YOS) const;
0047 
0048   /// Deserialize the stable function map from a YAML stream.
0049   void deserializeYAML(yaml::Input &YIS);
0050 
0051   /// Finalize the stable function map by trimming content.
0052   void finalize(bool SkipTrim = false) { FunctionMap->finalize(SkipTrim); }
0053 
0054   /// Merge the stable function map into this one.
0055   void merge(const StableFunctionMapRecord &Other) {
0056     FunctionMap->merge(*Other.FunctionMap);
0057   }
0058 
0059   /// \returns true if the stable function map is empty.
0060   bool empty() const { return FunctionMap->empty(); }
0061 
0062   /// Print the stable function map in a YAML format.
0063   void print(raw_ostream &OS = llvm::errs()) const {
0064     yaml::Output YOS(OS);
0065     serializeYAML(YOS);
0066   }
0067 };
0068 
0069 } // namespace llvm
0070 
0071 #endif