mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 09:51:41 +00:00
[gamecode] Correct incorrect bool32-bool64 conversion
And add tests for long, ulong and bool64 conversions.
This commit is contained in:
parent
4bf934e6b9
commit
1f73b26d24
5 changed files with 602 additions and 1 deletions
|
@ -43,7 +43,7 @@ convert_matrix = [
|
|||
[1, 1, 1, 0, 1, 3, 1, 3], # d
|
||||
|
||||
[0, 1, 1, 1, 0, 3, 1, 3], # ui
|
||||
[2, 2, 2, 2, 2, 0, 2, 1], # 32-bit bool
|
||||
[2, 2, 2, 2, 2, 0, 2, 3], # 32-bit bool
|
||||
[1, 1, 0, 1, 1, 3, 0, 3], # ul
|
||||
[2, 2, 2, 2, 2, 3, 2, 0], # 64-bit bool
|
||||
]
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
libs_gamecode_tests = \
|
||||
libs/gamecode/test/test-conv0 \
|
||||
libs/gamecode/test/test-conv1 \
|
||||
libs/gamecode/test/test-conv2 \
|
||||
libs/gamecode/test/test-conv4 \
|
||||
libs/gamecode/test/test-conv5 \
|
||||
libs/gamecode/test/test-conv6 \
|
||||
libs/gamecode/test/test-conv7 \
|
||||
libs/gamecode/test/test-double \
|
||||
libs/gamecode/test/test-float \
|
||||
libs/gamecode/test/test-int \
|
||||
|
@ -33,6 +36,11 @@ libs_gamecode_test_test_conv1_SOURCES= \
|
|||
libs_gamecode_test_test_conv1_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv1_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv2_SOURCES= \
|
||||
libs/gamecode/test/test-conv2.c
|
||||
libs_gamecode_test_test_conv2_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv2_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)
|
||||
|
@ -43,6 +51,16 @@ libs_gamecode_test_test_conv5_SOURCES= \
|
|||
libs_gamecode_test_test_conv5_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv5_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv6_SOURCES= \
|
||||
libs/gamecode/test/test-conv6.c
|
||||
libs_gamecode_test_test_conv6_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv6_DEPENDENCIES= $(test_gamecode_libs)
|
||||
|
||||
libs_gamecode_test_test_conv7_SOURCES= \
|
||||
libs/gamecode/test/test-conv7.c
|
||||
libs_gamecode_test_test_conv7_LDADD= $(test_gamecode_libs)
|
||||
libs_gamecode_test_test_conv7_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)
|
||||
|
|
192
libs/gamecode/test/test-conv2.c
Normal file
192
libs/gamecode/test/test-conv2.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t long_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 long_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
|
||||
{ 5, 0, -5, 0xffffffff}, // int
|
||||
{ 0x80000000, 0xffffffff, 0x7fffffff, 0},
|
||||
{ 1, 0, -1, -1}, // float
|
||||
{ 0, 0x80000000, 0, 0x80000000},
|
||||
{ 0, 0, 0, 0}, // long
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0x80000000, 0, 0x80000000}, // double
|
||||
{ 1, 0, -1, -1},
|
||||
{ 5, 0, -5, 0}, // uint
|
||||
{ 0x80000000, 0, 0x7fffffff, 0},
|
||||
{ 1, 0, 1, 0}, // bool32
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 0, 0}, // ulong
|
||||
{ 0, 0, 0, 0},
|
||||
{ 1, 0, 1, 0}, // bool64
|
||||
{ 1, 0, 0, 0},
|
||||
};
|
||||
|
||||
static dstatement_t long_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, 0002, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0012, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0032, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0042, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0052, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0072, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t long_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, 0102, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0112, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0132, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0142, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0152, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0172, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t long_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0202, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 3, 0002, 54 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0212, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 7, 0012, 62 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0232, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 22, 0032, 78 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0242, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 27, 0042, 86 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0252, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 31, 0052, 94 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0272, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 46, 0072, 110 },
|
||||
};
|
||||
|
||||
static dstatement_t long_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0002, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 1, 0202, 50 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0012, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 5, 0212, 58 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0032, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 18, 0232, 74 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0042, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 25, 0242, 82 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0052, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 29, 0252, 90 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0072, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 42, 0272, 106 },
|
||||
};
|
||||
|
||||
static dstatement_t long_conv_4_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0302, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0312, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0332, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0342, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0352, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0372, 104 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "long conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(long_conv_init,long_conv_expect),
|
||||
.num_statements = num_statements (long_conv_1_statements),
|
||||
.statements = long_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) long_conv_init,
|
||||
.expect_globals = (pr_int_t *) long_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(long_conv_init,long_conv_expect),
|
||||
.num_statements = num_statements (long_conv_2_statements),
|
||||
.statements = long_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) long_conv_init,
|
||||
.expect_globals = (pr_int_t *) long_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(long_conv_init,long_conv_expect),
|
||||
.num_statements = num_statements (long_conv_3a_statements),
|
||||
.statements = long_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) long_conv_init,
|
||||
.expect_globals = (pr_int_t *) long_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(long_conv_init,long_conv_expect),
|
||||
.num_statements = num_statements (long_conv_3b_statements),
|
||||
.statements = long_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) long_conv_init,
|
||||
.expect_globals = (pr_int_t *) long_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "long conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(long_conv_init,long_conv_expect),
|
||||
.num_statements = num_statements (long_conv_4_statements),
|
||||
.statements = long_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) long_conv_init,
|
||||
.expect_globals = (pr_int_t *) long_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
192
libs/gamecode/test/test-conv6.c
Normal file
192
libs/gamecode/test/test-conv6.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t ulong_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 ulong_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
|
||||
{ 5, 0, -5, 0xffffffff}, // int
|
||||
{ 0x80000000, 0xffffffff, 0x7fffffff, 0},
|
||||
{ 1, 0, -1, -1}, // float
|
||||
{ 0, 0, 0, 0x80000000},
|
||||
{ 0, 0, 0, 0}, // long
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0x80000000}, // double
|
||||
{ 1, 0, -1, -1},
|
||||
{ 5, 0, -5, 0}, // uint
|
||||
{ 0x80000000, 0, 0x7fffffff, 0},
|
||||
{ 1, 0, 1, 0}, // bool32
|
||||
{ 1, 0, 0, 0},
|
||||
{ 0, 0, 0, 0}, // ulong
|
||||
{ 0, 0, 0, 0},
|
||||
{ 1, 0, 1, 0}, // bool64
|
||||
{ 1, 0, 0, 0},
|
||||
};
|
||||
|
||||
static dstatement_t ulong_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, 0006, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0016, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0036, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0046, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0056, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0076, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t ulong_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, 0106, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0116, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0136, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0146, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0156, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0176, 104 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -12, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t ulong_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0206, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 3, 0006, 54 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0216, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 7, 0016, 62 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0236, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 22, 0036, 78 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0246, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 27, 0046, 86 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0256, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 31, 0056, 94 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0276, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 46, 0076, 110 },
|
||||
};
|
||||
|
||||
static dstatement_t ulong_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0006, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 1, 0206, 50 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0016, 56 },
|
||||
{ OP(1, 1, 2, OP_CONV), 5, 0216, 58 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0036, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 18, 0236, 74 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0046, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 25, 0246, 82 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0056, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 29, 0256, 90 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0076, 104 },
|
||||
{ OP(2, 1, 2, OP_CONV), 42, 0276, 106 },
|
||||
};
|
||||
|
||||
static dstatement_t ulong_conv_4_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0306, 48 },
|
||||
{ OP(1, 1, 2, OP_CONV), 4, 0316, 56 },
|
||||
{ OP(2, 1, 2, OP_CONV), 16, 0336, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0346, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0356, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 40, 0376, 104 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "ulong conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(ulong_conv_init,ulong_conv_expect),
|
||||
.num_statements = num_statements (ulong_conv_1_statements),
|
||||
.statements = ulong_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) ulong_conv_init,
|
||||
.expect_globals = (pr_int_t *) ulong_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "ulong conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(ulong_conv_init,ulong_conv_expect),
|
||||
.num_statements = num_statements (ulong_conv_2_statements),
|
||||
.statements = ulong_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) ulong_conv_init,
|
||||
.expect_globals = (pr_int_t *) ulong_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "ulong conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(ulong_conv_init,ulong_conv_expect),
|
||||
.num_statements = num_statements (ulong_conv_3a_statements),
|
||||
.statements = ulong_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) ulong_conv_init,
|
||||
.expect_globals = (pr_int_t *) ulong_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "ulong conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(ulong_conv_init,ulong_conv_expect),
|
||||
.num_statements = num_statements (ulong_conv_3b_statements),
|
||||
.statements = ulong_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) ulong_conv_init,
|
||||
.expect_globals = (pr_int_t *) ulong_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "ulong conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(ulong_conv_init,ulong_conv_expect),
|
||||
.num_statements = num_statements (ulong_conv_4_statements),
|
||||
.statements = ulong_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) ulong_conv_init,
|
||||
.expect_globals = (pr_int_t *) ulong_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
199
libs/gamecode/test/test-conv7.c
Normal file
199
libs/gamecode/test/test-conv7.c
Normal file
|
@ -0,0 +1,199 @@
|
|||
#include "head.c"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
static pr_ivec4_t bool64_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 bool64_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
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // int
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // float
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // long
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // double
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // uint
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // bool32
|
||||
{ 0xffffffff, 0xffffffff, 0, 0},
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}, // ulong
|
||||
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff},
|
||||
{ 0, 0, 0, 0}, // bool64
|
||||
{ 0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static dstatement_t bool64_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, 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), 16, 0037, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0047, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0057, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0067, 96 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t bool64_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, 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), 16, 0137, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0147, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0157, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0167, 96 },
|
||||
{ OP(0, 0, 0, OP_JUMP_A), -13, 0, 0 },
|
||||
};
|
||||
|
||||
static dstatement_t bool64_conv_3a_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0207, 48 },
|
||||
{ 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), 16, 0237, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 22, 0037, 78 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0247, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 27, 0047, 86 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0257, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 31, 0057, 94 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0267, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 38, 0067, 102 },
|
||||
};
|
||||
|
||||
static dstatement_t bool64_conv_3b_statements[] = {
|
||||
{ OP(1, 1, 2, OP_CONV), 0, 0007, 48 },
|
||||
{ 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), 16, 0037, 72 },
|
||||
{ OP(2, 1, 2, OP_CONV), 18, 0237, 74 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0047, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 25, 0247, 82 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0057, 88 },
|
||||
{ OP(1, 1, 2, OP_CONV), 29, 0257, 90 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0067, 96 },
|
||||
{ OP(2, 1, 2, OP_CONV), 34, 0267, 98 },
|
||||
};
|
||||
|
||||
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), 16, 0337, 72 },
|
||||
{ OP(1, 1, 2, OP_CONV), 24, 0347, 80 },
|
||||
{ OP(1, 1, 2, OP_CONV), 28, 0357, 88 },
|
||||
{ OP(2, 1, 2, OP_CONV), 32, 0367, 96 },
|
||||
};
|
||||
|
||||
test_t tests[] = {
|
||||
{
|
||||
.desc = "bool64 conv 1",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool64_conv_init,bool64_conv_expect),
|
||||
.num_statements = num_statements (bool64_conv_1_statements),
|
||||
.statements = bool64_conv_1_statements,
|
||||
.init_globals = (pr_int_t *) bool64_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool64_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool64 conv 2",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool64_conv_init,bool64_conv_expect),
|
||||
.num_statements = num_statements (bool64_conv_2_statements),
|
||||
.statements = bool64_conv_2_statements,
|
||||
.init_globals = (pr_int_t *) bool64_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool64_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool64 conv 3a",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool64_conv_init,bool64_conv_expect),
|
||||
.num_statements = num_statements (bool64_conv_3a_statements),
|
||||
.statements = bool64_conv_3a_statements,
|
||||
.init_globals = (pr_int_t *) bool64_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool64_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool64 conv 3b",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool64_conv_init,bool64_conv_expect),
|
||||
.num_statements = num_statements (bool64_conv_3b_statements),
|
||||
.statements = bool64_conv_3b_statements,
|
||||
.init_globals = (pr_int_t *) bool64_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool64_conv_expect,
|
||||
},
|
||||
{
|
||||
.desc = "bool64 conv 4",
|
||||
.extra_globals = 4 * 1,
|
||||
.num_globals = 4*num_globals(bool64_conv_init,bool64_conv_expect),
|
||||
.num_statements = num_statements (bool64_conv_4_statements),
|
||||
.statements = bool64_conv_4_statements,
|
||||
.init_globals = (pr_int_t *) bool64_conv_init,
|
||||
.expect_globals = (pr_int_t *) bool64_conv_expect,
|
||||
},
|
||||
};
|
||||
|
||||
#include "main.c"
|
Loading…
Reference in a new issue