-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARC][IAS] Set correct ELF flag values for VIS & VIS2-enabled objects #130966
Merged
koachan
merged 1 commit into
main
from
users/koachan/spr/sparcias-set-correct-elf-flag-values-for-vis-vis2-enabled-objects
Mar 23, 2025
Merged
[SPARC][IAS] Set correct ELF flag values for VIS & VIS2-enabled objects #130966
koachan
merged 1 commit into
main
from
users/koachan/spr/sparcias-set-correct-elf-flag-values-for-vis-vis2-enabled-objects
Mar 23, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.5
@llvm/pr-subscribers-backend-sparc Author: Koakuma (koachan) ChangesFull diff: https://github.com/llvm/llvm-project/pull/130966.diff 2 Files Affected:
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: ]
|
@llvm/pr-subscribers-mc Author: Koakuma (koachan) ChangesFull diff: https://github.com/llvm/llvm-project/pull/130966.diff 2 Files Affected:
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: ]
|
Ping? |
s-barannikov
approved these changes
Mar 22, 2025
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Mar 23, 2025
…abled objects Reviewers: brad0, s-barannikov, rorth Reviewed By: s-barannikov Pull Request: llvm/llvm-project#130966
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.