Skip to content

Commit

Permalink
target/hexagon: import additional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Di Federico <ale@rev.ng>
Signed-off-by: Niccolò Izzo <nizzo@rev.ng>
Signed-off-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Message-Id: <20220923173831.227551-12-anjo@rev.ng>
  • Loading branch information
Niccolò Izzo authored and taylorsimpson committed Dec 16, 2022
1 parent e71fdc4 commit 585a86b
Show file tree
Hide file tree
Showing 27 changed files with 766 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/tcg/hexagon/Makefile.target
Expand Up @@ -24,7 +24,7 @@ CFLAGS += -fno-unroll-loops
HEX_SRC=$(SRC_PATH)/tests/tcg/hexagon
VPATH += $(HEX_SRC)

first: $(HEX_SRC)/first.S
%: $(HEX_SRC)/%.S $(HEX_SRC)/crt.S
$(CC) -static -mv67 -nostdlib $^ -o $@

HEX_TESTS = first
Expand All @@ -44,6 +44,32 @@ HEX_TESTS += atomics
HEX_TESTS += fpstuff
HEX_TESTS += overflow

HEX_TESTS += test_abs
HEX_TESTS += test_bitcnt
HEX_TESTS += test_bitsplit
HEX_TESTS += test_call
HEX_TESTS += test_clobber
HEX_TESTS += test_cmp
HEX_TESTS += test_dotnew
HEX_TESTS += test_ext
HEX_TESTS += test_fibonacci
HEX_TESTS += test_hl
HEX_TESTS += test_hwloops
HEX_TESTS += test_jmp
HEX_TESTS += test_lsr
HEX_TESTS += test_mpyi
HEX_TESTS += test_packet
HEX_TESTS += test_reorder
HEX_TESTS += test_round
HEX_TESTS += test_vavgw
HEX_TESTS += test_vcmpb
HEX_TESTS += test_vcmpw
HEX_TESTS += test_vlsrw
HEX_TESTS += test_vmaxh
HEX_TESTS += test_vminh
HEX_TESTS += test_vpmpyh
HEX_TESTS += test_vspliceb

TESTS += $(HEX_TESTS)

# This test has to be compiled for the -mv67t target
Expand Down
14 changes: 14 additions & 0 deletions tests/tcg/hexagon/crt.S
@@ -0,0 +1,14 @@
#define SYS_exit_group 94

.text
.globl pass
pass:
r0 = #0
r6 = #SYS_exit_group
trap0(#1)

.globl fail
fail:
r0 = #1
r6 = #SYS_exit_group
trap0(#1)
17 changes: 17 additions & 0 deletions tests/tcg/hexagon/test_abs.S
@@ -0,0 +1,17 @@
/* Purpose: test example, verify the soundness of the abs operation */

.text
.globl _start

_start:
{
r1 = #-2
r2 = #2
}
{
r3 = abs(r1)
}
{
p0 = cmp.eq(r3, r2); if (p0.new) jump:t pass
jump fail
}
40 changes: 40 additions & 0 deletions tests/tcg/hexagon/test_bitcnt.S
@@ -0,0 +1,40 @@
/*
* Purpose: test example, verify the soundness of the cl[01] operations.
*
* The number 0x000001aa has 23 leading zeroes
* they become 55 when considered as 64 bit register
* and it has 1 trailing zero.
*/
.text
.globl _start

_start:
{
r0 = #426
r1 = #0
}
{
r2 = cl0(r0)
}
{
p0 = cmp.eq(r2, #23); if (p0.new) jump:t test2
jump fail
}

test2:
{
r2 = cl0(r1:0)
}
{
p0 = cmp.eq(r2, #55); if (p0.new) jump:t test3
jump fail
}

test3:
{
r2 = ct0(r0)
}
{
p0 = cmp.eq(r2, #1); if (p0.new) jump:t pass
jump fail
}
22 changes: 22 additions & 0 deletions tests/tcg/hexagon/test_bitsplit.S
@@ -0,0 +1,22 @@
/* Purpose: test example, verify the soundness of the bitsplit operation */

.text
.globl _start

_start:
{
r1 = #187
}
{
r3:2 = bitsplit(r1, #3)
}
{
p0 = cmp.eq(r2, #3); if (p0.new) jump:t test2
jump fail
}

test2:
{
p0 = cmp.eq(r3, #23); if (p0.new) jump:t pass
jump fail
}
64 changes: 64 additions & 0 deletions tests/tcg/hexagon/test_call.S
@@ -0,0 +1,64 @@
/*
* Purpose: test function calls and duplex instructions.
* The string "Hello there, I'm a test string!" with the first letter replaced
* with a capital L should be printed out.
*/

#define SYS_write 64
#define FD_STDOUT 1

.text
.globl test
test:
{
jumpr r31
memb(r0+#0) = #76
}
.Lfunc_end0:
.Ltmp0:
.size test, .Ltmp0-test

.globl _start
_start:
{
r0 = ##dummy_buffer
allocframe(#0)
call test
}
{
call write
}
{
deallocframe
jump pass
}
.Lfunc_end1:
.Ltmp1:
.size _start, .Ltmp1-_start

write:
{
r6 = #SYS_write
r0 = #FD_STDOUT
r1 = ##dummy_buffer
r2 = #33
}
{
trap0(#1)
}
{
jumpr r31
}

.Lfunc_end2:
.Ltmp2:
.size write, .Ltmp2-write

.type dummy_buffer,@object
.data
.globl dummy_buffer
.p2align 3
dummy_buffer:
.string "Hello there, I'm a test string!\n"
.space 223
.size dummy_buffer, 256
29 changes: 29 additions & 0 deletions tests/tcg/hexagon/test_clobber.S
@@ -0,0 +1,29 @@
/*
* Purpose: demonstrate the succesful operation of the register save mechanism,
* in which the caller saves the registers that will be clobbered, and restores
* them after the call.
*/

.text
.globl _start

_start:
allocframe(#8)
{
r16 = #47
r17 = #155
}
memd(sp+#0) = r17:16
{
r16 = #255
r17 = #42
}
{
deallocframe
r17:16 = memd(sp+#0)
}
{
p0 = cmp.eq(r16, #47)
p0 = cmp.eq(r17, #155); if (p0.new) jump:t pass
jump fail
}
31 changes: 31 additions & 0 deletions tests/tcg/hexagon/test_cmp.S
@@ -0,0 +1,31 @@
/* Purpose: test a signed and unsigned comparison */

.text
.globl _start

_start:
{
jump signed
}

.globl signed
signed:
{
r0 = #-2
r1 = #0
}
{
p0 = cmp.lt(r0, r1); if (p0.new) jump:t unsigned
jump fail
}

.globl unsigned
unsigned:
{
r0 = #-2
r1 = #0
}
{
p0 = cmp.gtu(r0, r1); if (p0.new) jump:t pass
jump fail
}
38 changes: 38 additions & 0 deletions tests/tcg/hexagon/test_dotnew.S
@@ -0,0 +1,38 @@
/* Purpose: test the .new operator while performing memory stores. */

.text
.globl _start

_start:
{
allocframe(#16)
}
{
r0 = #1
memw(sp+#0) = r0.new
}
{
r1 = #2
memw(sp+#4) = r1.new
}
{
r2 = #3
memw(sp+#8) = r2.new
}
{
r0 = memw(sp+#8)
}
{
r1 = memw(sp+#4)
}
{
r2 = memw(sp+#0)
}
{
r3 = mpyi(r1, r2)
}
{
deallocframe
p0 = cmp.eq(r3, #2); if (p0.new) jump:t pass
jump fail
}
13 changes: 13 additions & 0 deletions tests/tcg/hexagon/test_ext.S
@@ -0,0 +1,13 @@
/* Purpose: test immediate extender instructions. */

.text
.globl _start

_start:
{
r2 = ##-559038737
}
{
p0 = cmp.eq(r2, ##-559038737); if (p0.new) jump:t pass
jump fail
}
30 changes: 30 additions & 0 deletions tests/tcg/hexagon/test_fibonacci.S
@@ -0,0 +1,30 @@
/* Purpose: computes the Fibonacci series up to a constant number. */

.text
.globl _start

_start:
{
r2 = #100
}
{
p0 = cmp.gt(r2, #0); if (!p0.new) jump:nt .LBB0_3
}
{
r3 = #0
r4 = #1
}
.LBB0_2:
{
r5 = r4
}
{
p0 = cmp.gt(r2, r5); if (p0.new) jump:nt .LBB0_2
r4 = add(r3, r4)
r3 = r5
}
.LBB0_3:
{
p0 = cmp.eq(r3, #144); if (p0.new) jump:t pass
jump fail
}
16 changes: 16 additions & 0 deletions tests/tcg/hexagon/test_hl.S
@@ -0,0 +1,16 @@
/* Purpose: test example, verify the soundness of the high/low assignment */

.text
.globl _start

_start:
{
r0.H = #42
}
{
r0.L = #69
}
{
p0 = cmp.eq(r0, #2752581); if (p0.new) jump:t pass
jump fail
}
19 changes: 19 additions & 0 deletions tests/tcg/hexagon/test_hwloops.S
@@ -0,0 +1,19 @@
/* Purpose: simple C Program to test hardware loops. */

.text
.globl _start

_start:
{
loop0(.LBB0_1, #10)
r2 = #0
}
.LBB0_1:
{
r2 = add(r2, #1)
nop
}:endloop0
{
p0 = cmp.eq(r2, #10); if (p0.new) jump:t pass
jump fail
}

0 comments on commit 585a86b

Please sign in to comment.