9#include "llvm/ADT/STLExtras.h"
15static inline bool bitof(
const std::byte *B,
Bits BitIndex) {
22 for (
unsigned It = 0; It != BitWidth.
getQuantity(); ++It) {
29 DstBit = BitOffset +
Bits(It);
31 DstBit =
size() - BitOffset - BitWidth +
Bits(It);
38std::unique_ptr<std::byte[]>
40 Endian TargetEndianness)
const {
43 auto Out = std::make_unique<std::byte[]>(FullBitWidth.
roundToBytes());
45 for (
unsigned It = 0; It != BitWidth.
getQuantity(); ++It) {
48 BitIndex = BitOffset +
Bits(It);
50 BitIndex =
size() - BitWidth - BitOffset +
Bits(It);
52 bool BitValue =
bitof(
Data.get(), BitIndex);
85 if (End == (Offset -
Bits(1))) {
105 assert(Prev.End.N < Cur.Start.N);
116 bool FoundStart =
false;
119 if (BR.contains(
Range.End)) {
127 if (BR.contains(
Range.Start)) {
135 return Sum >=
Range.size();
140 static std::string hex(
T t) {
141 std::stringstream stream;
142 stream << std::hex << (
int)t;
143 return std::string(stream.str());
147 void BitcastBuffer::dump(
bool AsHex =
true)
const {
148 llvm::errs() <<
"LSB\n ";
149 unsigned LineLength = 0;
151 std::byte B =
Data[I];
153 std::stringstream stream;
154 stream << std::hex << (
int)B;
155 llvm::errs() << stream.str();
156 LineLength += stream.str().size() + 1;
158 llvm::errs() << std::bitset<8>((
int)B).to_string();
164 llvm::errs() <<
'\n';
166 for (
unsigned I = 0; I != LineLength; ++I)
168 llvm::errs() <<
"MSB\n";
static bool bitof(const std::byte *B, Bits BitIndex)
Returns the value of the bit in the given sequence of bytes.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
A bit range. Both Start and End are inclusive.
std::unique_ptr< std::byte[]> copyBits(Bits BitOffset, Bits BitWidth, Bits FullBitWidth, Endian TargetEndianness) const
Copy BitWidth bits at offset BitOffset from the buffer.
void markInitialized(Bits Start, Bits Length)
Marks the bits in the given range as initialized.
llvm::SmallVector< BitRange > InitializedBits
bool allInitialized() const
Returns true if all bits in the buffer have been initialized.
bool rangeInitialized(Bits Offset, Bits Length) const
Bits size() const
Returns the buffer size in bits.
void pushData(const std::byte *In, Bits BitOffset, Bits BitWidth, Endian TargetEndianness)
Push BitWidth bits at BitOffset from In into the buffer.
std::unique_ptr< std::byte[]> Data
size_t roundToBytes() const
size_t getOffsetInByte() const
size_t getQuantity() const