summaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h
diff options
context:
space:
mode:
authorvitalyisaev <[email protected]>2023-06-29 10:00:50 +0300
committervitalyisaev <[email protected]>2023-06-29 10:00:50 +0300
commit6ffe9e53658409f212834330e13564e4952558f6 (patch)
tree85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h
parent726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff)
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h')
-rw-r--r--contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h b/contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h
new file mode 100644
index 00000000000..a06db483155
--- /dev/null
+++ b/contrib/libs/llvm16/include/llvm/Bitcode/BitcodeAnalyzer.h
@@ -0,0 +1,120 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- llvm/Bitcode/BitcodeAnalyzer.h - Bitcode analyzer --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This header defines interfaces to analyze LLVM bitcode files/streams.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_BITCODE_BITCODEANALYZER_H
+#define LLVM_BITCODE_BITCODEANALYZER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Bitstream/BitstreamReader.h"
+#include "llvm/Support/Error.h"
+#include <map>
+#include <optional>
+#include <vector>
+
+namespace llvm {
+
+class raw_ostream;
+
+/// CurStreamTypeType - A type for CurStreamType
+enum CurStreamTypeType {
+ UnknownBitstream,
+ LLVMIRBitstream,
+ ClangSerializedASTBitstream,
+ ClangSerializedDiagnosticsBitstream,
+ LLVMBitstreamRemarks
+};
+
+struct BCDumpOptions {
+ /// The stream.
+ raw_ostream &OS;
+ /// Print per-code histogram.
+ bool Histogram = false;
+ /// Don't emit numeric info in dump if symbolic info is available.
+ bool Symbolic = false;
+ /// Print binary blobs using hex escapes.
+ bool ShowBinaryBlobs = false;
+ /// Print BLOCKINFO block details.
+ bool DumpBlockinfo = false;
+
+ BCDumpOptions(raw_ostream &OS) : OS(OS) {}
+};
+
+class BitcodeAnalyzer {
+ BitstreamCursor Stream;
+ BitstreamBlockInfo BlockInfo;
+ CurStreamTypeType CurStreamType;
+ std::optional<BitstreamCursor> BlockInfoStream;
+ unsigned NumTopBlocks = 0;
+
+ struct PerRecordStats {
+ unsigned NumInstances;
+ unsigned NumAbbrev;
+ uint64_t TotalBits;
+ PerRecordStats() : NumInstances(0), NumAbbrev(0), TotalBits(0) {}
+ };
+
+ struct PerBlockIDStats {
+ /// NumInstances - This the number of times this block ID has been seen.
+ unsigned NumInstances;
+ /// NumBits - The total size in bits of all of these blocks.
+ uint64_t NumBits;
+ /// NumSubBlocks - The total number of blocks these blocks contain.
+ unsigned NumSubBlocks;
+ /// NumAbbrevs - The total number of abbreviations.
+ unsigned NumAbbrevs;
+ /// NumRecords - The total number of records these blocks contain, and the
+ /// number that are abbreviated.
+ unsigned NumRecords, NumAbbreviatedRecords;
+ /// CodeFreq - Keep track of the number of times we see each code.
+ std::vector<PerRecordStats> CodeFreq;
+ PerBlockIDStats()
+ : NumInstances(0), NumBits(0), NumSubBlocks(0), NumAbbrevs(0),
+ NumRecords(0), NumAbbreviatedRecords(0) {}
+ };
+
+ std::map<unsigned, PerBlockIDStats> BlockIDStats;
+
+public:
+ BitcodeAnalyzer(StringRef Buffer,
+ std::optional<StringRef> BlockInfoBuffer = std::nullopt);
+ /// Analyze the bitcode file.
+ Error analyze(std::optional<BCDumpOptions> O = std::nullopt,
+ std::optional<StringRef> CheckHash = std::nullopt);
+ /// Print stats about the bitcode file.
+ void printStats(BCDumpOptions O,
+ std::optional<StringRef> Filename = std::nullopt);
+
+private:
+ /// Read a block, updating statistics, etc.
+ Error parseBlock(unsigned BlockID, unsigned IndentLevel,
+ std::optional<BCDumpOptions> O = std::nullopt,
+ std::optional<StringRef> CheckHash = std::nullopt);
+
+ Error decodeMetadataStringsBlob(StringRef Indent, ArrayRef<uint64_t> Record,
+ StringRef Blob, raw_ostream &OS);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_BITCODE_BITCODEANALYZER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif