[llvm-branch-commits] [llvm] [GOFF] Add writing of section symbols (PR #133799)
Kai Nacke via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 7 13:51:29 PDT 2025
================
@@ -16,34 +16,94 @@
#define LLVM_MC_MCSECTIONGOFF_H
#include "llvm/BinaryFormat/GOFF.h"
+#include "llvm/MC/MCGOFFAttributes.h"
#include "llvm/MC/MCSection.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
class MCExpr;
class MCSectionGOFF final : public MCSection {
-private:
- MCSection *Parent;
- uint32_t Subsection;
+ // Parent of this section. Implies that the parent is emitted first.
+ MCSectionGOFF *Parent;
+
+ // The attributes of the GOFF symbols.
+ GOFF::SDAttr SDAttributes;
+ GOFF::EDAttr EDAttributes;
+ GOFF::PRAttr PRAttributes;
+
+ // The type of this section.
+ GOFF::ESDSymbolType SymbolType;
+
+ // Indicates that the PR symbol needs to set the length of the section to a
+ // non-zero value. This is only a problem with the ADA PR - the binder will
+ // generate an error in this case.
+ unsigned RequiresNonZeroLength : 1;
friend class MCContext;
- MCSectionGOFF(StringRef Name, SectionKind K, MCSection *P, uint32_t Sub)
+ MCSectionGOFF(StringRef Name, SectionKind K, GOFF::ESDSymbolType SymbolType,
+ GOFF::SDAttr SDAttributes, GOFF::EDAttr EDAttributes,
+ GOFF::PRAttr PRAttributes, MCSectionGOFF *Parent = nullptr)
: MCSection(SV_GOFF, Name, K.isText(), /*IsVirtual=*/false, nullptr),
- Parent(P), Subsection(Sub) {}
+ Parent(Parent), SDAttributes(SDAttributes), EDAttributes(EDAttributes),
+ PRAttributes(PRAttributes), SymbolType(SymbolType) {}
public:
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
raw_ostream &OS,
- uint32_t /*Subsection*/) const override {
- OS << "\t.section\t\"" << getName() << "\"\n";
+ uint32_t Subsection) const override {
+ switch (SymbolType) {
+ case GOFF::ESD_ST_SectionDefinition:
+ OS << Name << " CSECT\n";
+ break;
+ case GOFF::ESD_ST_ElementDefinition:
+ getParent()->printSwitchToSection(MAI, T, OS, Subsection);
+ OS << Name << " CATTR\n";
+ break;
+ case GOFF::ESD_ST_PartReference:
+ getParent()->printSwitchToSection(MAI, T, OS, Subsection);
+ OS << Name << " XATTR\n";
----------------
redstar wrote:
Yes, true, I need to update my HLASM skills.....
https://github.com/llvm/llvm-project/pull/133799
More information about the llvm-branch-commits
mailing list