[llvm] [Mips] Add 'j' alias for r6 (PR #196706)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 9 02:19:07 PDT 2026
https://github.com/yingopq created https://github.com/llvm/llvm-project/pull/196706
Fix #107460.
>From d37d1ec3c6bd09a71a9c63fc749708ada8487979 Mon Sep 17 00:00:00 2001
From: Ying Huang <ying.huang at oss.cipunited.com>
Date: Sat, 9 May 2026 17:18:13 +0800
Subject: [PATCH] [Mips] Add 'j' alias for r6
Fix #107460.
---
llvm/lib/Target/Mips/MipsInstrInfo.td | 4 +++-
llvm/test/MC/Mips/j-alias-r6.s | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/MC/Mips/j-alias-r6.s
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 76bfe31534161..fabf812c9d1a8 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -2747,7 +2747,9 @@ let AdditionalPredicates = [NotInMicroMips] in {
def : MipsInstAlias<"bal $offset", (BGEZAL ZERO, brtarget:$offset), 1>,
ISA_MIPS1_NOT_32R6_64R6;
- def : MipsInstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>, ISA_MIPS1;
+ def : MipsInstAlias<"j $rs", (JR GPR32Opnd:$rs), 0>, ISA_MIPS1_NOT_32R6_64R6;
+
+ def : MipsInstAlias<"j $rs", (JALR RA, GPR32Opnd:$rs), 0>, ISA_MIPS32R6;
def : MipsInstAlias<"jalr $rs", (JALR RA, GPR32Opnd:$rs), 0>;
diff --git a/llvm/test/MC/Mips/j-alias-r6.s b/llvm/test/MC/Mips/j-alias-r6.s
new file mode 100644
index 0000000000000..720b4f936cfbd
--- /dev/null
+++ b/llvm/test/MC/Mips/j-alias-r6.s
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple mips-unknown-linux-gnu -show-inst --mcpu=mips32r5 %s \
+# RUN: | FileCheck --check-prefix=R5 %s
+# RUN: llvm-mc -triple mips-unknown-linux-gnu -show-inst --mcpu=mips32r6 %s \
+# RUN: | FileCheck --check-prefix=R6 %s
+
+ .text
+ j $ra
+
+# R5: jr $ra
+# R6: jalr $ra
More information about the llvm-commits
mailing list