LLVM: include/llvm/Support/BinaryStreamRef.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_SUPPORT_BINARYSTREAMREF_H

10#define LLVM_SUPPORT_BINARYSTREAMREF_H

11

17#include

18#include

19#include

20

21namespace llvm {

22

23

25protected:

32

34 std::optional<uint64_t> Length)

38 std::optional<uint64_t> Length)

42

45

46public:

48

55

56

57

58

61 return RefType();

62

64 RefType Result(static_cast<const RefType &>(*this));

65 if (N == 0)

66 return Result;

67

68 Result.ViewOffset += N;

69 if (Result.Length)

70 *Result.Length -= N;

71 return Result;

72 }

73

74

75

76

79 return RefType();

80

81 RefType Result(static_cast<const RefType &>(*this));

83

84 if (N == 0)

85 return Result;

86

87

88

89 if (!Result.Length)

91

92 *Result.Length -= N;

93 return Result;

94 }

95

96

101

102

107

108

109

113

114

115

119

121

123 if (LHS.BorrowedImpl != RHS.BorrowedImpl)

124 return false;

125 if (LHS.ViewOffset != RHS.ViewOffset)

126 return false;

127 if (LHS.Length != RHS.Length)

128 return false;

129 return true;

130 }

131

132protected:

140

145};

146

147

148

149

150

151

152

153

154class BinaryStreamRef

159 std::optional<uint64_t> Length)

161

162public:

166 std::optional<uint64_t> Length);

170

172 BinaryStreamRef &operator=(const BinaryStreamRef &Other) = default;

175

176

179

180

181

182

183

184

185

188

189

190

191

192

193

196};

197

201

204 return {Off + Offset, SubSub};

205 }

210

211 std::pair<BinarySubstreamRef, BinarySubstreamRef> split(uint64_t Off) const {

213 }

214

217};

218

219class WritableBinaryStreamRef

221 WritableBinaryStream> {

226

230

234 }

235

236public:

241 std::optional<uint64_t> Length);

245 WritableBinaryStreamRef &

247

249 WritableBinaryStreamRef &operator=(WritableBinaryStreamRef &&Other) = default;

250

251

254

255

256

257

258

259

260

262

263

265

266

268};

269

270}

271

272#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

friend bool operator==(const RefType &LHS, const RefType &RHS)

Definition BinaryStreamRef.h:122

uint64_t ViewOffset

Definition BinaryStreamRef.h:143

std::optional< uint64_t > Length

Definition BinaryStreamRef.h:144

RefType drop_back(uint64_t N) const

Return a new BinaryStreamRef with the last N elements removed.

Definition BinaryStreamRef.h:77

BinaryStreamRefBase & operator=(const BinaryStreamRefBase &Other)=default

RefType drop_front(uint64_t N) const

Return a new BinaryStreamRef with the first N elements removed.

Definition BinaryStreamRef.h:59

BinaryStreamRefBase()=default

BinaryStreamRefBase & operator=(BinaryStreamRefBase &&Other)=default

BinaryStreamRefBase(StreamType &BorrowedImpl, uint64_t Offset, std::optional< uint64_t > Length)

Definition BinaryStreamRef.h:37

std::shared_ptr< StreamType > SharedImpl

Definition BinaryStreamRef.h:141

StreamType * BorrowedImpl

Definition BinaryStreamRef.h:142

Error checkOffsetForRead(uint64_t Offset, uint64_t DataSize) const

Definition BinaryStreamRef.h:133

RefType drop_symmetric(uint64_t N) const

Return a new BinaryStreamRef with the first and last N elements removed.

Definition BinaryStreamRef.h:110

BinaryStreamRefBase(std::shared_ptr< StreamType > SharedImpl, uint64_t Offset, std::optional< uint64_t > Length)

Definition BinaryStreamRef.h:33

RefType slice(uint64_t Offset, uint64_t Len) const

Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...

Definition BinaryStreamRef.h:116

BinaryStreamRefBase(StreamType &BorrowedImpl)

Definition BinaryStreamRef.h:27

llvm::endianness getEndian() const

Definition BinaryStreamRef.h:47

RefType keep_back(uint64_t N) const

Return a new BinaryStreamRef with only the last N elements remaining.

Definition BinaryStreamRef.h:103

bool valid() const

Definition BinaryStreamRef.h:120

RefType keep_front(uint64_t N) const

Return a new BinaryStreamRef with only the first N elements remaining.

Definition BinaryStreamRef.h:97

BinaryStreamRefBase(BinaryStreamRefBase &&Other)=default

uint64_t getLength() const

Definition BinaryStreamRef.h:49

BinaryStreamRefBase(const BinaryStreamRefBase &Other)=default

BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.

Definition BinaryStreamRef.h:155

BinaryStreamRef(BinaryStreamRef &&Other)=default

LLVM_ABI Error readLongestContiguousChunk(uint64_t Offset, ArrayRef< uint8_t > &Buffer) const

Given an Offset into this BinaryStreamRef, return a reference to the largest buffer the stream could ...

BinaryStreamRef(const BinaryStreamRef &Other)=default

BinaryStreamRef(BinaryStreamRef &S, uint64_t Offset, uint64_t Length)=delete

LLVM_ABI Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) const

Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream.

friend class WritableBinaryStreamRef

Definition BinaryStreamRef.h:157

BinaryStreamRef()=default

BinaryStreamRef & operator=(BinaryStreamRef &&Other)=default

BinaryStreamRef & operator=(const BinaryStreamRef &Other)=default

An interface for accessing data in a stream-like format, but which discourages copying.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...

StringRef - Represent a constant reference to a string, i.e.

WritableBinaryStreamRef & operator=(const WritableBinaryStreamRef &Other)=default

WritableBinaryStreamRef(const WritableBinaryStreamRef &Other)=default

WritableBinaryStreamRef()=default

WritableBinaryStreamRef(WritableBinaryStreamRef &&Other)=default

WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint64_t Offset, uint64_t Length)=delete

LLVM_ABI Error writeBytes(uint64_t Offset, ArrayRef< uint8_t > Data) const

Given an Offset into this WritableBinaryStreamRef and some input data, writes the data to the underly...

WritableBinaryStreamRef & operator=(WritableBinaryStreamRef &&Other)=default

LLVM_ABI Error commit()

For buffered streams, commits changes to the backing store.

A BinaryStream which can be read from as well as written to.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr uintptr_t uintptr_t DataSize

decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

Definition BinaryStreamRef.h:198

uint64_t Offset

Definition BinaryStreamRef.h:199

std::pair< BinarySubstreamRef, BinarySubstreamRef > split(uint64_t Off) const

Definition BinaryStreamRef.h:211

uint64_t size() const

Definition BinaryStreamRef.h:215

BinarySubstreamRef keep_front(uint64_t N) const

Definition BinaryStreamRef.h:209

bool empty() const

Definition BinaryStreamRef.h:216

BinarySubstreamRef slice(uint64_t Off, uint64_t Size) const

Definition BinaryStreamRef.h:202

BinaryStreamRef StreamData

Definition BinaryStreamRef.h:200

BinarySubstreamRef drop_front(uint64_t N) const

Definition BinaryStreamRef.h:206