aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/include/llvm/Bitstream
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/include/llvm/Bitstream
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Bitstream')
-rw-r--r--contrib/libs/llvm12/include/llvm/Bitstream/BitCodes.h4
-rw-r--r--contrib/libs/llvm12/include/llvm/Bitstream/BitstreamWriter.h186
2 files changed, 95 insertions, 95 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Bitstream/BitCodes.h b/contrib/libs/llvm12/include/llvm/Bitstream/BitCodes.h
index 5132bc5df0..ba33d3760d 100644
--- a/contrib/libs/llvm12/include/llvm/Bitstream/BitCodes.h
+++ b/contrib/libs/llvm12/include/llvm/Bitstream/BitCodes.h
@@ -25,7 +25,7 @@
#define LLVM_BITSTREAM_BITCODES_H
#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
@@ -145,7 +145,7 @@ public:
}
/// isChar6 - Return true if this character is legal in the Char6 encoding.
- static bool isChar6(char C) { return isAlnum(C) || C == '.' || C == '_'; }
+ static bool isChar6(char C) { return isAlnum(C) || C == '.' || C == '_'; }
static unsigned EncodeChar6(char C) {
if (C >= 'a' && C <= 'z') return C-'a';
if (C >= 'A' && C <= 'Z') return C-'A'+26;
diff --git a/contrib/libs/llvm12/include/llvm/Bitstream/BitstreamWriter.h b/contrib/libs/llvm12/include/llvm/Bitstream/BitstreamWriter.h
index dc4c1ff1ef..1a8d1c22d3 100644
--- a/contrib/libs/llvm12/include/llvm/Bitstream/BitstreamWriter.h
+++ b/contrib/libs/llvm12/include/llvm/Bitstream/BitstreamWriter.h
@@ -27,28 +27,28 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Bitstream/BitCodes.h"
#include "llvm/Support/Endian.h"
-#include "llvm/Support/raw_ostream.h"
-#include <algorithm>
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
#include <vector>
namespace llvm {
class BitstreamWriter {
- /// Out - The buffer that keeps unflushed bytes.
+ /// Out - The buffer that keeps unflushed bytes.
SmallVectorImpl<char> &Out;
- /// FS - The file stream that Out flushes to. If FS is nullptr, it does not
- /// support read or seek, Out cannot be flushed until all data are written.
- raw_fd_stream *FS;
-
- /// FlushThreshold - If FS is valid, this is the threshold (unit B) to flush
- /// FS.
- const uint64_t FlushThreshold;
-
+ /// FS - The file stream that Out flushes to. If FS is nullptr, it does not
+ /// support read or seek, Out cannot be flushed until all data are written.
+ raw_fd_stream *FS;
+
+ /// FlushThreshold - If FS is valid, this is the threshold (unit B) to flush
+ /// FS.
+ const uint64_t FlushThreshold;
+
/// CurBit - Always between 0 and 31 inclusive, specifies the next bit to use.
unsigned CurBit;
- /// CurValue - The current value. Only bits < CurBit are valid.
+ /// CurValue - The current value. Only bits < CurBit are valid.
uint32_t CurValue;
/// CurCodeSize - This is the declared size of code values used for the
@@ -82,49 +82,49 @@ class BitstreamWriter {
void WriteByte(unsigned char Value) {
Out.push_back(Value);
- FlushToFile();
+ FlushToFile();
}
void WriteWord(unsigned Value) {
Value = support::endian::byte_swap<uint32_t, support::little>(Value);
Out.append(reinterpret_cast<const char *>(&Value),
reinterpret_cast<const char *>(&Value + 1));
- FlushToFile();
+ FlushToFile();
}
- uint64_t GetNumOfFlushedBytes() const { return FS ? FS->tell() : 0; }
-
- size_t GetBufferOffset() const { return Out.size() + GetNumOfFlushedBytes(); }
+ uint64_t GetNumOfFlushedBytes() const { return FS ? FS->tell() : 0; }
+ size_t GetBufferOffset() const { return Out.size() + GetNumOfFlushedBytes(); }
+
size_t GetWordIndex() const {
size_t Offset = GetBufferOffset();
assert((Offset & 3) == 0 && "Not 32-bit aligned");
return Offset / 4;
}
- /// If the related file stream supports reading, seeking and writing, flush
- /// the buffer if its size is above a threshold.
- void FlushToFile() {
- if (!FS)
- return;
- if (Out.size() < FlushThreshold)
- return;
- FS->write((char *)&Out.front(), Out.size());
- Out.clear();
- }
-
+ /// If the related file stream supports reading, seeking and writing, flush
+ /// the buffer if its size is above a threshold.
+ void FlushToFile() {
+ if (!FS)
+ return;
+ if (Out.size() < FlushThreshold)
+ return;
+ FS->write((char *)&Out.front(), Out.size());
+ Out.clear();
+ }
+
public:
- /// Create a BitstreamWriter that writes to Buffer \p O.
- ///
- /// \p FS is the file stream that \p O flushes to incrementally. If \p FS is
- /// null, \p O does not flush incrementially, but writes to disk at the end.
- ///
- /// \p FlushThreshold is the threshold (unit M) to flush \p O if \p FS is
- /// valid.
- BitstreamWriter(SmallVectorImpl<char> &O, raw_fd_stream *FS = nullptr,
- uint32_t FlushThreshold = 512)
- : Out(O), FS(FS), FlushThreshold(FlushThreshold << 20), CurBit(0),
- CurValue(0), CurCodeSize(2) {}
+ /// Create a BitstreamWriter that writes to Buffer \p O.
+ ///
+ /// \p FS is the file stream that \p O flushes to incrementally. If \p FS is
+ /// null, \p O does not flush incrementially, but writes to disk at the end.
+ ///
+ /// \p FlushThreshold is the threshold (unit M) to flush \p O if \p FS is
+ /// valid.
+ BitstreamWriter(SmallVectorImpl<char> &O, raw_fd_stream *FS = nullptr,
+ uint32_t FlushThreshold = 512)
+ : Out(O), FS(FS), FlushThreshold(FlushThreshold << 20), CurBit(0),
+ CurValue(0), CurCodeSize(2) {}
~BitstreamWriter() {
assert(CurBit == 0 && "Unflushed data remaining");
@@ -145,60 +145,60 @@ public:
/// with the specified value.
void BackpatchWord(uint64_t BitNo, unsigned NewWord) {
using namespace llvm::support;
- uint64_t ByteNo = BitNo / 8;
- uint64_t StartBit = BitNo & 7;
- uint64_t NumOfFlushedBytes = GetNumOfFlushedBytes();
-
- if (ByteNo >= NumOfFlushedBytes) {
- assert((!endian::readAtBitAlignment<uint32_t, little, unaligned>(
- &Out[ByteNo - NumOfFlushedBytes], StartBit)) &&
- "Expected to be patching over 0-value placeholders");
- endian::writeAtBitAlignment<uint32_t, little, unaligned>(
- &Out[ByteNo - NumOfFlushedBytes], NewWord, StartBit);
- return;
- }
-
- // If the byte offset to backpatch is flushed, use seek to backfill data.
- // First, save the file position to restore later.
- uint64_t CurPos = FS->tell();
-
- // Copy data to update into Bytes from the file FS and the buffer Out.
- char Bytes[9]; // Use one more byte to silence a warning from Visual C++.
- size_t BytesNum = StartBit ? 8 : 4;
- size_t BytesFromDisk = std::min(static_cast<uint64_t>(BytesNum), NumOfFlushedBytes - ByteNo);
- size_t BytesFromBuffer = BytesNum - BytesFromDisk;
-
- // When unaligned, copy existing data into Bytes from the file FS and the
- // buffer Out so that it can be updated before writing. For debug builds
- // read bytes unconditionally in order to check that the existing value is 0
- // as expected.
-#ifdef NDEBUG
- if (StartBit)
-#endif
- {
- FS->seek(ByteNo);
- ssize_t BytesRead = FS->read(Bytes, BytesFromDisk);
- (void)BytesRead; // silence warning
- assert(BytesRead >= 0 && static_cast<size_t>(BytesRead) == BytesFromDisk);
- for (size_t i = 0; i < BytesFromBuffer; ++i)
- Bytes[BytesFromDisk + i] = Out[i];
- assert((!endian::readAtBitAlignment<uint32_t, little, unaligned>(
- Bytes, StartBit)) &&
- "Expected to be patching over 0-value placeholders");
- }
-
- // Update Bytes in terms of bit offset and value.
- endian::writeAtBitAlignment<uint32_t, little, unaligned>(Bytes, NewWord,
- StartBit);
-
- // Copy updated data back to the file FS and the buffer Out.
- FS->seek(ByteNo);
- FS->write(Bytes, BytesFromDisk);
- for (size_t i = 0; i < BytesFromBuffer; ++i)
- Out[i] = Bytes[BytesFromDisk + i];
-
- // Restore the file position.
- FS->seek(CurPos);
+ uint64_t ByteNo = BitNo / 8;
+ uint64_t StartBit = BitNo & 7;
+ uint64_t NumOfFlushedBytes = GetNumOfFlushedBytes();
+
+ if (ByteNo >= NumOfFlushedBytes) {
+ assert((!endian::readAtBitAlignment<uint32_t, little, unaligned>(
+ &Out[ByteNo - NumOfFlushedBytes], StartBit)) &&
+ "Expected to be patching over 0-value placeholders");
+ endian::writeAtBitAlignment<uint32_t, little, unaligned>(
+ &Out[ByteNo - NumOfFlushedBytes], NewWord, StartBit);
+ return;
+ }
+
+ // If the byte offset to backpatch is flushed, use seek to backfill data.
+ // First, save the file position to restore later.
+ uint64_t CurPos = FS->tell();
+
+ // Copy data to update into Bytes from the file FS and the buffer Out.
+ char Bytes[9]; // Use one more byte to silence a warning from Visual C++.
+ size_t BytesNum = StartBit ? 8 : 4;
+ size_t BytesFromDisk = std::min(static_cast<uint64_t>(BytesNum), NumOfFlushedBytes - ByteNo);
+ size_t BytesFromBuffer = BytesNum - BytesFromDisk;
+
+ // When unaligned, copy existing data into Bytes from the file FS and the
+ // buffer Out so that it can be updated before writing. For debug builds
+ // read bytes unconditionally in order to check that the existing value is 0
+ // as expected.
+#ifdef NDEBUG
+ if (StartBit)
+#endif
+ {
+ FS->seek(ByteNo);
+ ssize_t BytesRead = FS->read(Bytes, BytesFromDisk);
+ (void)BytesRead; // silence warning
+ assert(BytesRead >= 0 && static_cast<size_t>(BytesRead) == BytesFromDisk);
+ for (size_t i = 0; i < BytesFromBuffer; ++i)
+ Bytes[BytesFromDisk + i] = Out[i];
+ assert((!endian::readAtBitAlignment<uint32_t, little, unaligned>(
+ Bytes, StartBit)) &&
+ "Expected to be patching over 0-value placeholders");
+ }
+
+ // Update Bytes in terms of bit offset and value.
+ endian::writeAtBitAlignment<uint32_t, little, unaligned>(Bytes, NewWord,
+ StartBit);
+
+ // Copy updated data back to the file FS and the buffer Out.
+ FS->seek(ByteNo);
+ FS->write(Bytes, BytesFromDisk);
+ for (size_t i = 0; i < BytesFromBuffer; ++i)
+ Out[i] = Bytes[BytesFromDisk + i];
+
+ // Restore the file position.
+ FS->seek(CurPos);
}
void BackpatchWord64(uint64_t BitNo, uint64_t Val) {