31 Rec_Continuation = 1 << (8 - 6 - 1),
34template <
typename ValueType>
struct BinaryBeImpl {
39template <
typename ValueType>
41 char Buffer[
sizeof(BBE.Value)];
42 support::endian::write<ValueType, llvm::endianness::big, support::unaligned>(
44 OS.
write(Buffer,
sizeof(BBE.Value));
48template <
typename ValueType> BinaryBeImpl<ValueType> binaryBe(
ValueType V) {
49 return BinaryBeImpl<ValueType>(V);
61ZerosImpl
zeros(
const size_t NumBytes) {
return ZerosImpl{NumBytes}; }
71 :
OS(
OS), LogicalRecords(0), RemainingSize(0), NewLogicalRecord(
false) {
83 NewLogicalRecord =
true;
89 uint32_t logicalRecords() {
return LogicalRecords; }
105 bool NewLogicalRecord;
110 size_t bytesToNextPhysicalRecord() {
118 size_t RemainingSize,
119 uint8_t Flags = Rec_Continuation) {
120 uint8_t TypeAndFlags =
Flags | (
Type << 4);
122 TypeAndFlags |= Rec_Continued;
124 << binaryBe(
static_cast<unsigned char>(TypeAndFlags))
125 << binaryBe(
static_cast<unsigned char>(0));
131 "More bytes in buffer than expected");
135 "Attempting to fill more than one physical record");
139 assert(RemainingSize == 0 &&
"Not fully flushed");
144 void write_impl(
const char *
Ptr,
size_t Size)
override {
145 assert((RemainingSize >=
Size) &&
"Attempt to write too much data");
146 assert(RemainingSize &&
"Logical record overflow");
148 writeRecordPrefix(OS, CurrentType, RemainingSize,
149 NewLogicalRecord ? 0 : Rec_Continuation);
150 NewLogicalRecord =
false;
152 assert(!NewLogicalRecord &&
153 "New logical record not on physical record boundary");
157 size_t BytesToWrite = bytesToNextPhysicalRecord();
158 if (BytesToWrite >
Size)
162 Size -= BytesToWrite;
163 RemainingSize -= BytesToWrite;
165 writeRecordPrefix(OS, CurrentType, RemainingSize);
186 : GW(
OS), Doc(Doc), ErrHandler(ErrHandler), HasError(
false) {}
188 ~GOFFState() { GW.finalize(); }
205 if (std::error_code EC =
208 if (CCSIDName.
size() > 16) {
216 if (LangProd.
size() > 16) {
225 << binaryBe(FileHdr.
CCSID)
238 GW << binaryBe(ModPropLen) <<
zeros(6);
248void GOFFState::writeEnd() {
250 GW << binaryBe(uint8_t(0))
251 << binaryBe(uint8_t(0))
253 << binaryBe(GW.logicalRecords());
258bool GOFFState::writeObject() {
259 writeHeader(Doc.Header);
268 GOFFState State(
OS, Doc, ErrHandler);
269 return State.writeObject();
278 return GOFFState::writeGOFF(Out, Doc, ErrHandler);
static Error reportError(StringRef Message)
zeros_impl< sizeof(T)> zeros(const T &)
This file provides utility functions for converting between EBCDIC-1047 and UTF-8.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file implements an indexed map.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
uint64_t tell() const
tell - Return the current offset with the file.
void SetBufferSize(size_t Size)
Set the stream to be buffered, using the specified buffer size.
raw_ostream & write(unsigned char C)
size_t GetNumBytesInBuffer() const
std::error_code convertToEBCDIC(StringRef Source, SmallVectorImpl< char > &Result)
constexpr uint8_t PayloadLength
constexpr uint8_t PTVPrefix
Prefix byte on every record. This indicates GOFF format.
constexpr uint8_t RecordLength
Length of the parts of a physical GOFF record.
bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Common declarations for yaml2obj.