[llvm] [SPARC][Utilities] Add names for SPARC ELF flags in LLVM binary utilities (PR #102843)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 18:48:19 PDT 2024


https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/102843

>From b7e2ee82e9db4c2d45cb2721240a0fedf43b501a Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Mon, 12 Aug 2024 09:55:53 +0700
Subject: [PATCH 1/4] [SPARC][Utilities] Add names for SPARC ELF flags in
 llvm-readobj

This allows us to print readable names in llvm-readobj output.
---
 llvm/test/MC/Sparc/elf-sparc-flags.s  | 20 ++++++++++++++++++++
 llvm/tools/llvm-readobj/ELFDumper.cpp | 18 ++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 llvm/test/MC/Sparc/elf-sparc-flags.s

diff --git a/llvm/test/MC/Sparc/elf-sparc-flags.s b/llvm/test/MC/Sparc/elf-sparc-flags.s
new file mode 100644
index 00000000000000..f250aadfc61203
--- /dev/null
+++ b/llvm/test/MC/Sparc/elf-sparc-flags.s
@@ -0,0 +1,20 @@
+## Emit correct flags depending on triple, cpu, and memory model options.
+## - `-triple sparc` sets the flag field to 0x0
+## - `-triple sparc -mattr=+v8plus` adds an EF_SPARC_32PLUS (0x100)
+## - Currently, for sparc64 we always compile for TSO memory model, so
+##   `-triple sparcv9` sets the memory model flag to EF_SPARCV9_TSO (0x0)
+##   (i.e the last two bits have to be a zero).
+
+# RUN: llvm-mc -filetype=obj -triple sparc                  %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARC       %s
+# RUN: llvm-mc -filetype=obj -triple sparc   -mattr=+v8plus %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARC32PLUS %s
+# RUN: llvm-mc -filetype=obj -triple sparcv9                %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARCV9     %s
+
+# SPARC:      Flags [ (0x0)
+# SPARC-NEXT: ]
+
+# SPARC32PLUS:      Flags [ (0x100)
+# SPARC32PLUS-NEXT:   EF_SPARC_32PLUS (0x100)
+# SPARC32PLUS-NEXT: ]
+
+# SPARCV9:      Flags [ (0x0)
+# SPARCV9-NEXT: ]
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 1457ae8cb41733..3cc87e8b49fb2a 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1684,6 +1684,18 @@ const EnumEntry<unsigned> ElfHeaderRISCVFlags[] = {
   ENUM_ENT(EF_RISCV_TSO, "TSO"),
 };
 
+const EnumEntry<unsigned> ElfHeaderSPARCFlags[] = {
+    ENUM_ENT(EF_SPARC_EXT_MASK, "SPARC extension mask"),
+    ENUM_ENT(EF_SPARC_32PLUS, "V8+ ABI"),
+    ENUM_ENT(EF_SPARC_SUN_US1, "Sun UltraSPARC I extensions"),
+    ENUM_ENT(EF_SPARC_HAL_R1, "HAL/Fujitsu R1 extensions"),
+    ENUM_ENT(EF_SPARC_SUN_US3, "Sun UltraSPARC III extensions"),
+    ENUM_ENT(EF_SPARCV9_MM, "SPARC memory model mask"),
+    ENUM_ENT(EF_SPARCV9_TSO, "Total Store Ordering"),
+    ENUM_ENT(EF_SPARCV9_PSO, "Partial Store Ordering"),
+    ENUM_ENT(EF_SPARCV9_RMO, "Relaxed Memory Ordering"),
+};
+
 const EnumEntry<unsigned> ElfHeaderAVRFlags[] = {
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AVR_ARCH_AVR1),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AVR_ARCH_AVR2),
@@ -3625,6 +3637,9 @@ template <class ELFT> void GNUELFDumper<ELFT>::printFileHeaders() {
         unsigned(ELF::EF_MIPS_ABI), unsigned(ELF::EF_MIPS_MACH));
   else if (e.e_machine == EM_RISCV)
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderRISCVFlags));
+  else if (e.e_machine == EM_SPARC || e.e_machine == EM_SPARC32PLUS ||
+           e.e_machine == EM_SPARCV9)
+    ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderSPARCFlags));
   else if (e.e_machine == EM_AVR)
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderAVRFlags),
                           unsigned(ELF::EF_AVR_ARCH_MASK));
@@ -7117,6 +7132,9 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printFileHeaders() {
       }
     } else if (E.e_machine == EM_RISCV)
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderRISCVFlags));
+    else if (E.e_machine == EM_SPARC || E.e_machine == EM_SPARC32PLUS ||
+             E.e_machine == EM_SPARCV9)
+      W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderSPARCFlags));
     else if (E.e_machine == EM_AVR)
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderAVRFlags),
                    unsigned(ELF::EF_AVR_ARCH_MASK));

>From 6ec2ef4a64b09f2a89e7b3a994aabd79afdd7972 Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Mon, 12 Aug 2024 18:24:14 +0700
Subject: [PATCH 2/4] Properly use the flag masks when printing

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 3cc87e8b49fb2a..d27d695dad0987 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1685,12 +1685,10 @@ const EnumEntry<unsigned> ElfHeaderRISCVFlags[] = {
 };
 
 const EnumEntry<unsigned> ElfHeaderSPARCFlags[] = {
-    ENUM_ENT(EF_SPARC_EXT_MASK, "SPARC extension mask"),
     ENUM_ENT(EF_SPARC_32PLUS, "V8+ ABI"),
     ENUM_ENT(EF_SPARC_SUN_US1, "Sun UltraSPARC I extensions"),
     ENUM_ENT(EF_SPARC_HAL_R1, "HAL/Fujitsu R1 extensions"),
     ENUM_ENT(EF_SPARC_SUN_US3, "Sun UltraSPARC III extensions"),
-    ENUM_ENT(EF_SPARCV9_MM, "SPARC memory model mask"),
     ENUM_ENT(EF_SPARCV9_TSO, "Total Store Ordering"),
     ENUM_ENT(EF_SPARCV9_PSO, "Partial Store Ordering"),
     ENUM_ENT(EF_SPARCV9_RMO, "Relaxed Memory Ordering"),
@@ -3639,7 +3637,9 @@ template <class ELFT> void GNUELFDumper<ELFT>::printFileHeaders() {
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderRISCVFlags));
   else if (e.e_machine == EM_SPARC || e.e_machine == EM_SPARC32PLUS ||
            e.e_machine == EM_SPARCV9)
-    ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderSPARCFlags));
+    ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderSPARCFlags),
+                          unsigned(ELF::EF_SPARC_EXT_MASK),
+                          unsigned(ELF::EF_SPARCV9_MM));
   else if (e.e_machine == EM_AVR)
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderAVRFlags),
                           unsigned(ELF::EF_AVR_ARCH_MASK));
@@ -7134,7 +7134,9 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printFileHeaders() {
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderRISCVFlags));
     else if (E.e_machine == EM_SPARC || E.e_machine == EM_SPARC32PLUS ||
              E.e_machine == EM_SPARCV9)
-      W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderSPARCFlags));
+      W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderSPARCFlags),
+                   unsigned(ELF::EF_SPARC_EXT_MASK),
+                   unsigned(ELF::EF_SPARCV9_MM));
     else if (E.e_machine == EM_AVR)
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderAVRFlags),
                    unsigned(ELF::EF_AVR_ARCH_MASK));

>From 82640d0029af62ce5af3b306a7a866c8a1aa1556 Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Mon, 12 Aug 2024 22:34:24 +0700
Subject: [PATCH 3/4] Move tests to YAML; fix a bug in feature flag decoding

---
 llvm/include/llvm/BinaryFormat/ELF.h          | 11 +++++++
 llvm/lib/ObjectYAML/ELFYAML.cpp               | 14 +++++++++
 llvm/test/MC/Sparc/elf-sparc-flags.s          | 20 -------------
 .../ELF/Sparc/sparc-elf-headers.test          | 13 +++++++++
 .../ELF/Sparc/sparc64-elf-headers.test        | 29 +++++++++++++++++++
 .../ELF/Sparc/sparcv8plus-elf-headers.test    | 23 +++++++++++++++
 llvm/tools/llvm-readobj/ELFDumper.cpp         |  2 --
 7 files changed, 90 insertions(+), 22 deletions(-)
 delete mode 100644 llvm/test/MC/Sparc/elf-sparc-flags.s
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test

diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h
index c21bb41d386aca..29dbe4b522ed54 100644
--- a/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/llvm/include/llvm/BinaryFormat/ELF.h
@@ -699,11 +699,22 @@ enum {
 
 // SPARC Specific e_flags
 enum : unsigned {
+  // ELF extension mask.
+  // All values are available for 32 and 64-bit objects,
+  // except EF_SPARC_32PLUS which is a 32-bit only flag.
+  //
+  // Note that those features are not mutually exclusive (i.e
+  // one can set more than one flag in this group), so
+  // do not use the mask in LLVM's BCaseMask, printFlags,
+  // etc. as they assume that everything covered under one
+  // mask needs to be a mutually exclusive choice.
   EF_SPARC_EXT_MASK = 0xffff00,
   EF_SPARC_32PLUS = 0x000100,
   EF_SPARC_SUN_US1 = 0x000200,
   EF_SPARC_HAL_R1 = 0x000400,
   EF_SPARC_SUN_US3 = 0x000800,
+
+  // Memory model selection mask for 64-bit SPARC objects.
   EF_SPARCV9_MM = 0x3,
   EF_SPARCV9_TSO = 0x0,
   EF_SPARCV9_PSO = 0x1,
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index cb099efe51309f..195aa669f1090b 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -546,6 +546,20 @@ void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
     BCase(EF_RISCV_RVE);
     BCase(EF_RISCV_TSO);
     break;
+  case ELF::EM_SPARC32PLUS:
+    BCase(EF_SPARC_32PLUS);
+    BCase(EF_SPARC_SUN_US1);
+    BCase(EF_SPARC_SUN_US3);
+    BCase(EF_SPARC_HAL_R1);
+    break;
+  case ELF::EM_SPARCV9:
+    BCase(EF_SPARC_SUN_US1);
+    BCase(EF_SPARC_SUN_US3);
+    BCase(EF_SPARC_HAL_R1);
+    BCaseMask(EF_SPARCV9_RMO, EF_SPARCV9_MM);
+    BCaseMask(EF_SPARCV9_PSO, EF_SPARCV9_MM);
+    BCaseMask(EF_SPARCV9_TSO, EF_SPARCV9_MM);
+    break;
   case ELF::EM_XTENSA:
     BCase(EF_XTENSA_XT_INSN);
     BCaseMask(EF_XTENSA_MACH_NONE, EF_XTENSA_MACH);
diff --git a/llvm/test/MC/Sparc/elf-sparc-flags.s b/llvm/test/MC/Sparc/elf-sparc-flags.s
deleted file mode 100644
index f250aadfc61203..00000000000000
--- a/llvm/test/MC/Sparc/elf-sparc-flags.s
+++ /dev/null
@@ -1,20 +0,0 @@
-## Emit correct flags depending on triple, cpu, and memory model options.
-## - `-triple sparc` sets the flag field to 0x0
-## - `-triple sparc -mattr=+v8plus` adds an EF_SPARC_32PLUS (0x100)
-## - Currently, for sparc64 we always compile for TSO memory model, so
-##   `-triple sparcv9` sets the memory model flag to EF_SPARCV9_TSO (0x0)
-##   (i.e the last two bits have to be a zero).
-
-# RUN: llvm-mc -filetype=obj -triple sparc                  %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARC       %s
-# RUN: llvm-mc -filetype=obj -triple sparc   -mattr=+v8plus %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARC32PLUS %s
-# RUN: llvm-mc -filetype=obj -triple sparcv9                %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=SPARCV9     %s
-
-# SPARC:      Flags [ (0x0)
-# SPARC-NEXT: ]
-
-# SPARC32PLUS:      Flags [ (0x100)
-# SPARC32PLUS-NEXT:   EF_SPARC_32PLUS (0x100)
-# SPARC32PLUS-NEXT: ]
-
-# SPARCV9:      Flags [ (0x0)
-# SPARCV9-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
new file mode 100644
index 00000000000000..0fdfb6e304aa5e
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
@@ -0,0 +1,13 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -h %t | FileCheck %s -DFLAG_VALUE=0x0
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2MSB
+  Type:            ET_REL
+  Machine:         EM_SPARC
+
+# CHECK:          Flags [ ([[FLAG_VALUE]])
+# CHECK-NEXT:     ]
+
diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
new file mode 100644
index 00000000000000..862d0aec2448be
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
@@ -0,0 +1,29 @@
+# RUN: yaml2obj %s -o %t -DFLAG_NAME=""
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=PLAIN -DFLAG_VALUE=0x0
+
+# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1 -DFLAG_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x200
+
+# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_SUN_US1, EF_SPARCV9_RMO"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1-RMO -DFLAG0_NAME=EF_SPARCV9_RMO -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x202
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2MSB
+  Type:            ET_REL
+  Machine:         EM_SPARCV9
+  Flags:           [ [[FLAG_NAME]] ]
+
+# PLAIN:          Flags [ ([[FLAG_VALUE]])
+# PLAIN-NEXT:     ]
+
+# US1:          Flags [ ([[FLAG_VALUE]])
+# US1-NEXT:       [[FLAG_NAME]]
+# US1-NEXT:     ]
+
+# US1-RMO:          Flags [ ([[FLAG_VALUE]])
+# US1-RMO-NEXT:       [[FLAG0_NAME]]
+# US1-RMO-NEXT:       [[FLAG1_NAME]]
+# US1-RMO-NEXT:     ]
+
diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test
new file mode 100644
index 00000000000000..e266ad265d95e9
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test
@@ -0,0 +1,23 @@
+# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_32PLUS"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=PLAIN -DFLAG_NAME=EF_SPARC_32PLUS -DFLAG_VALUE=0x100
+
+# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_32PLUS, EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1 -DFLAG0_NAME=EF_SPARC_32PLUS -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x300
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2MSB
+  Type:            ET_REL
+  Machine:         EM_SPARC32PLUS
+  Flags:           [ [[FLAG_NAME]] ]
+
+# PLAIN:          Flags [ ([[FLAG_VALUE]])
+# PLAIN-NEXT:       [[FLAG_NAME]] ([[FLAG_VALUE]])
+# PLAIN-NEXT:     ]
+
+# US1:          Flags [ ([[FLAG_VALUE]])
+# US1-NEXT:       [[FLAG0_NAME]]
+# US1-NEXT:       [[FLAG1_NAME]]
+# US1-NEXT:     ]
+
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index d27d695dad0987..03846fa3569465 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3638,7 +3638,6 @@ template <class ELFT> void GNUELFDumper<ELFT>::printFileHeaders() {
   else if (e.e_machine == EM_SPARC || e.e_machine == EM_SPARC32PLUS ||
            e.e_machine == EM_SPARCV9)
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderSPARCFlags),
-                          unsigned(ELF::EF_SPARC_EXT_MASK),
                           unsigned(ELF::EF_SPARCV9_MM));
   else if (e.e_machine == EM_AVR)
     ElfFlags = printFlags(e.e_flags, ArrayRef(ElfHeaderAVRFlags),
@@ -7135,7 +7134,6 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printFileHeaders() {
     else if (E.e_machine == EM_SPARC || E.e_machine == EM_SPARC32PLUS ||
              E.e_machine == EM_SPARCV9)
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderSPARCFlags),
-                   unsigned(ELF::EF_SPARC_EXT_MASK),
                    unsigned(ELF::EF_SPARCV9_MM));
     else if (E.e_machine == EM_AVR)
       W.printFlags("Flags", E.e_flags, ArrayRef(ElfHeaderAVRFlags),

>From 6b4f2194c49694a45bea102cbeaf5f3bc2646260 Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Tue, 13 Aug 2024 08:47:53 +0700
Subject: [PATCH 4/4] Merge tests into one file

---
 .../ELF/Sparc/sparc-elf-headers.test          | 48 ++++++++++++++++---
 .../ELF/Sparc/sparc64-elf-headers.test        | 29 -----------
 .../ELF/Sparc/sparcv8plus-elf-headers.test    | 23 ---------
 3 files changed, 42 insertions(+), 58 deletions(-)
 delete mode 100644 llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
 delete mode 100644 llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test

diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
index 0fdfb6e304aa5e..09bc866e950fb4 100644
--- a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc-elf-headers.test
@@ -1,13 +1,49 @@
-# RUN: yaml2obj %s -o %t
-# RUN: llvm-readobj -h %t | FileCheck %s -DFLAG_VALUE=0x0
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC" -DFLAG_NAME=""
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8 -DFLAG_VALUE=0x0
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC32PLUS" -DFLAG_NAME="EF_SPARC_32PLUS"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8PLUS-PLAIN -DFLAG_NAME=EF_SPARC_32PLUS -DFLAG_VALUE=0x100
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS32" -DMACHINE_NAME="EM_SPARC32PLUS" -DFLAG_NAME="EF_SPARC_32PLUS, EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V8PLUS-US1 -DFLAG0_NAME=EF_SPARC_32PLUS -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x300
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME=""
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-PLAIN -DFLAG_VALUE=0x0
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME="EF_SPARC_SUN_US1"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-US1 -DFLAG_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x200
+
+# RUN: yaml2obj %s -o %t -DCLASS_NAME="ELFCLASS64" -DMACHINE_NAME="EM_SPARCV9" -DFLAG_NAME="EF_SPARC_SUN_US1, EF_SPARCV9_RMO"
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=V9-US1-RMO -DFLAG0_NAME=EF_SPARCV9_RMO -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x202
 
 --- !ELF
 FileHeader:
-  Class:           ELFCLASS32
+  Class:           [[CLASS_NAME]]
   Data:            ELFDATA2MSB
   Type:            ET_REL
-  Machine:         EM_SPARC
+  Machine:         [[MACHINE_NAME]]
+  Flags:           [ [[FLAG_NAME]] ]
+
+# V8:          Flags [ ([[FLAG_VALUE]])
+# V8-NEXT:     ]
+
+# V8PLUS-PLAIN:          Flags [ ([[FLAG_VALUE]])
+# V8PLUS-PLAIN-NEXT:       [[FLAG_NAME]] ([[FLAG_VALUE]])
+# V8PLUS-PLAIN-NEXT:     ]
+
+# V8PLUS-US1:          Flags [ ([[FLAG_VALUE]])
+# V8PLUS-US1-NEXT:       [[FLAG0_NAME]]
+# V8PLUS-US1-NEXT:       [[FLAG1_NAME]]
+# V8PLUS-US1-NEXT:     ]
+
+# V9-PLAIN:          Flags [ ([[FLAG_VALUE]])
+# V9-PLAIN-NEXT:     ]
 
-# CHECK:          Flags [ ([[FLAG_VALUE]])
-# CHECK-NEXT:     ]
+# V9-US1:          Flags [ ([[FLAG_VALUE]])
+# V9-US1-NEXT:       [[FLAG_NAME]]
+# V9-US1-NEXT:     ]
 
+# V9-US1-RMO:          Flags [ ([[FLAG_VALUE]])
+# V9-US1-RMO-NEXT:       [[FLAG0_NAME]]
+# V9-US1-RMO-NEXT:       [[FLAG1_NAME]]
+# V9-US1-RMO-NEXT:     ]
diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
deleted file mode 100644
index 862d0aec2448be..00000000000000
--- a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparc64-elf-headers.test
+++ /dev/null
@@ -1,29 +0,0 @@
-# RUN: yaml2obj %s -o %t -DFLAG_NAME=""
-# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=PLAIN -DFLAG_VALUE=0x0
-
-# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_SUN_US1"
-# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1 -DFLAG_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x200
-
-# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_SUN_US1, EF_SPARCV9_RMO"
-# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1-RMO -DFLAG0_NAME=EF_SPARCV9_RMO -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x202
-
---- !ELF
-FileHeader:
-  Class:           ELFCLASS64
-  Data:            ELFDATA2MSB
-  Type:            ET_REL
-  Machine:         EM_SPARCV9
-  Flags:           [ [[FLAG_NAME]] ]
-
-# PLAIN:          Flags [ ([[FLAG_VALUE]])
-# PLAIN-NEXT:     ]
-
-# US1:          Flags [ ([[FLAG_VALUE]])
-# US1-NEXT:       [[FLAG_NAME]]
-# US1-NEXT:     ]
-
-# US1-RMO:          Flags [ ([[FLAG_VALUE]])
-# US1-RMO-NEXT:       [[FLAG0_NAME]]
-# US1-RMO-NEXT:       [[FLAG1_NAME]]
-# US1-RMO-NEXT:     ]
-
diff --git a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test b/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test
deleted file mode 100644
index e266ad265d95e9..00000000000000
--- a/llvm/test/tools/llvm-readobj/ELF/Sparc/sparcv8plus-elf-headers.test
+++ /dev/null
@@ -1,23 +0,0 @@
-# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_32PLUS"
-# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=PLAIN -DFLAG_NAME=EF_SPARC_32PLUS -DFLAG_VALUE=0x100
-
-# RUN: yaml2obj %s -o %t -DFLAG_NAME="EF_SPARC_32PLUS, EF_SPARC_SUN_US1"
-# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=US1 -DFLAG0_NAME=EF_SPARC_32PLUS -DFLAG1_NAME=EF_SPARC_SUN_US1 -DFLAG_VALUE=0x300
-
---- !ELF
-FileHeader:
-  Class:           ELFCLASS32
-  Data:            ELFDATA2MSB
-  Type:            ET_REL
-  Machine:         EM_SPARC32PLUS
-  Flags:           [ [[FLAG_NAME]] ]
-
-# PLAIN:          Flags [ ([[FLAG_VALUE]])
-# PLAIN-NEXT:       [[FLAG_NAME]] ([[FLAG_VALUE]])
-# PLAIN-NEXT:     ]
-
-# US1:          Flags [ ([[FLAG_VALUE]])
-# US1-NEXT:       [[FLAG0_NAME]]
-# US1-NEXT:       [[FLAG1_NAME]]
-# US1-NEXT:     ]
-



More information about the llvm-commits mailing list