mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 19:01:06 +00:00
[gamecode] Add tests for bitops
This commit is contained in:
parent
7cd398d4a7
commit
bffcbfc9fc
2 changed files with 266 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
libs_gamecode_tests = \
|
||||
libs/gamecode/test/test-bitops \
|
||||
libs/gamecode/test/test-conv0 \
|
||||
libs/gamecode/test/test-conv1 \
|
||||
libs/gamecode/test/test-conv2 \
|
||||
|
@ -30,6 +31,11 @@ test_gamecode_libs= \
|
|||
libs/gamecode/libQFgamecode.la \
|
||||
libs/util/libQFutil.la
|
||||
|
||||
libs_gamecode_test_test_bitops_SOURCES= \
|
||||
libs/gamecode/test/test-bitops.c
|
||||
libs_gamecode_test_test_bitops_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_bitops_DEPENDENCIES=$(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv0_SOURCES= \
|
||||
libs/gamecode/test/test-conv0.c
|
||||
libs_gamecode_test_test_conv0_LDADD= $(test_gamecode_libs)
|
||||
|
|
260
libs/gamecode/test/test-bitops.c
Normal file
260
libs/gamecode/test/test-bitops.c
Normal file
|
@ -0,0 +1,260 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t int_bitop_init[] = {
|
||||
{ 5, -5, 5, -5},
|
||||
{ 5, 5, -5, -5},
|
||||
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static pr_ivec4_t int_bitop_expect[] = {
|
||||
{ 5, -5, 5, -5},
|
||||
{ 5, 5, -5, -5},
|
||||
|
||||
{ 5, 1, 1, -5},
|
||||
{ 5, -1, -1, -5},
|
||||
{ 0, -2, -2, 0},
|
||||
{ -6, 4, -6, 4},
|
||||
};
|
||||
|
||||
static dstatement_t int_bitop_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 24 }, // init index
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 24, -1, 24 }, // dec index
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 24 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 24, 1 },
|
||||
|
||||
{ OP(1, 1, 1, OP_BITAND_I_1), 0, 4, 8},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_1), 0, 4, 12},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_1), 0, 4, 16},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_1), 0, 4, 20},
|
||||
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -8, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t int_bitop_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 24 }, // index
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 24, -2, 24 }, // dec index
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 24 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 24, 1 },
|
||||
|
||||
{ OP(1, 1, 1, OP_BITAND_I_2), 0, 4, 8},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_2), 0, 4, 12},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_2), 0, 4, 16},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_2), 0, 4, 20},
|
||||
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -8, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t int_bitop_3a_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_I_3), 0, 4, 8},
|
||||
{ OP(1, 1, 1, OP_BITAND_I_1), 3, 7, 11},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_3), 0, 4, 12},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_1), 3, 7, 15},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_3), 0, 4, 16},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_1), 3, 7, 19},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_3), 0, 4, 20},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_1), 3, 7, 23},
|
||||
};
|
||||
|
||||
static dstatement_t int_bitop_3b_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_I_1), 0, 4, 8},
|
||||
{ OP(1, 1, 1, OP_BITAND_I_3), 1, 5, 9},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_1), 0, 4, 12},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_3), 1, 5, 13},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_1), 0, 4, 16},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_3), 1, 5, 17},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_1), 0, 4, 20},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_3), 1, 5, 21},
|
||||
};
|
||||
|
||||
static dstatement_t int_bitop_4_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_I_4), 0, 4, 8},
|
||||
{ OP(1, 1, 1, OP_BITOR_I_4), 0, 4, 12},
|
||||
{ OP(1, 1, 1, OP_BITXOR_I_4), 0, 4, 16},
|
||||
{ OP(1, 1, 1, OP_BITNOT_I_4), 0, 4, 20},
|
||||
};
|
||||
|
||||
static pr_lvec4_t long_bitop_init[] = {
|
||||
{ 5, -5, 5, -5},
|
||||
{ 5, 5, -5, -5},
|
||||
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static pr_lvec4_t long_bitop_expect[] = {
|
||||
{ 5, -5, 5, -5},
|
||||
{ 5, 5, -5, -5},
|
||||
|
||||
{ 5, 1, 1, -5},
|
||||
{ 5, -1, -1, -5},
|
||||
{ 0, -2, -2, 0},
|
||||
{ -6, 4, -6, 4},
|
||||
};
|
||||
|
||||
static dstatement_t long_bitop_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 48 }, // init index
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 48, -2, 48 }, // dec index
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 48 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 48, 1 },
|
||||
|
||||
{ OP(1, 1, 1, OP_BITAND_L_1), 0, 8, 16},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_1), 0, 8, 24},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_1), 0, 8, 32},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_1), 0, 8, 40},
|
||||
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -8, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t long_bitop_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 48 }, // init index
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 48, -4, 48 }, // dec index
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 48 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 48, 1 },
|
||||
|
||||
{ OP(1, 1, 1, OP_BITAND_L_2), 0, 8, 16},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_2), 0, 8, 24},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_2), 0, 8, 32},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_2), 0, 8, 40},
|
||||
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -8, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t long_bitop_3a_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_L_3), 0, 8, 16},
|
||||
{ OP(1, 1, 1, OP_BITAND_L_1), 6, 14, 22},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_3), 0, 8, 24},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_1), 6, 14, 30},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_3), 0, 8, 32},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_1), 6, 14, 38},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_3), 0, 8, 40},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_1), 6, 14, 46},
|
||||
};
|
||||
|
||||
static dstatement_t long_bitop_3b_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_L_1), 0, 8, 16},
|
||||
{ OP(1, 1, 1, OP_BITAND_L_3), 2, 10, 18},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_1), 0, 8, 24},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_3), 2, 10, 26},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_1), 0, 8, 32},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_3), 2, 10, 34},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_1), 0, 8, 40},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_3), 2, 10, 42},
|
||||
};
|
||||
|
||||
static dstatement_t long_bitop_4_statements[] = {
|
||||
{ OP(1, 1, 1, OP_BITAND_L_4), 0, 8, 16},
|
||||
{ OP(1, 1, 1, OP_BITOR_L_4), 0, 8, 24},
|
||||
{ OP(1, 1, 1, OP_BITXOR_L_4), 0, 8, 32},
|
||||
{ OP(1, 1, 1, OP_BITNOT_L_4), 0, 8, 40},
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "int bitop 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(int_bitop_init,int_bitop_expect),
|
||||
.num_statements = num_statements (int_bitop_1_statements),
|
||||
.statements = int_bitop_1_statements,
|
||||
.init_globals = (pr_int_t *) int_bitop_init,
|
||||
.expect_globals = (pr_int_t *) int_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "int bitop 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(int_bitop_init,int_bitop_expect),
|
||||
.num_statements = num_statements (int_bitop_2_statements),
|
||||
.statements = int_bitop_2_statements,
|
||||
.init_globals = (pr_int_t *) int_bitop_init,
|
||||
.expect_globals = (pr_int_t *) int_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "int bitop 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(int_bitop_init,int_bitop_expect),
|
||||
.num_statements = num_statements (int_bitop_3a_statements),
|
||||
.statements = int_bitop_3a_statements,
|
||||
.init_globals = (pr_int_t *) int_bitop_init,
|
||||
.expect_globals = (pr_int_t *) int_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "int bitop 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(int_bitop_init,int_bitop_expect),
|
||||
.num_statements = num_statements (int_bitop_3b_statements),
|
||||
.statements = int_bitop_3b_statements,
|
||||
.init_globals = (pr_int_t *) int_bitop_init,
|
||||
.expect_globals = (pr_int_t *) int_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "int bitop 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(int_bitop_init,int_bitop_expect),
|
||||
.num_statements = num_statements (int_bitop_4_statements),
|
||||
.statements = int_bitop_4_statements,
|
||||
.init_globals = (pr_int_t *) int_bitop_init,
|
||||
.expect_globals = (pr_int_t *) int_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long bitop 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(long_bitop_init,long_bitop_expect),
|
||||
.num_statements = num_statements (long_bitop_1_statements),
|
||||
.statements = long_bitop_1_statements,
|
||||
.init_globals = (pr_int_t *) long_bitop_init,
|
||||
.expect_globals = (pr_int_t *) long_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long bitop 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(long_bitop_init,long_bitop_expect),
|
||||
.num_statements = num_statements (long_bitop_2_statements),
|
||||
.statements = long_bitop_2_statements,
|
||||
.init_globals = (pr_int_t *) long_bitop_init,
|
||||
.expect_globals = (pr_int_t *) long_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long bitop 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(long_bitop_init,long_bitop_expect),
|
||||
.num_statements = num_statements (long_bitop_3a_statements),
|
||||
.statements = long_bitop_3a_statements,
|
||||
.init_globals = (pr_int_t *) long_bitop_init,
|
||||
.expect_globals = (pr_int_t *) long_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long bitop 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(long_bitop_init,long_bitop_expect),
|
||||
.num_statements = num_statements (long_bitop_3b_statements),
|
||||
.statements = long_bitop_3b_statements,
|
||||
.init_globals = (pr_int_t *) long_bitop_init,
|
||||
.expect_globals = (pr_int_t *) long_bitop_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long bitop 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = num_globals(long_bitop_init,long_bitop_expect),
|
||||
.num_statements = num_statements (long_bitop_4_statements),
|
||||
.statements = long_bitop_4_statements,
|
||||
.init_globals = (pr_int_t *) long_bitop_init,
|
||||
.expect_globals = (pr_int_t *) long_bitop_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
Loading…
Reference in a new issue