Skip to content

[SystemZ][z/OS] Implement yaml2obj for GOFF Object File Format #71445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions llvm/lib/ObjectYAML/GOFFEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static const uint8_t TXTMaxDataLength = 56;
// Common flag values on records.
enum {
// Flag: This record is continued.
Rec_Continued = 1 << (8 - 7 - 1),
Rec_Continued = 1,

// Flag: This record is a continuation.
Rec_Continuation = 1 << (8 - 6 - 1),
Expand Down Expand Up @@ -73,6 +73,22 @@ raw_ostream &operator<<(raw_ostream &OS, const yaml::BinaryRef &Data) {
// physical records are created for the data. Possible fill bytes at the end of
// a physical record are written automatically.
class GOFFOstream : public raw_ostream {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no blank line here to start the class.

public:
explicit GOFFOstream(raw_ostream &OS)
: OS(OS), LogicalRecords(0), RemainingSize(0), NewLogicalRecord(false) {
SetBufferSize(GOFF::PayloadLength);
}

~GOFFOstream() { finalize(); }

void newRecord(GOFF::RecordType Type, size_t Size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


void finalize() { fillRecord(); }

uint32_t logicalRecords() { return LogicalRecords; }

private:
/// The underlying raw_ostream.
raw_ostream &OS;

Expand Down Expand Up @@ -112,20 +128,6 @@ class GOFFOstream : public raw_ostream {
/// Return the current position within the stream, not counting the bytes
/// currently in the buffer.
uint64_t current_pos() const override { return OS.tell(); }

public:
explicit GOFFOstream(raw_ostream &OS)
: OS(OS), LogicalRecords(0), RemainingSize(0), NewLogicalRecord(false) {
SetBufferSize(GOFF::PayloadLength);
}

~GOFFOstream() { finalize(); }

void newRecord(GOFF::RecordType Type, size_t Size);

void finalize() { fillRecord(); }

uint32_t logicalRecords() { return LogicalRecords; }
};

void GOFFOstream::writeRecordPrefix(raw_ostream &OS, GOFF::RecordType Type,
Expand Down Expand Up @@ -352,7 +354,7 @@ void GOFFState::writeSection(GOFFYAML::Section Sec) {

void GOFFState::writeRelocationDirectory(GOFFYAML::Relocations Rels) {
size_t Size = 0;
for (auto &Rel : Rels.Relocs) {
for (const llvm::GOFFYAML::Relocation &Rel : Rels.Relocs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'm fairly confident here and below you don't need llvm::.

Size += 8;
if (!(Rel.Flags & GOFF::RLD_Same_RID))
Size += 4;
Expand All @@ -375,7 +377,7 @@ void GOFFState::writeRelocationDirectory(GOFFYAML::Relocations Rels) {
GW.newRecord(GOFF::RT_RLD, Size + 3);
GW << binaryBe(uint8_t(0)) // Reserved
<< binaryBe(uint16_t(Size)); // Length of relocation data
for (auto &Rel : Rels.Relocs) {
for (const llvm::GOFFYAML::Relocation &Rel : Rels.Relocs) {
GW << binaryBe(uint8_t(Rel.Flags)) // Flags, byte 1
<< binaryBe(uint8_t(Rel.ReferenceType << 4 | Rel.ReferentType)) //
<< binaryBe(uint8_t(Rel.Action << 1 | (Rel.Flags >> 8))) //
Expand Down