diff --git a/.drone.yml b/.drone.yml index de83251..55c081b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -178,6 +178,61 @@ environment: workspace: path: /drone/src +steps: + - name: test + image: golang:1.22-alpine3.19 + commands: + - apk update + - apk add --no-cache git + - go test -tags purego -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -short -v . + - +--- +kind: pipeline +type: docker +name: go-arm-asm +platform: + os: linux + arch: arm64 + +environment: + GOPROXY: direct + GOARCH: arm + GOARM: 7 + GOOS: linux + GOTRACEBACK: 2 + GOEXPERIMENT: "cgocheck2,newinliner" + CGO_ENABLED: "0" + +workspace: + path: /drone/src + +steps: + - name: test + image: golang:1.22-alpine3.19 + commands: + - apk update + - apk add --no-cache git + - go test -p 1 -failfast -timeout 20m -cover -gcflags=-d=checkptr -short -v . +--- +kind: pipeline +type: docker +name: go-arm-purego +platform: + os: linux + arch: arm64 + +environment: + GOPROXY: direct + GOARCH: arm + GOARM: 7 + GOOS: linux + GOTRACEBACK: 2 + GOEXPERIMENT: "cgocheck2,newinliner" + CGO_ENABLED: "0" + +workspace: + path: /drone/src + steps: - name: test image: golang:1.22-alpine3.19 diff --git a/README.md b/README.md index 8eccf55..b844da4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ For the C++ implementation and design of RandomX, see [github.com/tevador/Random |:---------------------:|:----------:|:--------------:|:------:|:----------:|:------:|:------:|:-------:|:------:| | purego | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Full Mode | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ❌ | -| Float Operations | hw | **hw** | soft | **hw** | soft | soft | soft | soft | +| Float Operations | hw | **hw** | **hw** | **hw** | soft | soft | soft | soft | | AES Operations | soft | **hw** | soft | soft | soft | soft | soft | soft | | Superscalar Execution | native | **native+jit** | native | native | native | native | native | native | | VM Execution | **native** | **native+jit** | soft | **native** | soft | soft | soft | soft | diff --git a/internal/asm/round_arm.go b/internal/asm/round_arm.go new file mode 100644 index 0000000..382b345 --- /dev/null +++ b/internal/asm/round_arm.go @@ -0,0 +1,23 @@ +//go:build (arm.6 || arm.7) && !purego + +package asm + +// GetFPSCR returns the value of FPSCR register. +func getFPSCR() (value uint32) + +// SetFPSCR writes the FPSCR value. +func setFPSCR(value uint32) + +func setRoundingMode(mode uint8) { + switch mode { + // switch plus/minus infinity + case 1: + mode = 2 + case 2: + mode = 1 + + } + fpscr := getFPSCR() + fpscr = (fpscr & (^uint32(0x0C00000))) | ((uint32(mode) & 3) << 22) + setFPSCR(fpscr) +} diff --git a/internal/asm/round_arm.s b/internal/asm/round_arm.s new file mode 100644 index 0000000..3e4ad91 --- /dev/null +++ b/internal/asm/round_arm.s @@ -0,0 +1,13 @@ +//go:build (arm.6 || arm.7) && !purego + +#include "textflag.h" + +TEXT ·getFPSCR(SB),NOSPLIT,$0-4 + WORD $0xeef1ba10 // vmrs r11, fpscr + MOVW R11, value+0(FP) + RET + +TEXT ·setFPSCR(SB),NOSPLIT,$0-4 + MOVW value+0(FP), R11 + WORD $0xeee1ba10 // vmsr fpscr, r11 + RET diff --git a/internal/asm/round_noasm.go b/internal/asm/round_noasm.go index e259c7d..69bb481 100644 --- a/internal/asm/round_noasm.go +++ b/internal/asm/round_noasm.go @@ -1,4 +1,4 @@ -//go:build (!arm64 && !amd64 && !386) || purego +//go:build (!arm64 && !(arm.6 || arm.7) && !amd64 && !386) || purego package asm diff --git a/vm_bytecode_native.go b/vm_bytecode_native.go index 97bc865..ac22e7a 100644 --- a/vm_bytecode_native.go +++ b/vm_bytecode_native.go @@ -1,4 +1,4 @@ -//go:build (arm64 || amd64 || 386) && !purego +//go:build (arm64 || arm.6 || arm.7 || amd64 || 386) && !purego package randomx diff --git a/vm_bytecode_purego.go b/vm_bytecode_purego.go index 65e6988..21683e3 100644 --- a/vm_bytecode_purego.go +++ b/vm_bytecode_purego.go @@ -1,4 +1,4 @@ -//go:build (!arm64 && !amd64 && !386) || purego +//go:build (!arm64 && !(arm.6 || arm.7) && !amd64 && !386) || purego package randomx