aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm
diff options
context:
space:
mode:
authorMichael Munday <mike.munday@lowrisc.org>2021-02-17 15:00:34 +0000
committerMichael Munday <mike.munday@lowrisc.org>2021-09-01 21:17:04 +0000
commitea51e223c28babc530df475497de0be4579b5e86 (patch)
tree89b32b7b4577614d24cff4d7b8b5a206b14c9e99 /src/cmd/asm
parent711e1c8224f033ec1d95cdf84465b57b052e8948 (diff)
downloadgo-ea51e223c28babc530df475497de0be4579b5e86.tar.xz
cmd/{asm,compile}: add fused multiply-add support on riscv64
Add support to the assembler for F[N]M{ADD,SUB}[SD] instructions. Argument order is: OP RS1, RS2, RS3, RD Also, add support for the FMA intrinsic to the compiler. Automatic FMA matching is left to a future CL. Change-Id: I47166c7393b2ab6bfc2e42aa8c1a8997c3a071b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/293030 Trust: Michael Munday <mike.munday@lowrisc.org> Run-TryBot: Michael Munday <mike.munday@lowrisc.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au>
Diffstat (limited to 'src/cmd/asm')
-rw-r--r--src/cmd/asm/internal/asm/asm.go7
-rw-r--r--src/cmd/asm/internal/asm/testdata/riscv64.s8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go
index cf0d1550f9..d0cb6328f1 100644
--- a/src/cmd/asm/internal/asm/asm.go
+++ b/src/cmd/asm/internal/asm/asm.go
@@ -793,6 +793,13 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
return
}
}
+ if p.arch.Family == sys.RISCV64 {
+ prog.From = a[0]
+ prog.Reg = p.getRegister(prog, op, &a[1])
+ prog.SetRestArgs([]obj.Addr{a[2]})
+ prog.To = a[3]
+ break
+ }
if p.arch.Family == sys.S390X {
if a[1].Type != obj.TYPE_REG {
p.errorf("second operand must be a register in %s instruction", op)
diff --git a/src/cmd/asm/internal/asm/testdata/riscv64.s b/src/cmd/asm/internal/asm/testdata/riscv64.s
index 628a8d91cd..173c50f2e1 100644
--- a/src/cmd/asm/internal/asm/testdata/riscv64.s
+++ b/src/cmd/asm/internal/asm/testdata/riscv64.s
@@ -214,6 +214,10 @@ start:
FMVSX X5, F0 // 538002f0
FMVXW F0, X5 // d30200e0
FMVWX X5, F0 // 538002f0
+ FMADDS F1, F2, F3, F4 // 43822018
+ FMSUBS F1, F2, F3, F4 // 47822018
+ FNMSUBS F1, F2, F3, F4 // 4b822018
+ FNMADDS F1, F2, F3, F4 // 4f822018
// 11.8: Single-Precision Floating-Point Compare Instructions
FEQS F0, F1, X7 // d3a300a0
@@ -254,6 +258,10 @@ start:
FSGNJXD F1, F0, F2 // 53211022
FMVXD F0, X5 // d30200e2
FMVDX X5, F0 // 538002f2
+ FMADDD F1, F2, F3, F4 // 4382201a
+ FMSUBD F1, F2, F3, F4 // 4782201a
+ FNMSUBD F1, F2, F3, F4 // 4b82201a
+ FNMADDD F1, F2, F3, F4 // 4f82201a
// 12.6: Double-Precision Floating-Point Classify Instruction
FCLASSD F0, X5 // d31200e2