[llvm] [SPARC][IAS] Add `setuw` alias for `set` (PR #125149)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 23:27:10 PST 2025


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

>From 6b51393d638211fe66be14cb0a640f4b6ff59d0c Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Fri, 31 Jan 2025 09:05:24 +0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/lib/Target/Sparc/SparcInstrAliases.td        | 2 ++
 llvm/test/MC/Sparc/sparc-synthetic-instructions.s | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/llvm/lib/Target/Sparc/SparcInstrAliases.td b/llvm/lib/Target/Sparc/SparcInstrAliases.td
index 673a2db59b0929b..cfc0b4735c91c4b 100644
--- a/llvm/lib/Target/Sparc/SparcInstrAliases.td
+++ b/llvm/lib/Target/Sparc/SparcInstrAliases.td
@@ -605,6 +605,8 @@ def : InstAlias<"unimp", (UNIMP 0), 0>;
 // interchangeable with `unimp` all the time.
 def : MnemonicAlias<"illtrap", "unimp">;
 
+def : MnemonicAlias<"setuw", "set">;
+
 def : MnemonicAlias<"iflush", "flush">;
 
 def : MnemonicAlias<"stub", "stb">;
diff --git a/llvm/test/MC/Sparc/sparc-synthetic-instructions.s b/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
index 5652f868419504a..9c6db2836af1768 100644
--- a/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
+++ b/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
@@ -54,6 +54,13 @@
         ! CHECK:                                 !   fixup A - offset: 0, value: %lo(2147483647), kind: fixup_sparc_lo10
         set 2147483647, %o1
 
+        !! setuw is a mnemonic alias for set.
+        ! CHECK: sethi %hi(32768), %g1            ! encoding: [0x03,0b00AAAAAA,A,A]
+        ! CHECK:                                  !   fixup A - offset: 0, value: %hi(32768), kind: fixup_sparc_hi22
+        setuw 32768, %g1
+        ! CHECK: mov 1, %g1 ! encoding: [0x82,0x10,0x20,0x01]
+        setuw 1, %g1
+
         ! CHECK: xnor %g1, %g0, %g2               ! encoding: [0x84,0x38,0x40,0x00]
         not %g1, %g2
         ! CHECK: xnor %g1, %g0, %g1               ! encoding: [0x82,0x38,0x40,0x00]

>From 329c9415aa63f5376532adf9579f4743b37e32f6 Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Sat, 1 Feb 2025 14:26:42 +0700
Subject: [PATCH 2/2] Make setuw V9-only

Created using spr 1.3.4
---
 llvm/lib/Target/Sparc/SparcInstrAliases.td          | 2 +-
 llvm/test/MC/Sparc/sparc-synthetic-instructions.s   | 7 -------
 llvm/test/MC/Sparc/sparcv9-synthetic-instructions.s | 8 ++++++++
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Target/Sparc/SparcInstrAliases.td b/llvm/lib/Target/Sparc/SparcInstrAliases.td
index cfc0b4735c91c4b..906f51bb8d10b25 100644
--- a/llvm/lib/Target/Sparc/SparcInstrAliases.td
+++ b/llvm/lib/Target/Sparc/SparcInstrAliases.td
@@ -605,7 +605,7 @@ def : InstAlias<"unimp", (UNIMP 0), 0>;
 // interchangeable with `unimp` all the time.
 def : MnemonicAlias<"illtrap", "unimp">;
 
-def : MnemonicAlias<"setuw", "set">;
+def : MnemonicAlias<"setuw", "set">, Requires<[HasV9]>;
 
 def : MnemonicAlias<"iflush", "flush">;
 
diff --git a/llvm/test/MC/Sparc/sparc-synthetic-instructions.s b/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
index 9c6db2836af1768..5652f868419504a 100644
--- a/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
+++ b/llvm/test/MC/Sparc/sparc-synthetic-instructions.s
@@ -54,13 +54,6 @@
         ! CHECK:                                 !   fixup A - offset: 0, value: %lo(2147483647), kind: fixup_sparc_lo10
         set 2147483647, %o1
 
-        !! setuw is a mnemonic alias for set.
-        ! CHECK: sethi %hi(32768), %g1            ! encoding: [0x03,0b00AAAAAA,A,A]
-        ! CHECK:                                  !   fixup A - offset: 0, value: %hi(32768), kind: fixup_sparc_hi22
-        setuw 32768, %g1
-        ! CHECK: mov 1, %g1 ! encoding: [0x82,0x10,0x20,0x01]
-        setuw 1, %g1
-
         ! CHECK: xnor %g1, %g0, %g2               ! encoding: [0x84,0x38,0x40,0x00]
         not %g1, %g2
         ! CHECK: xnor %g1, %g0, %g1               ! encoding: [0x82,0x38,0x40,0x00]
diff --git a/llvm/test/MC/Sparc/sparcv9-synthetic-instructions.s b/llvm/test/MC/Sparc/sparcv9-synthetic-instructions.s
index d387e56bf02a342..f8a99cd1bdf5ebd 100644
--- a/llvm/test/MC/Sparc/sparcv9-synthetic-instructions.s
+++ b/llvm/test/MC/Sparc/sparcv9-synthetic-instructions.s
@@ -78,3 +78,11 @@ setx (0x0123456700000000+0x0000000089abcdef), %g1, %o0
 ! V9: sllx %g1, 32, %g1                       ! encoding: [0x83,0x28,0x70,0x20]
 ! V9: or %g1, %o0, %o0                        ! encoding: [0x90,0x10,0x40,0x08]
 setx (.BB1-.BB0), %g1, %o0
+
+!! In V9, setuw is a mnemonic alias for set.
+! V8:      error: invalid instruction mnemonic
+! V9: sethi %hi(32768), %g1            ! encoding: [0x03,0b00AAAAAA,A,A]
+! V9:                                  !   fixup A - offset: 0, value: %hi(32768), kind: fixup_sparc_hi22
+setuw 32768, %g1
+! V9: mov 1, %g1 ! encoding: [0x82,0x10,0x20,0x01]
+setuw 1, %g1



More information about the llvm-commits mailing list