aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm/internal
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2023-08-26 04:19:40 +1000
committerJoel Sing <joel@sing.id.au>2023-11-07 10:37:24 +0000
commitdc74a3dd4f30c4a3df235aac8a9e84575767ba69 (patch)
tree94b7cca8caf61a35fae614984edcf627d86dd73c /src/cmd/asm/internal
parent1d9040bf08cf8cda30b203c21de12a4b6ab66153 (diff)
downloadgo-dc74a3dd4f30c4a3df235aac8a9e84575767ba69.tar.xz
cmd/internal/obj/riscv: support subtraction with a constant
Allow SUB and SUBW to be specified with a constant, which are mapped to ADDI and ADDIW with negated values. Change-Id: I7dc55692febc81ea87393b0a3a7d23a43c30313b Reviewed-on: https://go-review.googlesource.com/c/go/+/538915 Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: M Zhuo <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Wang Yaduo <wangyaduo@linux.alibaba.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Diffstat (limited to 'src/cmd/asm/internal')
-rw-r--r--src/cmd/asm/internal/asm/testdata/riscv64.s5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/asm/internal/asm/testdata/riscv64.s b/src/cmd/asm/internal/asm/testdata/riscv64.s
index 2afa457105..072302b225 100644
--- a/src/cmd/asm/internal/asm/testdata/riscv64.s
+++ b/src/cmd/asm/internal/asm/testdata/riscv64.s
@@ -94,6 +94,10 @@ start:
SUB X6, X5, X7 // b3836240
SUB X5, X6 // 33035340
+ SUB $-2047, X5, X6 // 1383f27f
+ SUB $2048, X5, X6 // 13830280
+ SUB $-2047, X5 // 9382f27f
+ SUB $2048, X5 // 93820280
SRA X6, X5, X7 // b3d36240
SRA X5, X6 // 33535340
@@ -157,6 +161,7 @@ start:
ADDW $1, X6 // 1b031300
SLLW $1, X6 // 1b131300
SRLW $1, X6 // 1b531300
+ SUBW $1, X6 // 1b03f3ff
SRAW $1, X6 // 1b531340
// 5.3: Load and Store Instructions (RV64I)