[gamecode] Drop bool ops in favor of long bit ops

I realized that being able to do bit-wise operations with 64-bit values
(and 256-bit vectors) is far more important than some convenient boolean
logic operators. The logic ops can be handled via the bit-wise ops so
long as the values are all properly boolean, and I plan on adding some
boolean conversion ope, so no real loss.
This commit is contained in:
Bill Currie 2022-01-13 14:24:11 +09:00
parent 424bdcbf96
commit 6f6f47e27e
2 changed files with 9 additions and 57 deletions

View file

@ -20,7 +20,6 @@ bitmap_txt = """
1 011r tuss shiftops
1 0110 o1oo string
1 1ccc t0ss compare2
1 1000 ooss bitops
1 1001 t1ss scale
1 1001 t100 swizzle
1 1010 d1xx
@ -35,7 +34,7 @@ bitmap_txt = """
1 1101 11oo memset
1 1110 d1xx
1 11dd t100 vecops2
1 1100 ooss boolops
1 1t00 ooss bitops
n 1111 nnnn
0 1011 nnnn
"""
@ -77,14 +76,16 @@ any_formats = {
"types": "ev_integer, ev_integer, ev_integer",
}
bitops_formats = {
"opcode": "OP_{op_bit[oo].upper()}_I_{ss+1}",
"opcode": "OP_{op_bit[oo].upper()}_{bit_type[t]}_{ss+1}",
"mnemonic": "{op_bit[oo]}",
"opname": "{op_bit[oo]}",
"format": "{bit_fmt[oo]}",
"widths": "{ss+1}, {ss+1}, {ss+1}",
"types": "ev_integer, ev_integer, ev_integer",
"types": "{bit_types[t]}, {bit_types[t]}, {bit_types[t]}",
"args": {
"op_bit": ["bitand", "bitor", "bitxor", "bitnot"],
"bit_type": ["I", "L"],
"bit_types": ["ev_integer", "ev_long"],
"bit_fmt": [
"%Ga, %Gb, %gc",
"%Ga, %Gb, %gc",
@ -93,23 +94,6 @@ bitops_formats = {
],
},
}
boolops_formats = {
"opcode": "OP_{op_bool[oo].upper()}_I_{ss+1}",
"mnemonic": "{op_bool[oo]}",
"opname": "{op_bool[oo]}",
"format": "{bool_fmt[oo]}",
"widths": "{ss+1}, {ss+1}, {ss+1}",
"types": "ev_integer, ev_integer, ev_integer",
"args": {
"op_bool": ["and", "or", "xor", "not"],
"bool_fmt": [
"%Ga, %Gb, %gc",
"%Ga, %Gb, %gc",
"%Ga, %Gb, %gc",
"%Ga, %gc",
],
},
}
branch_formats = {
"opcode": "OP_{op_cond[ccc].upper()}_{op_mode[mm]}",
"mnemonic": "{op_cond[ccc]}",
@ -471,7 +455,6 @@ group_map = {
"all": all_formats,
"any": any_formats,
"bitops": bitops_formats,
"boolops": boolops_formats,
"branch": branch_formats,
"call": call_formats,
"compare": compare_formats,

View file

@ -3403,42 +3403,11 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
OPC(int) = none4i (OPA(ivec4));
break;
#define OP_bool_n(OP, t, n, op, m) \
case OP_##OP##_I_##n: \
OPC(t) = m((OPA(t) != 0) op (OPB(t) != 0)); \
break
#define OP_bool_3(OP, t, n, op, m) \
case OP_##OP##_I_##n: \
{ \
__auto_type a = loadvec3i (&OPA(int)); \
__auto_type b = loadvec3i (&OPB(int)); \
storevec3i (&OPC(int), (a != 0) op (b != 0)); \
} \
break
#define OP_bool(OP, op) \
OP_bool_n (OP, int, 1, op, -); \
OP_bool_n (OP, ivec2, 2, op, +); \
OP_bool_3 (OP, int, 3, op, +); \
OP_bool_n (OP, ivec4, 4, op, +)
#define OP_not_n(OP, t, n, m) \
case OP_##OP##_I_##n: \
OPC(t) = m((OPA(t) == 0)); \
break
#define OP_not_3(OP, t, n, m) \
case OP_##OP##_I_##n: \
{ \
__auto_type a = loadvec3i (&OPA(int)); \
storevec3i (&OPC(int), (a == 0)); \
} \
break
// 1 1100
OP_bool (AND, &);
OP_bool (OR, |);
OP_bool (XOR, ^);
OP_not_n (NOT, int, 1, -);
OP_not_n (NOT, ivec2, 2, +);
OP_not_3 (NOT, int, 3, +);
OP_not_n (NOT, ivec4, 4, +);
OP_op_T (BITAND, L, long, lvec2, lvec4, &);
OP_op_T (BITOR, L, long, lvec2, lvec4, |);
OP_op_T (BITXOR, L, long, lvec2, lvec4, ^);
OP_uop_T (BITNOT, L, long, lvec2, lvec4, ~);
// 1 1101
OP_cmp_T (GE, u, int, ivec2, ivec4, >=, uint, uivec2, uivec4);
case OP_QV4MUL_F: