Skip to content

Commit

Permalink
[SystemZ][z/OS] Add the PPA1 to SystemZAsmPrinter
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D125725
  • Loading branch information
Yusra Syeda committed May 18, 2022
1 parent 4d8268f commit 5ac411a
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 13 deletions.
31 changes: 31 additions & 0 deletions llvm/include/llvm/BinaryFormat/GOFF.h
@@ -0,0 +1,31 @@
//===-- llvm/BinaryFormat/GOFF.h - GOFF definitions --------------*- C++-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This header contains common, non-processor-specific data structures and
// constants for the GOFF file format.
//
// GOFF specifics can be found in MVS Program Management: Advanced Facilities
//===----------------------------------------------------------------------===//

#ifndef LLVM_BINARYFORMAT_GOFF_H
#define LLVM_BINARYFORMAT_GOFF_H

namespace llvm {

namespace GOFF {

// \brief Subsections of the primary C_CODE section in the object file.
enum SubsectionKind : uint8_t {
SK_PPA1 = 2,
};

} // end namespace GOFF

} // end namespace llvm

#endif // LLVM_BINARYFORMAT_GOFF_H
3 changes: 2 additions & 1 deletion llvm/include/llvm/MC/MCContext.h
Expand Up @@ -613,7 +613,8 @@ class MCContext {
unsigned Flags,
unsigned EntrySize);

MCSectionGOFF *getGOFFSection(StringRef Section, SectionKind Kind);
MCSectionGOFF *getGOFFSection(StringRef Section, SectionKind Kind,
MCSection *Parent, const MCExpr *SubsectionId);

MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
SectionKind Kind, StringRef COMDATSymName,
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/MC/MCObjectFileInfo.h
Expand Up @@ -225,6 +225,9 @@ class MCObjectFileInfo {
MCSection *GIATsSection = nullptr;
MCSection *GLJMPSection = nullptr;

// GOFF specific sections.
MCSection *PPA1Section = nullptr;

// XCOFF specific sections
MCSection *TOCBaseSection = nullptr;
MCSection *ReadOnly8Section = nullptr;
Expand Down Expand Up @@ -423,6 +426,9 @@ class MCObjectFileInfo {
MCSection *getGIATsSection() const { return GIATsSection; }
MCSection *getGLJMPSection() const { return GLJMPSection; }

// GOFF specific sections.
MCSection *getPPA1Section() const { return PPA1Section; }

// XCOFF specific sections
MCSection *getTOCBaseSection() const { return TOCBaseSection; }

Expand Down
11 changes: 9 additions & 2 deletions llvm/include/llvm/MC/MCSectionGOFF.h
Expand Up @@ -15,6 +15,7 @@
#ifndef LLVM_MC_MCSECTIONGOFF_H
#define LLVM_MC_MCSECTIONGOFF_H

#include "llvm/BinaryFormat/GOFF.h"
#include "llvm/MC/MCSection.h"
#include "llvm/Support/raw_ostream.h"

Expand All @@ -24,9 +25,12 @@ class MCExpr;

class MCSectionGOFF final : public MCSection {
private:
MCSection *Parent;
const MCExpr *SubsectionId;

friend class MCContext;
MCSectionGOFF(StringRef Name, SectionKind K)
: MCSection(SV_GOFF, Name, K, nullptr) {}
MCSectionGOFF(StringRef Name, SectionKind K, MCSection *P, const MCExpr *Sub)
: MCSection(SV_GOFF, Name, K, nullptr), Parent(P), SubsectionId(Sub) {}

public:
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
Expand All @@ -39,6 +43,9 @@ class MCSectionGOFF final : public MCSection {

bool isVirtualSection() const override { return false; }

MCSection *getParent() const { return Parent; }
const MCExpr *getSubsectionId() const { return SubsectionId; }

static bool classof(const MCSection *S) { return S->getVariant() == SV_GOFF; }
};
} // end namespace llvm
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Expand Up @@ -2593,8 +2593,8 @@ MCSection *TargetLoweringObjectFileGOFF::SelectSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
auto *Symbol = TM.getSymbol(GO);
if (Kind.isBSS())
return getContext().getGOFFSection(Symbol->getName(),
SectionKind::getBSS());
return getContext().getGOFFSection(Symbol->getName(), SectionKind::getBSS(),
nullptr, nullptr);

return getContext().getObjectFileInfo()->getTextSection();
}
7 changes: 5 additions & 2 deletions llvm/lib/MC/MCContext.cpp
Expand Up @@ -634,11 +634,14 @@ Optional<unsigned> MCContext::getELFUniqueIDForEntsize(StringRef SectionName,
return (I != ELFEntrySizeMap.end()) ? Optional<unsigned>(I->second) : None;
}

MCSectionGOFF *MCContext::getGOFFSection(StringRef Section, SectionKind Kind) {
MCSectionGOFF *MCContext::getGOFFSection(StringRef Section, SectionKind Kind,
MCSection *Parent,
const MCExpr *SubsectionId) {
// Do the lookup. If we don't have a hit, return a new section.
auto &GOFFSection = GOFFUniquingMap[Section.str()];
if (!GOFFSection)
GOFFSection = new (GOFFAllocator.Allocate()) MCSectionGOFF(Section, Kind);
GOFFSection = new (GOFFAllocator.Allocate())
MCSectionGOFF(Section, Kind, Parent, SubsectionId);

return GOFFSection;
}
Expand Down
9 changes: 7 additions & 2 deletions llvm/lib/MC/MCObjectFileInfo.cpp
Expand Up @@ -523,8 +523,13 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
}

void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
TextSection = Ctx->getGOFFSection(".text", SectionKind::getText());
BSSSection = Ctx->getGOFFSection(".bss", SectionKind::getBSS());
TextSection =
Ctx->getGOFFSection(".text", SectionKind::getText(), nullptr, nullptr);
BSSSection =
Ctx->getGOFFSection(".bss", SectionKind::getBSS(), nullptr, nullptr);
PPA1Section =
Ctx->getGOFFSection(".ppa1", SectionKind::getMetadata(), TextSection,
MCConstantExpr::create(GOFF::SK_PPA1, *Ctx));
}

void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
Expand Down

0 comments on commit 5ac411a

Please sign in to comment.