diff --git a/tests/tcg/e2k/Makefile.target b/tests/tcg/e2k/Makefile.target index 07ed6832c3..816902cf25 100644 --- a/tests/tcg/e2k/Makefile.target +++ b/tests/tcg/e2k/Makefile.target @@ -1,15 +1,23 @@ # -*- Mode: makefile -*- # -# Elbrus 2000 tests - -E2K_SRC=$(SRC_PATH)/tests/tcg/e2k -VPATH+=$(E2K_SRC) - -E2K_TESTS=hello-e2k -TESTS+=$(E2K_TESTS) - +# E2K tests # -# hello-e2k is a barebones app -# -hello-e2k: CFLAGS+=-ffreestanding -hello-e2k: LDFLAGS+=-nostdlib + +E2K_SRC = $(SRC_PATH)/tests/tcg/e2k +E2K_ALL = $(wildcard $(E2K_SRC)/*.s) + +TESTS = $(patsubst $(E2K_SRC)/%.s, %, $(E2K_ALL)) +VPATH = $(E2K_SRC) + +CROSS = e2k-linux- +AS = $(CROSS)as +LD = $(CROSS)ld + +ASFLAGS = -mcpu=elbrus-v4 -g -I$(E2K_SRC) +LDFLAGS = + +%.o: %.s + $(AS) $(ASFLAGS) $< -o $@ + +%: %.o + $(LD) $(LDFLAGS) $< -o $@ diff --git a/tests/tcg/e2k/hello-e2k.c b/tests/tcg/e2k/hello-e2k.c deleted file mode 100644 index 3b42e6d8e7..0000000000 --- a/tests/tcg/e2k/hello-e2k.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -#define MSG "Hello, world!\n" - -void _start(void) { - __E2K_SYSCALL_3(LINUX_SYSCALL64_TRAPNUM, __NR_write, 1, MSG, sizeof(MSG)); - __E2K_SYSCALL_1(LINUX_SYSCALL64_TRAPNUM, __NR_exit, 0); -} diff --git a/tests/tcg/e2k/macros.inc b/tests/tcg/e2k/macros.inc new file mode 100644 index 0000000000..a344192fc9 --- /dev/null +++ b/tests/tcg/e2k/macros.inc @@ -0,0 +1,123 @@ +.set SYSCALL32_TRAPNUM, 0x1 +.set SYSCALL64_TRAPNUM, 0x3 + +.set __NR_exit, 0x1 +.set __NR_write, 0x4 + +.macro e2k_syscall_1 trapnum sysnum v1 +{ + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + sdisp %ctpr1, \trapnum +} +{ + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_2 trapnum sysnum v1 v2 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] +} +{ + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_3 trapnum sysnum v1 v2 v3 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] + addd 0x0, \v3, %b[3] +} +{ + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_4 trapnum sysnum v1 v2 v3 v4 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] + addd 0x0, \v3, %b[3] + addd 0x0, \v4, %b[4] +} +{ + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_5 trapnum sysnum v1 v2 v3 v4 v5 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] + addd 0x0, \v3, %b[3] + addd 0x0, \v4, %b[4] + addd 0x0, \v5, %b[5] +} +{ + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_6 trapnum sysnum v1 v2 v3 v4 v5 v6 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] + addd 0x0, \v3, %b[3] + addd 0x0, \v4, %b[4] + addd 0x0, \v5, %b[5] +} +{ + addd 0x0, \v6, %b[5] + call %ctpr1, wbs = 0x4 +} +.endm + +.macro e2k_syscall_7 trapnum sysnum v1 v2 v3 v4 v5 v6 v7 +{ + sdisp %ctpr1, \trapnum + addd 0x0, \sysnum, %b[0] + addd 0x0, \v1, %b[1] + addd 0x0, \v2, %b[2] + addd 0x0, \v3, %b[3] + addd 0x0, \v4, %b[4] + addd 0x0, \v5, %b[5] +} +{ + addd 0x0, \v6, %b[6] + addd 0x0, \v7, %b[7] + call %ctpr1, wbs = 0x4 +} +.endm + +.macro assert op reg1 reg2 counter_reg +{ + \op \reg1, \reg2, %pred0 + addd 0x0, \counter_reg, %b[0] + disp %ctpr1, _test_fail +} +{ + addd 0x1, \counter_reg, \counter_reg + call %ctpr1, wbs = 0x4 ? ~%pred0 +} +.endm + +_test_fail: +{ + setwd wsz = 0x8, nfx = 0x0, dbl = 0x0 + setbn rsz = 0x3, rbs = 0x4, rcur = 0x0 +} + e2k_syscall_3 SYSCALL64_TRAPNUM, __NR_write, 0, [ _test_failed_str ], _test_failed_strlen + e2k_syscall_1 SYSCALL64_TRAPNUM, __NR_exit, %dr0 diff --git a/tests/tcg/e2k/macros_end.inc b/tests/tcg/e2k/macros_end.inc new file mode 100644 index 0000000000..e13dcd3869 --- /dev/null +++ b/tests/tcg/e2k/macros_end.inc @@ -0,0 +1,6 @@ +_stop: + e2k_syscall_1 SYSCALL64_TRAPNUM, __NR_exit, 0 + +_test_failed_str: + .ascii "TEST FAILED\n\0" + .set _test_failed_strlen, . - _test_failed_str diff --git a/tests/tcg/e2k/test_addd.s b/tests/tcg/e2k/test_addd.s new file mode 100644 index 0000000000..af02eb6b6c --- /dev/null +++ b/tests/tcg/e2k/test_addd.s @@ -0,0 +1,23 @@ +.global _start +.include "macros.inc" + +_start: +{ + setwd wsz=0x8, nfx=1 + setbn rbs=0x4, rsz=0x3, rcur=0 +} +{ + addd 0x0, 0x0, %r0 ! counter + addd 0x2, 0xFFFFFFFFFFFFFFFF, %r1 +} +{ + addd 0x2, 0x2, %r2 + adds 0x2, 0x2, %r3 + adds 0x2, 0xFFFFFFFF, %r4 +} + assert cmpedb, %r1, 0x1, %r0 + assert cmpedb, %r2, 0x4, %r0 + assert cmpesb, %r3, 0x4, %r0 + assert cmpesb, %r4, 0x1, %r0 + +.include "macros_end.inc"