mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[gamecode] Correct incorrect bool64-bool32 conversion
And add tests for float, uint and bool32 conversions.
This commit is contained in:
parent
e26fb49df7
commit
4bf934e6b9
5 changed files with 563 additions and 1 deletions
|
@ -45,7 +45,7 @@ convert_matrix = [
|
|||
[0, 1, 1, 1, 0, 3, 1, 3], # ui
|
||||
[2, 2, 2, 2, 2, 0, 2, 1], # 32-bit bool
|
||||
[1, 1, 0, 1, 1, 3, 0, 3], # ul
|
||||
[2, 2, 2, 2, 2, 1, 2, 0], # 64-bit bool
|
||||
[2, 2, 2, 2, 2, 3, 2, 0], # 64-bit bool
|
||||
]
|
||||
|
||||
def case_str(width, src_type, dst_type):
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
libs_gamecode_tests = \
|
||||
libs/gamecode/test/test-conv0 \
|
||||
libs/gamecode/test/test-conv1 \
|
||||
libs/gamecode/test/test-conv4 \
|
||||
libs/gamecode/test/test-conv5 \
|
||||
libs/gamecode/test/test-double \
|
||||
libs/gamecode/test/test-float \
|
||||
libs/gamecode/test/test-int \
|
||||
|
@ -25,6 +28,21 @@ libs_gamecode_test_test_conv0_SOURCES= \
|
|||
libs_gamecode_test_test_conv0_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv0_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv1_SOURCES= \
|
||||
libs/gamecode/test/test-conv1.c
|
||||
libs_gamecode_test_test_conv1_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv1_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)
|
||||
libs_gamecode_test_test_conv4_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv5_SOURCES= \
|
||||
libs/gamecode/test/test-conv5.c
|
||||
libs_gamecode_test_test_conv5_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv5_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_double_SOURCES= \
|
||||
libs/gamecode/test/test-double.c
|
||||
libs_gamecode_test_test_double_LDADD= $(test_gamecode_libs)
|
||||
|
|
183
libs/gamecode/test/test-conv1.c
Normal file
183
libs/gamecode/test/test-conv1.c
Normal file
|
@ -0,0 +1,183 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t float_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},
|
||||
};
|
||||
|
||||
static pr_ivec4_t float_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
|
||||
{ 0x40a00000, 0xc0a00000, 0xcf000000, 0x4f000000}, // int
|
||||
{ 0, 0, 0, 0}, // float
|
||||
{ 0xdf000000, 0x52c70000, 0x43800000, 0x4f000000}, // long
|
||||
{ 0x7149f2ca, 0xf149f2ca, 0x3fc00000, 0xbfc00000}, // double
|
||||
{ 0x40a00000, 0x4f800000, 0x4f000000, 0x4f000000}, // uint
|
||||
{ 0x3f800000, 0x3f800000, 0x3f800000, 0}, // bool32
|
||||
{ 0x5f000000, 0x52c70000, 0x43800000, 0x4f000000}, // ulong
|
||||
{ 0x3f800000, 0x3f800000, 0x3f800000, 0}, // bool64
|
||||
};
|
||||
|
||||
static dstatement_t float_conv_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // init index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -1, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -2, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0001, 48 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0021, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0031, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0041, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0051, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0061, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0071, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t float_conv_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -2, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -4, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0101, 48 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0121, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0131, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0141, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0151, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0161, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0171, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t float_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0201, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 3, 0001, 51 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0221, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 14, 0021, 59 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0231, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 22, 0031, 63 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0241, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 27, 0041, 67 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0251, 68 },
|
||||
{ OP(1, 1, 1, OP_CONV), 31, 0051, 71 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0261, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 38, 0061, 75 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0271, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 46, 0071, 79 },
|
||||
};
|
||||
|
||||
static dstatement_t float_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0001, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 1, 0201, 49 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0021, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 10, 0221, 57 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0031, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 18, 0231, 61 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0241, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 27, 0041, 67 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0051, 68 },
|
||||
{ OP(1, 1, 1, OP_CONV), 29, 0251, 69 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0061, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 34, 0261, 73 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0071, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 42, 0271, 77 },
|
||||
};
|
||||
|
||||
static dstatement_t float_conv_4_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0301, 48 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0321, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0331, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0341, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0351, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0361, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0371, 76 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "float conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(float_conv_init,float_conv_expect),
|
||||
.num_statements = num_statements (float_conv_1_statements),
|
||||
.statements = float_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) float_conv_init,
|
||||
.expect_globals = (pr_int_t *) float_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "float conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(float_conv_init,float_conv_expect),
|
||||
.num_statements = num_statements (float_conv_2_statements),
|
||||
.statements = float_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) float_conv_init,
|
||||
.expect_globals = (pr_int_t *) float_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "float conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(float_conv_init,float_conv_expect),
|
||||
.num_statements = num_statements (float_conv_3a_statements),
|
||||
.statements = float_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) float_conv_init,
|
||||
.expect_globals = (pr_int_t *) float_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "float conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(float_conv_init,float_conv_expect),
|
||||
.num_statements = num_statements (float_conv_3b_statements),
|
||||
.statements = float_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) float_conv_init,
|
||||
.expect_globals = (pr_int_t *) float_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "float conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(float_conv_init,float_conv_expect),
|
||||
.num_statements = num_statements (float_conv_4_statements),
|
||||
.statements = float_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) float_conv_init,
|
||||
.expect_globals = (pr_int_t *) float_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
178
libs/gamecode/test/test-conv4.c
Normal file
178
libs/gamecode/test/test-conv4.c
Normal file
|
@ -0,0 +1,178 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t uint_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},
|
||||
};
|
||||
|
||||
static pr_ivec4_t uint_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
|
||||
{ 0, 0, 0, 0}, // int
|
||||
// why 0? expected 0xfffffff. vv gcc bug?
|
||||
{ 1, 0xffffffff, 0, 0}, // float
|
||||
{ 99, 0x80000000, 256, 0x7fffffff}, // long
|
||||
// why 0? vv expected 0xfffffff. gcc bug?
|
||||
{ 0, 0, 1, 0xffffffff}, // double
|
||||
{ 0, 0, 0, 0}, // uint
|
||||
{ 1, 1, 1, 0}, // bool32
|
||||
{ 99, 0x80000000, 256, 0x7fffffff}, // ulong
|
||||
{ 1, 1, 1, 0}, // bool64
|
||||
};
|
||||
|
||||
static dstatement_t uint_conv_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // init index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -1, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -2, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0014, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0024, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0034, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0054, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0064, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0074, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t uint_conv_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -2, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -4, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0114, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0124, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0134, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0154, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0164, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0174, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t uint_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0214, 52 },
|
||||
{ OP(1, 1, 1, OP_CONV), 7, 0014, 55 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0224, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 14, 0024, 59 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0234, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 22, 0034, 63 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0254, 68 },
|
||||
{ OP(1, 1, 1, OP_CONV), 31, 0054, 71 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0264, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 38, 0064, 75 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0274, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 46, 0074, 79 },
|
||||
};
|
||||
|
||||
static dstatement_t uint_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0014, 52 },
|
||||
{ OP(1, 1, 1, OP_CONV), 5, 0214, 53 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0024, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 10, 0224, 57 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0034, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 18, 0234, 61 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0054, 68 },
|
||||
{ OP(1, 1, 1, OP_CONV), 29, 0254, 69 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0064, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 34, 0264, 73 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0074, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 42, 0274, 77 },
|
||||
};
|
||||
|
||||
static dstatement_t uint_conv_4_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0314, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0324, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0334, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 28, 0354, 68 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0364, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0374, 76 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "uint conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(uint_conv_init,uint_conv_expect),
|
||||
.num_statements = num_statements (uint_conv_1_statements),
|
||||
.statements = uint_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) uint_conv_init,
|
||||
.expect_globals = (pr_int_t *) uint_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "uint conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(uint_conv_init,uint_conv_expect),
|
||||
.num_statements = num_statements (uint_conv_2_statements),
|
||||
.statements = uint_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) uint_conv_init,
|
||||
.expect_globals = (pr_int_t *) uint_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "uint conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(uint_conv_init,uint_conv_expect),
|
||||
.num_statements = num_statements (uint_conv_3a_statements),
|
||||
.statements = uint_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) uint_conv_init,
|
||||
.expect_globals = (pr_int_t *) uint_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "uint conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(uint_conv_init,uint_conv_expect),
|
||||
.num_statements = num_statements (uint_conv_3b_statements),
|
||||
.statements = uint_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) uint_conv_init,
|
||||
.expect_globals = (pr_int_t *) uint_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "uint conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(uint_conv_init,uint_conv_expect),
|
||||
.num_statements = num_statements (uint_conv_4_statements),
|
||||
.statements = uint_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) uint_conv_init,
|
||||
.expect_globals = (pr_int_t *) uint_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
183
libs/gamecode/test/test-conv5.c
Normal file
183
libs/gamecode/test/test-conv5.c
Normal file
|
@ -0,0 +1,183 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t bool32_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},
|
||||
};
|
||||
|
||||
static pr_ivec4_t bool32_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
|
||||
{ -1, -1, -1, -1}, // int
|
||||
{ -1, -1, -1, -1}, // float
|
||||
{ -1, -1, -1, -1}, // long
|
||||
{ -1, -1, -1, -1}, // double
|
||||
{ -1, -1, -1, -1}, // uint
|
||||
{ 0, 0, 0, 0}, // bool32
|
||||
{ -1, -1, -1, -1}, // ulong
|
||||
{ -1, -1, -1, 0}, // bool64
|
||||
};
|
||||
|
||||
static dstatement_t bool32_conv_1_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // init index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -1, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -2, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0005, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0015, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0025, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0035, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0045, 64 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0065, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0075, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t bool32_conv_2_statements[] = {
|
||||
{ OP(0, 0, 0, OP_LEA_A), 4, 0, 80 }, // index
|
||||
{ OP(0, 0, 0, OP_LEA_A), 8, 0, 81 }, // init index for 64-bits
|
||||
//loop:
|
||||
{ OP(0, 0, 0, OP_LEA_C), 80, -2, 80 }, // dec index
|
||||
{ OP(0, 0, 0, OP_LEA_C), 81, -4, 81 }, // dec index for 64-bits
|
||||
{ OP(0, 0, 0, OP_IFAE_A), 2, 0, 80 },
|
||||
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 80, 1 },
|
||||
{ OP(0, 0, 0, OP_WITH), 4, 81, 2 },
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0105, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0115, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0125, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0135, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0145, 64 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0165, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0175, 76 },
|
||||
{ OP(1, 1, 1, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t bool32_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0205, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 3, 0005, 51 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0215, 52 },
|
||||
{ OP(1, 1, 1, OP_CONV), 7, 0015, 55 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0225, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 14, 0025, 59 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0235, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 22, 0035, 63 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0245, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 27, 0045, 67 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0265, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 38, 0065, 75 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0275, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 46, 0075, 79 },
|
||||
};
|
||||
|
||||
static dstatement_t bool32_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0005, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 1, 0205, 49 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0015, 52 },
|
||||
{ OP(1, 1, 1, OP_CONV), 5, 0215, 53 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0025, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 10, 0225, 57 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0035, 60 },
|
||||
{ OP(2, 1, 1, OP_CONV), 18, 0235, 61 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0045, 64 },
|
||||
{ OP(1, 1, 1, OP_CONV), 25, 0245, 65 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0065, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 34, 0265, 73 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0075, 76 },
|
||||
{ OP(2, 1, 1, OP_CONV), 42, 0275, 77 },
|
||||
};
|
||||
|
||||
static dstatement_t bool32_conv_4_statements[] = {
|
||||
{ OP(1, 1, 1, OP_CONV), 0, 0305, 48 },
|
||||
{ OP(1, 1, 1, OP_CONV), 4, 0315, 52 },
|
||||
{ OP(2, 1, 1, OP_CONV), 8, 0325, 56 },
|
||||
{ OP(2, 1, 1, OP_CONV), 16, 0335, 60 },
|
||||
{ OP(1, 1, 1, OP_CONV), 24, 0345, 64 },
|
||||
{ OP(2, 1, 1, OP_CONV), 32, 0365, 72 },
|
||||
{ OP(2, 1, 1, OP_CONV), 40, 0375, 76 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "bool32 conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool32_conv_init,bool32_conv_expect),
|
||||
.num_statements = num_statements (bool32_conv_1_statements),
|
||||
.statements = bool32_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) bool32_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool32_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool32 conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool32_conv_init,bool32_conv_expect),
|
||||
.num_statements = num_statements (bool32_conv_2_statements),
|
||||
.statements = bool32_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) bool32_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool32_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool32 conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool32_conv_init,bool32_conv_expect),
|
||||
.num_statements = num_statements (bool32_conv_3a_statements),
|
||||
.statements = bool32_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) bool32_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool32_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool32 conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool32_conv_init,bool32_conv_expect),
|
||||
.num_statements = num_statements (bool32_conv_3b_statements),
|
||||
.statements = bool32_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) bool32_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool32_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool32 conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool32_conv_init,bool32_conv_expect),
|
||||
.num_statements = num_statements (bool32_conv_4_statements),
|
||||
.statements = bool32_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) bool32_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool32_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
Loading…
Reference in a new issue