From 1bb909a44d2303f88bb05125fc6742e97f80cd1d Mon Sep 17 00:00:00 2001 From: Andrew Gierth Date: Fri, 19 Jun 2020 17:07:34 +0100 Subject: [PATCH 1/4] Fix ARMv7 THUMB encoding for immediates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lightening/arm-cpu.c (encode_thumb_immediate): Fix return value in third case. Signed-off-by: Ludovic Courtès --- lightening/arm-cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightening/arm-cpu.c b/lightening/arm-cpu.c index 4445266af..2b4eecc29 100644 --- a/lightening/arm-cpu.c +++ b/lightening/arm-cpu.c @@ -230,7 +230,7 @@ encode_thumb_immediate(unsigned int v) return ((v & 0xff) | (1 << 12)); /* abcdefgh 00000000 abcdefgh 00000000 */ if (((v & 0xffff0000) >> 16) == (v & 0xffff) && (v & 0xff) == 0) - return ((v & 0x000000ff) | (2 << 12)); + return (((v & 0x0000ff00) >> 8) | (2 << 12)); /* abcdefgh abcdefgh abcdefgh abcdefgh */ if ( (v & 0xff) == ((v & 0xff00) >> 8) && ((v & 0xff00) >> 8) == ((v & 0xff0000) >> 16) && From e3d9bdf03f0ee6440515c473f789fa501012ec76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 20 Jun 2020 16:13:16 +0200 Subject: [PATCH 2/4] tests: Make 'TARGETS' overridable. This allows users to run "make TARGETS=armv7", for instance. * tests/Makefile (TARGETS): Make it overridable. --- tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile b/tests/Makefile index 81279720d..b358a886b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,5 @@ TESTS=$(sort $(basename $(wildcard *.c))) -TARGETS=native ia32 aarch64 armv7 +TARGETS ?= native ia32 aarch64 armv7 # Suitable values of cross-compiler variables for Debian: # From e20ca01d9bfebd6e71f09e4a5bfbf80d44745e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 20 Jun 2020 16:14:10 +0200 Subject: [PATCH 3/4] tests: Remove 'glibc' from the 'guix environment' command line. * tests/Makefile (CC_IA32, CC_AARCH64, CC_ARMv7): Remove 'glibc' from the 'guix environment' command line since it's redundant with 'gcc-toolchain'. --- tests/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index b358a886b..769b43423 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -17,9 +17,9 @@ TARGETS ?= native ia32 aarch64 armv7 # gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6:arm64 # CC = gcc -CC_IA32=guix environment --pure -s i686-linux --ad-hoc gcc-toolchain glibc -- gcc -CC_AARCH64=guix environment --pure -s aarch64-linux --ad-hoc gcc-toolchain glibc -- gcc -CC_ARMv7=guix environment --pure -s armhf-linux --ad-hoc gcc-toolchain glibc -- gcc +CC_IA32=guix environment --pure -s i686-linux --ad-hoc gcc-toolchain -- gcc +CC_AARCH64=guix environment --pure -s aarch64-linux --ad-hoc gcc-toolchain -- gcc +CC_ARMv7=guix environment --pure -s armhf-linux --ad-hoc gcc-toolchain -- gcc CFLAGS = -Wall -O0 -g all: $(foreach TARGET,$(TARGETS),$(addprefix test-$(TARGET)-,$(TESTS))) From 24ef197b1269f8371b1f4a412caa6d2b99d66839 Mon Sep 17 00:00:00 2001 From: "Dale P. Smith" Date: Sat, 20 Jun 2020 16:28:44 +0200 Subject: [PATCH 4/4] Add 'movi' test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a followup to 1bb909a44d2303f88bb05125fc6742e97f80cd1d. It reproduces the bug that 1bb909a44d2303f88bb05125fc6742e97f80cd1d fixes on ARMv7. * tests/movi.c: New file. Co-authored-by: Ludovic Courtès --- tests/movi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/movi.c diff --git a/tests/movi.c b/tests/movi.c new file mode 100644 index 000000000..fcdd656c0 --- /dev/null +++ b/tests/movi.c @@ -0,0 +1,22 @@ +#include "test.h" + +static void +run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size) +{ + jit_begin(j, arena_base, arena_size); + size_t align = jit_enter_jit_abi(j, 0, 0, 0); + + jit_movi(j, JIT_R0, 0xa500a500); + jit_leave_jit_abi(j, 0, 0, align); + jit_retr(j, JIT_R0); + + jit_uword_t (*f)(void) = jit_end(j, NULL); + + ASSERT(f() == 0xa500a500); +} + +int +main (int argc, char *argv[]) +{ + return main_helper(argc, argv, run_test); +}