30 Rec_Continuation = 1 << (8 - 6 - 1),
33template <
typename ValueType>
struct BinaryBeImpl {
38template <
typename ValueType>
40 char Buffer[
sizeof(BBE.Value)];
41 support::endian::write<ValueType, llvm::endianness::big, support::unaligned>(
43 OS.
write(Buffer,
sizeof(BBE.Value));
47template <
typename ValueType> BinaryBeImpl<ValueType> binaryBe(
ValueType V) {
48 return BinaryBeImpl<ValueType>(V);
60ZerosImpl
zeros(
const size_t NumBytes) {
return ZerosImpl{NumBytes}; }
70 :
OS(
OS), LogicalRecords(0), RemainingSize(0), NewLogicalRecord(
false) {
82 NewLogicalRecord =
true;
88 uint32_t logicalRecords() {
return LogicalRecords; }
104 bool NewLogicalRecord;
109 size_t bytesToNextPhysicalRecord() {
117 size_t RemainingSize,
118 uint8_t Flags = Rec_Continuation) {
121 TypeAndFlags |= Rec_Continued;
123 << binaryBe(
static_cast<unsigned char>(TypeAndFlags))
124 << binaryBe(
static_cast<unsigned char>(0));
130 "More bytes in buffer than expected");
134 "Attempting to fill more than one physical record");
138 assert(RemainingSize == 0 &&
"Not fully flushed");
143 void write_impl(
const char *
Ptr,
size_t Size)
override {
144 assert((RemainingSize >=
Size) &&
"Attempt to write too much data");
145 assert(RemainingSize &&
"Logical record overflow");
147 writeRecordPrefix(OS, CurrentType, RemainingSize,
148 NewLogicalRecord ? 0 : Rec_Continuation);
149 NewLogicalRecord =
false;
151 assert(!NewLogicalRecord &&
152 "New logical record not on physical record boundary");
156 size_t BytesToWrite = bytesToNextPhysicalRecord();
157 if (BytesToWrite >
Size)
161 Size -= BytesToWrite;
162 RemainingSize -= BytesToWrite;
164 writeRecordPrefix(OS, CurrentType, RemainingSize);
185 : GW(
OS), Doc(Doc), ErrHandler(ErrHandler), HasError(
false) {}
187 ~GOFFState() { GW.finalize(); }
204 if (std::error_code EC =
207 if (CCSIDName.
size() > 16) {
215 if (LangProd.
size() > 16) {
224 << binaryBe(FileHdr.
CCSID)
237 GW << binaryBe(ModPropLen) <<
zeros(6);
245void GOFFState::writeEnd() {
250 << binaryBe(GW.logicalRecords());
255bool GOFFState::writeObject() {
256 writeHeader(Doc.Header);
265 GOFFState State(
OS, Doc, ErrHandler);
266 return State.writeObject();
275 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
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.