diff --git a/libs/gamecode/pr_exec.c b/libs/gamecode/pr_exec.c index 66b1f3818..852f8f980 100644 --- a/libs/gamecode/pr_exec.c +++ b/libs/gamecode/pr_exec.c @@ -3121,7 +3121,6 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) // 0 1010 OP_cmp(GT, >); // 0 1011 - //FIXME conversion 1 // 0 1100 OP_cmp(NE, !=); // 0 1101 @@ -3300,20 +3299,20 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) OP_op_T (BITXOR, I, int, ivec2, ivec4, ^); OP_uop_T (BITNOT, I, int, ivec2, ivec4, ~); // 1 1001 - OP_op_T (LT, u, uint, uivec2, uivec4, <); + OP_cmp_T (LT, u, int, ivec2, ivec4, <, uint, uivec2, uivec4); case OP_SWIZZLE_F: OPC(ivec4) = pr_swizzle_f (OPA(ivec4), st->b); break; //FIXME scale ops - OP_op_T (LT, U, ulong, ulvec2, ulvec4, <); + OP_cmp_T (LT, U, long, lvec2, lvec4, <, ulong, ulvec2, ulvec4); case OP_SWIZZLE_D: OPC(lvec4) = pr_swizzle_d (OPA(lvec4), st->b); break; //FIXME scale ops // 1 1010 - OP_op_T (GT, u, uint, uivec2, uivec4, >); + OP_cmp_T (GT, u, int, ivec2, ivec4, >, uint, uivec2, uivec4); //FIXME conversion ops - OP_op_T (GT, U, ulong, ulvec2, ulvec4, >); + OP_cmp_T (GT, U, long, lvec2, lvec4, >, ulong, ulvec2, ulvec4); //FIXME conversion ops // 1 1011 case OP_LEA_A: @@ -3415,7 +3414,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) OP_not_3 (NOT, int, 3, +); OP_not_n (NOT, ivec4, 4, +); // 1 1101 - OP_op_T (GE, u, uint, uivec2, uivec4, >=); + OP_cmp_T (GE, u, int, ivec2, ivec4, >=, uint, uivec2, uivec4); case OP_QV4MUL_F: OPC(vec4) = qvmulf (OPA(vec4), OPB(vec4)); break; @@ -3430,7 +3429,7 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) memmove (pr->pr_globals + OPC(int), pr->pr_globals + OPA(int), st->b * sizeof (pr_type_t)); break; - OP_op_T (GE, U, ulong, ulvec2, ulvec4, >=); + OP_cmp_T (GE, U, long, lvec2, lvec4, >=, ulong, ulvec2, ulvec4); case OP_QV4MUL_D: OPC(dvec4) = qvmuld (OPA(dvec4), OPB(dvec4)); break; @@ -3444,12 +3443,12 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) pr_memset (pr->pr_globals + OPC(int), OPA(int), st->b); break; // 1 1110 - OP_op_T (LE, u, uint, uivec2, uivec4, <=); + OP_cmp_T (LE, u, int, ivec2, ivec4, <=, uint, uivec2, uivec4); case OP_V4QMUL_F: OPC(vec4) = vqmulf (OPA(vec4), OPB(vec4)); break; - OP_op_T (LE, U, ulong, ulvec2, ulvec4, <=); + OP_cmp_T (LE, U, long, lvec2, lvec4, <=, ulong, ulvec2, ulvec4); case OP_V4QMUL_D: OPC(dvec4) = vqmuld (OPA(dvec4), OPB(dvec4)); break; diff --git a/libs/gamecode/test/Makemodule.am b/libs/gamecode/test/Makemodule.am index 2df9ef114..af16fe67f 100644 --- a/libs/gamecode/test/Makemodule.am +++ b/libs/gamecode/test/Makemodule.am @@ -4,9 +4,10 @@ libs_gamecode_tests = \ libs/gamecode/test/test-int \ libs/gamecode/test/test-load \ libs/gamecode/test/test-long \ - libs/gamecode/test/test-vector \ libs/gamecode/test/test-stack \ - libs/gamecode/test/test-store + libs/gamecode/test/test-store \ + libs/gamecode/test/test-unsigned \ + libs/gamecode/test/test-vector TESTS += $(libs_gamecode_tests) @@ -57,3 +58,8 @@ libs_gamecode_test_test_vector_SOURCES= \ libs/gamecode/test/test-vector.c libs_gamecode_test_test_vector_LDADD= $(test_gamecode_libs) libs_gamecode_test_test_vector_DEPENDENCIES= $(test_gamecode_libs) + +libs_gamecode_test_test_unsigned_SOURCES= \ + libs/gamecode/test/test-unsigned.c +libs_gamecode_test_test_unsigned_LDADD= $(test_gamecode_libs) +libs_gamecode_test_test_unsigned_DEPENDENCIES= $(test_gamecode_libs) diff --git a/libs/gamecode/test/test-unsigned.c b/libs/gamecode/test/test-unsigned.c new file mode 100644 index 000000000..ffd3959eb --- /dev/null +++ b/libs/gamecode/test/test-unsigned.c @@ -0,0 +1,284 @@ +#include "head.c" + +#include "QF/mathlib.h" + +static pr_uivec4_t uint_cmpop_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}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, +}; + +static pr_uivec4_t uint_cmpop_expect[] = { + { 5, -5, 5, -5}, + { 5, 5, -5, -5}, + { 0, 0, 0, 0}, // no unsigned EQ (redundant) + { 0, 0, -1, 0}, + { 0, -1, 0, 0}, + { 0, 0, 0, 0}, // no unsigned NE (redundant) + { -1, -1, 0, -1}, + { -1, 0, -1, -1}, +}; + +static dstatement_t uint_cmpop_1_statements[] = { + { OP(0, 0, 0, OP_LEA_A), 4, 0, 32 }, // init index +//loop: + { OP(0, 0, 0, OP_LEA_C), 32, -1, 32 }, // dec index + { OP(0, 0, 0, OP_IFAE_A), 2, 0, 32 }, + { OP(0, 0, 0, OP_BREAK), 0, 0, 0 }, + { OP(0, 0, 0, OP_WITH), 4, 32, 1 }, + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_u_1), 0, 4, 12 }, + { OP(1, 1, 1, OP_GT_u_1), 0, 4, 16 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_u_1), 0, 4, 24 }, + { OP(1, 1, 1, OP_LE_u_1), 0, 4, 28 }, + { OP(1, 1, 1, OP_JUMP_A), -8, 0, 0 }, +}; + +static dstatement_t uint_cmpop_2_statements[] = { + { OP(0, 0, 0, OP_LEA_A), 4, 0, 32 }, // index +//loop: + { OP(0, 0, 0, OP_LEA_C), 32, -2, 32 }, // dec index + { OP(0, 0, 0, OP_IFAE_A), 2, 0, 32 }, + { OP(0, 0, 0, OP_BREAK), 0, 0, 0 }, + { OP(0, 0, 0, OP_WITH), 4, 32, 1 }, + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_u_2), 0, 4, 12 }, + { OP(1, 1, 1, OP_GT_u_2), 0, 4, 16 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_u_2), 0, 4, 24 }, + { OP(1, 1, 1, OP_LE_u_2), 0, 4, 28 }, + { OP(1, 1, 1, OP_JUMP_A), -8, 0, 0 }, +}; + +static dstatement_t uint_cmpop_3a_statements[] = { + // no unsigned EQ (redundant) + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_u_3), 0, 4, 12 }, + { OP(1, 1, 1, OP_LT_u_1), 3, 7, 15 }, + { OP(1, 1, 1, OP_GT_u_3), 0, 4, 16 }, + { OP(1, 1, 1, OP_GT_u_1), 3, 7, 19 }, + // no unsigned NE (redundant) + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_u_3), 0, 4, 24 }, + { OP(1, 1, 1, OP_GE_u_1), 3, 7, 27 }, + { OP(1, 1, 1, OP_LE_u_3), 0, 4, 28 }, + { OP(1, 1, 1, OP_LE_u_1), 3, 7, 31 }, +}; + +static dstatement_t uint_cmpop_3b_statements[] = { + // no unsigned EQ (redundant) + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_u_1), 0, 4, 12 }, + { OP(1, 1, 1, OP_LT_u_3), 1, 5, 13 }, + { OP(1, 1, 1, OP_GT_u_1), 0, 4, 16 }, + { OP(1, 1, 1, OP_GT_u_3), 1, 5, 17 }, + // no unsigned NE (redundant) + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_u_1), 0, 4, 24 }, + { OP(1, 1, 1, OP_GE_u_3), 1, 5, 25 }, + { OP(1, 1, 1, OP_LE_u_1), 0, 4, 28 }, + { OP(1, 1, 1, OP_LE_u_3), 1, 5, 29 }, +}; + +static dstatement_t uint_cmpop_4_statements[] = { + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_u_4), 0, 4, 12 }, + { OP(1, 1, 1, OP_GT_u_4), 0, 4, 16 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_u_4), 0, 4, 24 }, + { OP(1, 1, 1, OP_LE_u_4), 0, 4, 28 }, +}; + +static pr_ulvec4_t ulong_cmpop_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}, + { 0, 0, 0, 0}, + { 0, 0, 0, 0}, +}; + +static pr_ulvec4_t ulong_cmpop_expect[] = { + { 5, -5, 5, -5}, + { 5, 5, -5, -5}, + { 0, 0, 0, 0}, // no unsigned EQ (redundant) + { 0, 0, -1, 0}, + { 0, -1, 0, 0}, + { 0, 0, 0, 0}, // no unsigned NE (redundant) + { -1, -1, 0, -1}, + { -1, 0, -1, -1}, +}; + +static dstatement_t ulong_cmpop_1_statements[] = { + { OP(0, 0, 0, OP_LEA_A), 8, 0, 64 }, // init index +//loop: + { OP(0, 0, 0, OP_LEA_C), 64, -2, 64 }, // dec index + { OP(0, 0, 0, OP_IFAE_A), 2, 0, 64 }, + { OP(0, 0, 0, OP_BREAK), 0, 0, 0 }, + { OP(0, 0, 0, OP_WITH), 4, 64, 1 }, + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_U_1), 0, 8, 24 }, + { OP(1, 1, 1, OP_GT_U_1), 0, 8, 32 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_U_1), 0, 8, 48 }, + { OP(1, 1, 1, OP_LE_U_1), 0, 8, 56 }, + { OP(1, 1, 1, OP_JUMP_A), -8, 0, 0 }, +}; + +static dstatement_t ulong_cmpop_2_statements[] = { + { OP(0, 0, 0, OP_LEA_A), 8, 0, 64 }, // init index +//loop: + { OP(0, 0, 0, OP_LEA_C), 64, -4, 64 }, // dec index + { OP(0, 0, 0, OP_IFAE_A), 2, 0, 64 }, + { OP(0, 0, 0, OP_BREAK), 0, 0, 0 }, + { OP(0, 0, 0, OP_WITH), 4, 64, 1 }, + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_U_2), 0, 8, 24 }, + { OP(1, 1, 1, OP_GT_U_2), 0, 8, 32 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_U_2), 0, 8, 48 }, + { OP(1, 1, 1, OP_LE_U_2), 0, 8, 56 }, + { OP(1, 1, 1, OP_JUMP_A), -8, 0, 0 }, +}; + +static dstatement_t ulong_cmpop_3a_statements[] = { + // no unsigned EQ (redundant) + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_U_3), 0, 8, 24 }, + { OP(1, 1, 1, OP_LT_U_1), 6, 14, 30 }, + { OP(1, 1, 1, OP_GT_U_3), 0, 8, 32 }, + { OP(1, 1, 1, OP_GT_U_1), 6, 14, 38 }, + // no unsigned NE (redundant) + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_U_3), 0, 8, 48 }, + { OP(1, 1, 1, OP_GE_U_1), 6, 14, 54 }, + { OP(1, 1, 1, OP_LE_U_3), 0, 8, 56 }, + { OP(1, 1, 1, OP_LE_U_1), 6, 14, 62 }, +}; + +static dstatement_t ulong_cmpop_3b_statements[] = { + // no unsigned EQ (redundant) + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_U_1), 0, 8, 24 }, + { OP(1, 1, 1, OP_LT_U_3), 2, 10, 26 }, + { OP(1, 1, 1, OP_GT_U_1), 0, 8, 32 }, + { OP(1, 1, 1, OP_GT_U_3), 2, 10, 34 }, + // no unsigned NE (redundant) + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_U_1), 0, 8, 48 }, + { OP(1, 1, 1, OP_GE_U_3), 2, 10, 50 }, + { OP(1, 1, 1, OP_LE_U_1), 0, 8, 56 }, + { OP(1, 1, 1, OP_LE_U_3), 2, 10, 58 }, +}; + +static dstatement_t ulong_cmpop_4_statements[] = { + // no unsigned EQ (redundant) + { OP(1, 1, 1, OP_LT_U_4), 0, 8, 24 }, + { OP(1, 1, 1, OP_GT_U_4), 0, 8, 32 }, + // no unsigned NE (redundant) + { OP(1, 1, 1, OP_GE_U_4), 0, 8, 48 }, + { OP(1, 1, 1, OP_LE_U_4), 0, 8, 56 }, +}; + +test_t tests[] = { + { + .desc = "uint cmpop 1", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(uint_cmpop_init,uint_cmpop_expect), + .num_statements = num_statements (uint_cmpop_1_statements), + .statements = uint_cmpop_1_statements, + .init_globals = (pr_int_t *) uint_cmpop_init, + .expect_globals = (pr_int_t *) uint_cmpop_expect, + }, + { + .desc = "uint cmpop 2", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(uint_cmpop_init,uint_cmpop_expect), + .num_statements = num_statements (uint_cmpop_2_statements), + .statements = uint_cmpop_2_statements, + .init_globals = (pr_int_t *) uint_cmpop_init, + .expect_globals = (pr_int_t *) uint_cmpop_expect, + }, + { + .desc = "uint cmpop 3a", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(uint_cmpop_init,uint_cmpop_expect), + .num_statements = num_statements (uint_cmpop_3a_statements), + .statements = uint_cmpop_3a_statements, + .init_globals = (pr_int_t *) uint_cmpop_init, + .expect_globals = (pr_int_t *) uint_cmpop_expect, + }, + { + .desc = "uint cmpop 3b", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(uint_cmpop_init,uint_cmpop_expect), + .num_statements = num_statements (uint_cmpop_3b_statements), + .statements = uint_cmpop_3b_statements, + .init_globals = (pr_int_t *) uint_cmpop_init, + .expect_globals = (pr_int_t *) uint_cmpop_expect, + }, + { + .desc = "uint cmpop 4", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(uint_cmpop_init,uint_cmpop_expect), + .num_statements = num_statements (uint_cmpop_4_statements), + .statements = uint_cmpop_4_statements, + .init_globals = (pr_int_t *) uint_cmpop_init, + .expect_globals = (pr_int_t *) uint_cmpop_expect, + }, + { + .desc = "ulong cmpop 1", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(ulong_cmpop_init,ulong_cmpop_expect), + .num_statements = num_statements (ulong_cmpop_1_statements), + .statements = ulong_cmpop_1_statements, + .init_globals = (pr_int_t *) ulong_cmpop_init, + .expect_globals = (pr_int_t *) ulong_cmpop_expect, + }, + { + .desc = "ulong cmpop 2", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(ulong_cmpop_init,ulong_cmpop_expect), + .num_statements = num_statements (ulong_cmpop_2_statements), + .statements = ulong_cmpop_2_statements, + .init_globals = (pr_int_t *) ulong_cmpop_init, + .expect_globals = (pr_int_t *) ulong_cmpop_expect, + }, + { + .desc = "ulong cmpop 3a", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(ulong_cmpop_init,ulong_cmpop_expect), + .num_statements = num_statements (ulong_cmpop_3a_statements), + .statements = ulong_cmpop_3a_statements, + .init_globals = (pr_int_t *) ulong_cmpop_init, + .expect_globals = (pr_int_t *) ulong_cmpop_expect, + }, + { + .desc = "ulong cmpop 3b", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(ulong_cmpop_init,ulong_cmpop_expect), + .num_statements = num_statements (ulong_cmpop_3b_statements), + .statements = ulong_cmpop_3b_statements, + .init_globals = (pr_int_t *) ulong_cmpop_init, + .expect_globals = (pr_int_t *) ulong_cmpop_expect, + }, + { + .desc = "ulong cmpop 4", + .extra_globals = 4 * 1, + .num_globals = 4*num_globals(ulong_cmpop_init,ulong_cmpop_expect), + .num_statements = num_statements (ulong_cmpop_4_statements), + .statements = ulong_cmpop_4_statements, + .init_globals = (pr_int_t *) ulong_cmpop_init, + .expect_globals = (pr_int_t *) ulong_cmpop_expect, + }, +}; + +#include "main.c"