aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
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 /test/codegen
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 'test/codegen')
-rw-r--r--test/codegen/math.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/codegen/math.go b/test/codegen/math.go
index 04cb4e577d..cd573db7b3 100644
--- a/test/codegen/math.go
+++ b/test/codegen/math.go
@@ -125,9 +125,25 @@ func fma(x, y, z float64) float64 {
// s390x:"FMADD"
// ppc64:"FMADD"
// ppc64le:"FMADD"
+ // riscv64:"FMADDD"
return math.FMA(x, y, z)
}
+func fms(x, y, z float64) float64 {
+ // riscv64:"FMSUBD"
+ return math.FMA(x, y, -z)
+}
+
+func fnma(x, y, z float64) float64 {
+ // riscv64:"FNMADDD"
+ return math.FMA(-x, y, z)
+}
+
+func fnms(x, y, z float64) float64 {
+ // riscv64:"FNMSUBD"
+ return math.FMA(x, -y, -z)
+}
+
func fromFloat64(f64 float64) uint64 {
// amd64:"MOVQ\tX.*, [^X].*"
// arm64:"FMOVD\tF.*, R.*"