mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-19 09:01:30 +00:00
d9d0a80752
The extend instruction is for loading narrower data types into wider data types, eg, single element into 2, 3, or 4 element types, with a small set of extension schemes: 0, 1, -1, copy (for 1->any and 2 -> 4). Possibly most importantly, it works with unaligned data. Progress towards #30
223 lines
5.4 KiB
C
223 lines
5.4 KiB
C
#include "head.c"
|
|
|
|
#include "QF/mathlib.h"
|
|
|
|
#define _ -6.259853398707798e+18 // 0xdeadbeef
|
|
|
|
static pr_vec4_t float_extend_init[] = {
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ 2, 3, 4, 5 },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
};
|
|
|
|
static pr_vec4_t float_extend_expect[] = {
|
|
{ 5, 0, _, _ },
|
|
{ 4, 0, 0, _ },
|
|
{ 3, 0, 0, 0 },
|
|
{ 4, 5, 0, _ },
|
|
{ 2, 3, 0, 0 },
|
|
{ 3, 4, 5, 0 },
|
|
{ 2, 3, 4, 5 },
|
|
{ _, _, 4, 1 },
|
|
{ _, 3, 1, 1 },
|
|
{ 2, 1, 1, 1 },
|
|
{ _, 4, 5, 1 },
|
|
{ 2, 3, 1, 1 },
|
|
{ 2, 3, 4, 1 },
|
|
{ _, _, _, _ },
|
|
{ 5, 5, _, _ },
|
|
{ 4, 4, 4, _ },
|
|
{ 3, 3, 3, 3 },
|
|
{ 4, 5, 0, _ },
|
|
{ 2, 3, 2, 3 },
|
|
{ 3, 4, 5, 0 },
|
|
{ _, _, _, _ },
|
|
{ _, _, 4, -1 },
|
|
{ _, 3, -1, -1 },
|
|
{ 2, -1, -1, -1 },
|
|
{ _, 4, 5, -1 },
|
|
{ 2, 3, -1, -1 },
|
|
{ 2, 3, 4, -1 },
|
|
{ _, _, _, _ },
|
|
};
|
|
|
|
static dstatement_t float_extend_statements[] = {
|
|
{ OP(0, 0, 0, OP_WITH), 0, 0, 0 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 28, 1 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 56, 2 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 84, 3 },
|
|
|
|
{ OP(0, 0, 0, OP_EXTEND), 27, 000, 0 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 26, 001, 4 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 25, 002, 8 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 26, 003, 12 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 24, 004, 16 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 25, 005, 20 },
|
|
|
|
{ OP(0, 0, 1, OP_EXTEND), 26, 010, 2 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 25, 011, 5 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 24, 012, 8 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 26, 013, 13 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 24, 014, 16 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 24, 015, 20 },
|
|
|
|
{ OP(0, 0, 2, OP_EXTEND), 27, 020, 0 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 26, 021, 4 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 25, 022, 8 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 26, 023, 12 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 24, 024, 16 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 25, 025, 20 },
|
|
|
|
{ OP(0, 0, 3, OP_EXTEND), 26, 030, 2 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 25, 031, 5 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 24, 032, 8 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 26, 033, 13 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 24, 034, 16 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 24, 035, 20 },
|
|
};
|
|
|
|
#undef _
|
|
#define _ -1.1885959257070704e+148 // 0xdeadbeefdeadbeef
|
|
|
|
static pr_dvec4_t double_extend_init[] = {
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ 2, 3, 4, 5 },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
{ _, _, _, _ },
|
|
};
|
|
|
|
static pr_dvec4_t double_extend_expect[] = {
|
|
{ 5, 0, _, _ },
|
|
{ 4, 0, 0, _ },
|
|
{ 3, 0, 0, 0 },
|
|
{ 4, 5, 0, _ },
|
|
{ 2, 3, 0, 0 },
|
|
{ 3, 4, 5, 0 },
|
|
{ 2, 3, 4, 5 },
|
|
{ _, _, 4, 1 },
|
|
{ _, 3, 1, 1 },
|
|
{ 2, 1, 1, 1 },
|
|
{ _, 4, 5, 1 },
|
|
{ 2, 3, 1, 1 },
|
|
{ 2, 3, 4, 1 },
|
|
{ _, _, _, _ },
|
|
{ 5, 5, _, _ },
|
|
{ 4, 4, 4, _ },
|
|
{ 3, 3, 3, 3 },
|
|
{ 4, 5, 0, _ },
|
|
{ 2, 3, 2, 3 },
|
|
{ 3, 4, 5, 0 },
|
|
{ _, _, _, _ },
|
|
{ _, _, 4, -1 },
|
|
{ _, 3, -1, -1 },
|
|
{ 2, -1, -1, -1 },
|
|
{ _, 4, 5, -1 },
|
|
{ 2, 3, -1, -1 },
|
|
{ 2, 3, 4, -1 },
|
|
{ _, _, _, _ },
|
|
};
|
|
|
|
static dstatement_t double_extend_statements[] = {
|
|
{ OP(0, 0, 0, OP_WITH), 0, 0, 0 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 56, 1 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 112, 2 },
|
|
{ OP(0, 0, 0, OP_WITH), 0, 168, 3 },
|
|
|
|
{ OP(0, 0, 0, OP_EXTEND), 54, 040, 0 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 52, 041, 8 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 50, 042, 16 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 52, 043, 24 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 48, 044, 32 },
|
|
{ OP(0, 0, 0, OP_EXTEND), 50, 045, 40 },
|
|
|
|
{ OP(0, 0, 1, OP_EXTEND), 52, 050, 4 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 50, 051, 10 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 48, 052, 16 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 52, 053, 26 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 48, 054, 32 },
|
|
{ OP(0, 0, 1, OP_EXTEND), 48, 055, 40 },
|
|
|
|
{ OP(0, 0, 2, OP_EXTEND), 54, 060, 0 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 52, 061, 8 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 50, 062, 16 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 52, 063, 24 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 48, 064, 32 },
|
|
{ OP(0, 0, 2, OP_EXTEND), 50, 065, 40 },
|
|
|
|
{ OP(0, 0, 3, OP_EXTEND), 52, 070, 4 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 50, 071, 10 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 48, 072, 16 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 52, 073, 26 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 48, 074, 32 },
|
|
{ OP(0, 0, 3, OP_EXTEND), 48, 075, 40 },
|
|
};
|
|
|
|
test_t tests[] = {
|
|
{
|
|
.desc = "float extend",
|
|
.num_globals = num_globals(float_extend_init,float_extend_expect),
|
|
.num_statements = num_statements (float_extend_statements),
|
|
.statements = float_extend_statements,
|
|
.init_globals = (pr_int_t *) float_extend_init,
|
|
.expect_globals = (pr_int_t *) float_extend_expect,
|
|
},
|
|
{
|
|
.desc = "double extend",
|
|
.num_globals = num_globals(double_extend_init,double_extend_expect),
|
|
.num_statements = num_statements (double_extend_statements),
|
|
.statements = double_extend_statements,
|
|
.init_globals = (pr_int_t *) double_extend_init,
|
|
.expect_globals = (pr_int_t *) double_extend_expect,
|
|
},
|
|
};
|
|
|
|
#include "main.c"
|