[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 14 13:41:33 PDT 2025


================
@@ -0,0 +1,145 @@
+//===- MCSectionGOFF.cpp - GOFF Code Section Representation ---------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCSectionGOFF.h"
+#include "llvm/BinaryFormat/GOFF.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+namespace {
+void emitRMode(raw_ostream &OS, GOFF::ESDRmode Rmode, bool UseParenthesis) {
+  if (Rmode != GOFF::ESD_RMODE_None) {
+    OS << "RMODE" << (UseParenthesis ? '(' : ' ');
+    switch (Rmode) {
+    case GOFF::ESD_RMODE_24:
+      OS << "24";
+      break;
+    case GOFF::ESD_RMODE_31:
+      OS << "31";
+      break;
+    case GOFF::ESD_RMODE_64:
+      OS << "64";
+      break;
+    case GOFF::ESD_RMODE_None:
+      break;
+    }
+    if (UseParenthesis)
+      OS << ')';
+  }
+}
+
+void emitCATTR(raw_ostream &OS, StringRef Name, StringRef ParentName,
+               bool EmitAmodeAndRmode, GOFF::ESDAmode Amode,
+               GOFF::ESDRmode Rmode, GOFF::ESDAlignment Alignment,
+               GOFF::ESDLoadingBehavior LoadBehavior,
+               GOFF::ESDExecutable Executable, bool IsReadOnly,
+               StringRef PartName) {
+  if (EmitAmodeAndRmode && Amode != GOFF::ESD_AMODE_None) {
+    OS << ParentName << " AMODE ";
+    switch (Amode) {
+    case GOFF::ESD_AMODE_24:
+      OS << "24";
+      break;
+    case GOFF::ESD_AMODE_31:
+      OS << "31";
+      break;
+    case GOFF::ESD_AMODE_ANY:
+      OS << "ANY";
+      break;
+    case GOFF::ESD_AMODE_64:
+      OS << "64";
+      break;
+    case GOFF::ESD_AMODE_MIN:
+      OS << "ANY64";
+      break;
+    case GOFF::ESD_AMODE_None:
+      break;
+    }
+    OS << "\n";
+  }
+  if (EmitAmodeAndRmode && Rmode != GOFF::ESD_RMODE_None) {
+    OS << ParentName << ' ';
+    emitRMode(OS, Rmode, /*UseParenthesis=*/false);
----------------
redstar wrote:

I changed it, only the `CATTR RMODE` is now emitted.

https://github.com/llvm/llvm-project/pull/133799


More information about the llvm-branch-commits mailing list