[llvm] da01a18 - [SPARC][IAS] Set correct ELF flag values for VIS & VIS2-enabled objects

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 23 07:02:04 PDT 2025


Author: Koakuma
Date: 2025-03-23T21:02:02+07:00
New Revision: da01a185f196df4b60b61306fdc4e185f1e9fb39

URL: https://github.com/llvm/llvm-project/commit/da01a185f196df4b60b61306fdc4e185f1e9fb39
DIFF: https://github.com/llvm/llvm-project/commit/da01a185f196df4b60b61306fdc4e185f1e9fb39.diff

LOG: [SPARC][IAS] Set correct ELF flag values for VIS & VIS2-enabled objects



Reviewers: brad0, s-barannikov, rorth

Reviewed By: s-barannikov

Pull Request: https://github.com/llvm/llvm-project/pull/130966

Added: 
    llvm/test/MC/Sparc/elf-sparc-feature.s

Modified: 
    llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.cpp
index 3205d06b295ee..6dd89849a2b71 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.cpp
@@ -27,6 +27,14 @@ static unsigned getEFlagsForFeatureSet(const MCSubtargetInfo &STI) {
   if (STI.hasFeature(Sparc::FeatureV8Plus))
     EFlags |= ELF::EF_SPARC_32PLUS;
 
+  if (STI.hasFeature(Sparc::FeatureVIS))
+    EFlags |= ELF::EF_SPARC_SUN_US1;
+
+  if (STI.hasFeature(Sparc::FeatureVIS2))
+    EFlags |= ELF::EF_SPARC_SUN_US3;
+
+  // VIS 3 and other ISA extensions doesn't set any flags.
+
   return EFlags;
 }
 

diff  --git a/llvm/test/MC/Sparc/elf-sparc-feature.s b/llvm/test/MC/Sparc/elf-sparc-feature.s
new file mode 100644
index 0000000000000..db30396c950f1
--- /dev/null
+++ b/llvm/test/MC/Sparc/elf-sparc-feature.s
@@ -0,0 +1,11 @@
+## Emit correct SPARC v9 ELF flags depending on feature options.
+## - `-mattr=+vis` sets the EF_SPARC_SUN_US1 flag; and
+## - `-mattr=+vis2` sets the EF_SPARC_SUN_US3 flag.
+
+# RUN: llvm-mc -filetype=obj -triple sparcv9              %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=COMMON      -DFLAG_VALUE=0x0                                %s
+# RUN: llvm-mc -filetype=obj -triple sparcv9 -mattr=+vis  %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=COMMON,FLAG -DFLAG_VALUE=0x200 -DFLAG_NAME=EF_SPARC_SUN_US1 %s
+# RUN: llvm-mc -filetype=obj -triple sparcv9 -mattr=+vis2 %s -o - | llvm-readobj -h - | FileCheck --check-prefixes=COMMON,FLAG -DFLAG_VALUE=0x800 -DFLAG_NAME=EF_SPARC_SUN_US3 %s
+
+# COMMON:      Flags [ ([[FLAG_VALUE]])
+# FLAG:          [[FLAG_NAME]]
+# COMMON-NEXT: ]


        


More information about the llvm-commits mailing list