mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 09:51:41 +00:00
[gamecode] Add test for conversions to double
And fix an incorrect base index in the bool64 tests.
This commit is contained in:
parent
1f73b26d24
commit
a1c1c9fcf0
3 changed files with 212 additions and 7 deletions
|
@ -2,6 +2,7 @@ libs_gamecode_tests = \
|
|||
libs/gamecode/test/test-conv0 \
|
||||
libs/gamecode/test/test-conv1 \
|
||||
libs/gamecode/test/test-conv2 \
|
||||
libs/gamecode/test/test-conv3 \
|
||||
libs/gamecode/test/test-conv4 \
|
||||
libs/gamecode/test/test-conv5 \
|
||||
libs/gamecode/test/test-conv6 \
|
||||
|
@ -41,6 +42,11 @@ libs_gamecode_test_test_conv2_SOURCES= \
|
|||
libs_gamecode_test_test_conv2_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv2_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv3_SOURCES= \
|
||||
libs/gamecode/test/test-conv3.c
|
||||
libs_gamecode_test_test_conv3_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv3_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv4_SOURCES= \
|
||||
libs/gamecode/test/test-conv4.c
|
||||
libs_gamecode_test_test_conv4_LDADD= $(test_gamecode_libs)
|
||||
|
|
199
libs/gamecode/test/test-conv3.c
Normal file
199
libs/gamecode/test/test-conv3.c
Normal file
|
@ -0,0 +1,199 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t double_conv_init[] = {
|
||||
{ 5, -5, 0x80000000, 0x7fffffff}, //int
|
||||
{ 0x3fc00000, 0xbfc00000, 0x7149f2ca, 0xf149f2ca}, //float 1e30, -1e30
|
||||
{ 99, 0x80000000, 0x80000000, 99}, //long
|
||||
{ 256, 0, 0x7fffffff, 0}, //long
|
||||
{ 0x39a08cea, 0x46293e59, 0x39a08cea, 0xc6293e59}, //double 1e30, -1e30
|
||||
{ 0, 0x3ff80000, 0, 0xbff80000}, //double 1.5, -1.5
|
||||
{ 5, -5, 0x80000000, 0x7fffffff}, //uint
|
||||
{ ~0, 1, 0x80000000, 0}, //bool32
|
||||
{ 99, 0x80000000, 0x80000000, 99}, //ulong
|
||||
{ 256, 0, 0x7fffffff, 0}, //ulong
|
||||
{ ~0, ~0, ~0, 0}, //bool64
|
||||
{ 0, ~0, 0, 0}, //bool64
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0},
|
||||
{ 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_ivec4_t double_conv_expect[] = {
|
||||
{ 5, -5, 0x80000000, 0x7fffffff}, //int
|
||||
{ 0x3fc00000, 0xbfc00000, 0x7149f2ca, 0xf149f2ca}, //float
|
||||
{ 99, 0x80000000, 0x80000000, 99}, //long
|
||||
{ 256, 0, 0x7fffffff, 0}, //long
|
||||
{ 0x39a08cea, 0x46293e59, 0x39a08cea, 0xc6293e59}, //double 1e30, -1e30
|
||||
{ 0, 0x3ff80000, 0, 0xbff80000}, //double 1.5, -1.5
|
||||
{ 5, -5, 0x80000000, 0x7fffffff}, //uint
|
||||
{ ~0, 1, 0x80000000, 0}, //bool32
|
||||
{ 99, 0x80000000, 0x80000000, 99}, //ulong
|
||||
{ 256, 0, 0x7fffffff, 0}, //ulong
|
||||
{ ~0, ~0, ~0, 0}, //bool64
|
||||
{ 0, ~0, 0, 0}, //bool64
|
||||
{ 0x00000000, 0x40140000, 0x00000000, 0xc0140000}, // int
|
||||
{ 0x00000000, 0xc1e00000, 0xffc00000, 0x41dfffff},
|
||||
{ 0x00000000, 0x3ff80000, 0x00000000, 0xbff80000}, // float
|
||||
{ 0x40000000, 0x46293e59, 0x40000000, 0xc6293e59},
|
||||
{ 0x00000000, 0xc3e00000, 0x00000000, 0x4258e000}, // long
|
||||
{ 0x00000000, 0x40700000, 0xffc00000, 0x41dfffff},
|
||||
{ 0, 0, 0, 0}, // double
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0x00000000, 0x40140000, 0xff600000, 0x41efffff}, // uint
|
||||
{ 0x00000000, 0x41e00000, 0xffc00000, 0x41dfffff},
|
||||
{ 0x00000000, 0x3ff00000, 0x00000000, 0x3ff00000}, // bool32
|
||||
{ 0x00000000, 0x3ff00000, 0x00000000, 0x00000000},
|
||||
{ 0x00000000, 0x43e00000, 0x00000000, 0x4258e000}, // long
|
||||
{ 0x00000000, 0x40700000, 0xffc00000, 0x41dfffff},
|
||||
{ 0x00000000, 0x3ff00000, 0x00000000, 0x3ff00000}, // bool64
|
||||
{ 0x00000000, 0x3ff00000, 0x00000000, 0x00000000},
|
||||
};
|
||||
|
||||
static dstatement_t double_conv_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 112 }, // init index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 113 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 112, -1, 112 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 113, -2, 113 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 112 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 112, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 113, 2 },
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0003, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0013, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0023, 64 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0043, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0053, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0063, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0073, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t double_conv_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 112 }, // index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 113 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 112, -2, 112 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 113, -4, 113 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 112 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 112, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 113, 2 },
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0103, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0113, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0123, 64 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0143, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0153, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0163, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0173, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t double_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0203, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 3, 0003, 54 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0213, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 7, 0013, 62 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0223, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 14, 0023, 70 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0243, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 27, 0043, 86 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0253, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 31, 0053, 94 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0263, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 38, 0063, 102 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0273, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 46, 0073, 110 },
|
||||
};
|
||||
|
||||
static dstatement_t double_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0003, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 1, 0203, 50 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0013, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 5, 0213, 58 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0023, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 10, 0223, 66 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0043, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 25, 0243, 82 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0053, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 29, 0253, 90 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0063, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 34, 0263, 98 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0073, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 42, 0273, 106 },
|
||||
};
|
||||
|
||||
static dstatement_t double_conv_4_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0303, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0313, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0323, 64 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0343, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0353, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0363, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0373, 104 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "double conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(double_conv_init,double_conv_expect),
|
||||
.num_statements = num_statements (double_conv_1_statements),
|
||||
.statements = double_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) double_conv_init,
|
||||
.expect_globals = (pr_int_t *) double_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "double conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(double_conv_init,double_conv_expect),
|
||||
.num_statements = num_statements (double_conv_2_statements),
|
||||
.statements = double_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) double_conv_init,
|
||||
.expect_globals = (pr_int_t *) double_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "double conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(double_conv_init,double_conv_expect),
|
||||
.num_statements = num_statements (double_conv_3a_statements),
|
||||
.statements = double_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) double_conv_init,
|
||||
.expect_globals = (pr_int_t *) double_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "double conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(double_conv_init,double_conv_expect),
|
||||
.num_statements = num_statements (double_conv_3b_statements),
|
||||
.statements = double_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) double_conv_init,
|
||||
.expect_globals = (pr_int_t *) double_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "double conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(double_conv_init,double_conv_expect),
|
||||
.num_statements = num_statements (double_conv_4_statements),
|
||||
.statements = double_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) double_conv_init,
|
||||
.expect_globals = (pr_int_t *) double_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
|
@ -76,7 +76,7 @@ static dstatement_t bool64_conv_1_statements[] = {
|
|||
{ OP(0, 0, 0, OP_WITH), 4, 113, 2 },
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0007, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0017, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 8, 0027, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0027, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0037, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0047, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0057, 88 },
|
||||
|
@ -96,7 +96,7 @@ static dstatement_t bool64_conv_2_statements[] = {
|
|||
{ OP(0, 0, 0, OP_WITH), 4, 113, 2 },
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0107, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0117, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 8, 0127, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0127, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0137, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0147, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0157, 88 },
|
||||
|
@ -109,8 +109,8 @@ static dstatement_t bool64_conv_3a_statements[] = {
|
|||
{ OP(1, 1, 2, OP_CONV), 3, 0007, 54 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0217, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 7, 0017, 62 },
|
||||
{ OP(1, 1, 2, OP_CONV), 8, 0227, 64 },
|
||||
{ OP(1, 1, 2, OP_CONV), 14, 0027, 70 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0227, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 14, 0027, 70 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0237, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 22, 0037, 78 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0247, 80 },
|
||||
|
@ -126,8 +126,8 @@ static dstatement_t bool64_conv_3b_statements[] = {
|
|||
{ OP(1, 1, 2, OP_CONV), 1, 0207, 50 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0017, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 5, 0217, 58 },
|
||||
{ OP(1, 1, 2, OP_CONV), 8, 0027, 64 },
|
||||
{ OP(1, 1, 2, OP_CONV), 10, 0227, 66 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0027, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 10, 0227, 66 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0037, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 18, 0237, 74 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0047, 80 },
|
||||
|
@ -141,7 +141,7 @@ static dstatement_t bool64_conv_3b_statements[] = {
|
|||
static dstatement_t bool64_conv_4_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0307, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0317, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 8, 0327, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 8, 0327, 64 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0337, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0347, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0357, 88 },
|
||||
|
|
Loading…
Reference in a new issue