LLVM 22.0.0git
MCGOFFObjectWriter.h
Go to the documentation of this file.
1//===- MCGOFFObjectWriter.h - GOFF Object Writer ----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_MC_MCGOFFOBJECTWRITER_H
10#define LLVM_MC_MCGOFFOBJECTWRITER_H
11
14#include "llvm/MC/MCValue.h"
15#include <memory>
16#include <vector>
17
18namespace llvm {
19class MCObjectWriter;
20class MCSectionGOFF;
21class MCSymbolGOFF;
23
25protected:
27
28public:
30 Reloc_Type_ACon = 0x1, // General address.
31 Reloc_Type_RICon = 0x2, // Relative-immediate address.
32 Reloc_Type_QCon = 0x3, // Offset of symbol in class.
33 Reloc_Type_VCon = 0x4, // Address of external symbol.
34 Reloc_Type_RCon = 0x5, // PSECT of symbol.
35 };
36
37 ~MCGOFFObjectTargetWriter() override = default;
38
39 virtual unsigned getRelocType(const MCValue &Target,
40 const MCFixup &Fixup) const = 0;
41
42 Triple::ObjectFormatType getFormat() const override { return Triple::GOFF; }
43
44 static bool classof(const MCObjectTargetWriter *W) {
45 return W->getFormat() == Triple::GOFF;
46 }
47};
48
49// A GOFFRelocationEntry describes a single relocation.
50// For the naming, see
51// https://www.ibm.com/docs/en/zos/3.1.0?topic=record-relocation-directory-data-item.
75
77 // The target specific GOFF writer instance.
78 std::unique_ptr<MCGOFFObjectTargetWriter> TargetObjectWriter;
79
80 // The stream used to write the GOFF records.
82
83 // The RootSD section.
84 MCSectionGOFF *RootSD = nullptr;
85
86 // Saved relocation data.
87 std::vector<GOFFRelocationEntry> Relocations;
88
89public:
90 GOFFObjectWriter(std::unique_ptr<MCGOFFObjectTargetWriter> MOTW,
93
94 void setRootSD(MCSectionGOFF *RootSD) { this->RootSD = RootSD; }
95
96 // Implementation of the MCObjectWriter interface.
97 void recordRelocation(const MCFragment &F, const MCFixup &Fixup,
98 MCValue Target, uint64_t &FixedValue) override;
99
100 uint64_t writeObject() override;
101};
102
103/// \brief Construct a new GOFF writer instance.
104///
105/// \param MOTW - The target-specific GOFF writer subclass.
106/// \param OS - The stream to write to.
107/// \returns The constructed object writer.
108std::unique_ptr<MCObjectWriter>
109createGOFFObjectWriter(std::unique_ptr<MCGOFFObjectTargetWriter> MOTW,
110 raw_pwrite_stream &OS);
111} // namespace llvm
112
113#endif
#define F(x, y, z)
Definition MD5.cpp:54
PowerPC TLS Dynamic Call Fixup
GOFFObjectWriter(std::unique_ptr< MCGOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
uint64_t writeObject() override
Write the object file and returns the number of bytes written.
~GOFFObjectWriter() override
void recordRelocation(const MCFragment &F, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
Record a relocation entry.
void setRootSD(MCSectionGOFF *RootSD)
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup) const =0
static bool classof(const MCObjectTargetWriter *W)
~MCGOFFObjectTargetWriter() override=default
Triple::ObjectFormatType getFormat() const override
Base class for classes that define behaviour that is specific to both the target and the object forma...
Defines the object file and target independent interfaces used by the assembler backend to write nati...
MCObjectWriter()=default
Target - Wrapper for Target specific information.
An abstract base class for streams implementations that also support a pwrite operation.
RLDFetchStore
Definition GOFF.h:181
RLDReferenceType
Definition GOFF.h:160
RLDReferentType
Definition GOFF.h:169
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< MCObjectWriter > createGOFFObjectWriter(std::unique_ptr< MCGOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Construct a new GOFF writer instance.
GOFF::RLDReferenceType ReferenceType
const MCSymbolGOFF * Rptr
const MCSectionGOFF * Pptr
GOFFRelocationEntry(const MCSectionGOFF *Pptr, const MCSymbolGOFF *Rptr, GOFF::RLDReferenceType ReferenceType, GOFF::RLDReferentType ReferentType, GOFF::RLDAction Action, GOFF::RLDFetchStore FetchStore, uint64_t POffset, uint32_t TargetLength)
GOFF::RLDFetchStore FetchStore
GOFF::RLDReferentType ReferentType