Hexagon (tests/tcg/hexagon) Add v73 scalar tests
Tests added for the following instructions J2_callrh J2_jumprh Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Reviewed-by: Anton Johansson <anjo@rev.ng> Message-Id: <20230427224057.3766963-10-tsimpson@quicinc.com>
This commit is contained in:
parent
59958d8903
commit
4dd311ed2e
|
@ -79,6 +79,7 @@ HEX_TESTS += test_vspliceb
|
||||||
HEX_TESTS += v68_scalar
|
HEX_TESTS += v68_scalar
|
||||||
HEX_TESTS += v68_hvx
|
HEX_TESTS += v68_hvx
|
||||||
HEX_TESTS += v69_hvx
|
HEX_TESTS += v69_hvx
|
||||||
|
HEX_TESTS += v73_scalar
|
||||||
|
|
||||||
TESTS += $(HEX_TESTS)
|
TESTS += $(HEX_TESTS)
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ v68_hvx: v68_hvx.c hvx_misc.h v6mpy_ref.c.inc
|
||||||
v68_hvx: CFLAGS += -mhvx -Wno-unused-function
|
v68_hvx: CFLAGS += -mhvx -Wno-unused-function
|
||||||
v69_hvx: v69_hvx.c hvx_misc.h
|
v69_hvx: v69_hvx.c hvx_misc.h
|
||||||
v69_hvx: CFLAGS += -mhvx -Wno-unused-function
|
v69_hvx: CFLAGS += -mhvx -Wno-unused-function
|
||||||
|
v73_scalar: CFLAGS += -Wno-unused-function
|
||||||
|
|
||||||
hvx_histogram: hvx_histogram.c hvx_histogram_row.S
|
hvx_histogram: hvx_histogram.c hvx_histogram_row.S
|
||||||
$(CC) $(CFLAGS) $(CROSS_CC_GUEST_CFLAGS) $^ -o $@ $(LDFLAGS)
|
$(CC) $(CFLAGS) $(CROSS_CC_GUEST_CFLAGS) $^ -o $@ $(LDFLAGS)
|
||||||
|
|
96
tests/tcg/hexagon/v73_scalar.c
Normal file
96
tests/tcg/hexagon/v73_scalar.c
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test the scalar core instructions that are new in v73
|
||||||
|
*/
|
||||||
|
|
||||||
|
int err;
|
||||||
|
|
||||||
|
static void __check32(int line, uint32_t result, uint32_t expect)
|
||||||
|
{
|
||||||
|
if (result != expect) {
|
||||||
|
printf("ERROR at line %d: 0x%08x != 0x%08x\n",
|
||||||
|
line, result, expect);
|
||||||
|
err++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define check32(RES, EXP) __check32(__LINE__, RES, EXP)
|
||||||
|
|
||||||
|
static void __check64(int line, uint64_t result, uint64_t expect)
|
||||||
|
{
|
||||||
|
if (result != expect) {
|
||||||
|
printf("ERROR at line %d: 0x%016llx != 0x%016llx\n",
|
||||||
|
line, result, expect);
|
||||||
|
err++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define check64(RES, EXP) __check64(__LINE__, RES, EXP)
|
||||||
|
|
||||||
|
static bool my_func_called;
|
||||||
|
|
||||||
|
static void my_func(void)
|
||||||
|
{
|
||||||
|
my_func_called = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void callrh(void *func)
|
||||||
|
{
|
||||||
|
asm volatile("callrh %0\n\t"
|
||||||
|
: : "r"(func)
|
||||||
|
/* Mark the caller-save registers as clobbered */
|
||||||
|
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
|
||||||
|
"r10", "r11", "r12", "r13", "r14", "r15", "r28",
|
||||||
|
"p0", "p1", "p2", "p3");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_callrh(void)
|
||||||
|
{
|
||||||
|
my_func_called = false;
|
||||||
|
callrh(&my_func);
|
||||||
|
check32(my_func_called, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_jumprh(void)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
asm ("%0 = #5\n\t"
|
||||||
|
"r0 = ##1f\n\t"
|
||||||
|
"jumprh r0\n\t"
|
||||||
|
"%0 = #3\n\t"
|
||||||
|
"jump 2f\n\t"
|
||||||
|
"1:\n\t"
|
||||||
|
"%0 = #1\n\t"
|
||||||
|
"2:\n\t"
|
||||||
|
: "=r"(res) : : "r0");
|
||||||
|
check32(res, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_callrh();
|
||||||
|
test_jumprh();
|
||||||
|
|
||||||
|
puts(err ? "FAIL" : "PASS");
|
||||||
|
return err ? 1 : 0;
|
||||||
|
}
|
Loading…
Reference in a new issue