[llvm] [SystemZ][z/OS] yaml2obj for header and end records (PR #73859)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 12:54:32 PST 2023
================
@@ -105,82 +112,64 @@ class GOFFOstream : public raw_ostream {
return Bytes ? Bytes : GOFF::PayloadLength;
}
- /// Write the record prefix of a physical record, using the current record
- /// type.
+ // Write the record prefix of a physical record, using the current record
+ // type.
static void writeRecordPrefix(raw_ostream &OS, GOFF::RecordType Type,
size_t RemainingSize,
- uint8_t Flags = Rec_Continuation);
-
- /// Fill the last physical record of a logical record with zero bytes.
- void fillRecord();
-
- /// See raw_ostream::write_impl.
- void write_impl(const char *Ptr, size_t Size) override;
-
- /// Return the current position within the stream, not counting the bytes
- /// currently in the buffer.
- uint64_t current_pos() const override { return OS.tell(); }
-};
-
-void GOFFOstream::writeRecordPrefix(raw_ostream &OS, GOFF::RecordType Type,
- size_t RemainingSize, uint8_t Flags) {
- uint8_t TypeAndFlags = Flags | (Type << 4);
- if (RemainingSize > GOFF::RecordLength)
- TypeAndFlags |= Rec_Continued;
- OS << binaryBe(static_cast<unsigned char>(GOFF::PTVPrefix))
- << binaryBe(static_cast<unsigned char>(TypeAndFlags))
- << binaryBe(static_cast<unsigned char>(0));
-}
-
-void GOFFOstream::makeNewRecord(GOFF::RecordType Type, size_t Size) {
- fillRecord();
- CurrentType = Type;
- RemainingSize = Size;
- if (size_t Gap = (RemainingSize % GOFF::PayloadLength))
- RemainingSize += GOFF::PayloadLength - Gap;
- NewLogicalRecord = true;
- ++LogicalRecords;
-}
-
-void GOFFOstream::fillRecord() {
- assert((GetNumBytesInBuffer() <= RemainingSize) &&
- "More bytes in buffer than expected");
- size_t Remains = RemainingSize - GetNumBytesInBuffer();
- if (Remains) {
- assert((Remains < GOFF::RecordLength) &&
- "Attempting to fill more than one physical record");
- raw_ostream::write_zeros(Remains);
+ uint8_t Flags = Rec_Continuation) {
+ uint8_t TypeAndFlags = Flags | (Type << 4);
+ if (RemainingSize > GOFF::RecordLength)
+ TypeAndFlags |= Rec_Continued;
+ OS << binaryBe(static_cast<unsigned char>(GOFF::PTVPrefix))
+ << binaryBe(static_cast<unsigned char>(TypeAndFlags))
+ << binaryBe(static_cast<unsigned char>(0));
}
- flush();
- assert(RemainingSize == 0 && "Not fully flushed");
- assert(GetNumBytesInBuffer() == 0 && "Buffer not fully empty");
-}
-
-void GOFFOstream::write_impl(const char *Ptr, size_t Size) {
- assert((RemainingSize >= Size) && "Attempt to write too much data");
- assert(RemainingSize && "Logical record overflow");
- if (!(RemainingSize % GOFF::PayloadLength)) {
- writeRecordPrefix(OS, CurrentType, RemainingSize,
- NewLogicalRecord ? 0 : Rec_Continuation);
- NewLogicalRecord = false;
+ // Fill the last physical record of a logical record with zero bytes.
----------------
jh7370 wrote:
Nit: missing blank line between this and the previous function.
https://github.com/llvm/llvm-project/pull/73859
More information about the llvm-commits
mailing list