tcg: Use C_NotImplemented in tcg_target_op_def

Return C_NotImplemented instead of asserting for opcodes
not implemented by the backend.  For now, the assertion
moves to process_op_defs.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2024-12-27 14:30:01 -08:00
parent 12f06532c8
commit da43e5e6ba
11 changed files with 16 additions and 14 deletions

View File

@ -3158,7 +3158,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return C_O1_I2(w, 0, w); return C_O1_I2(w, 0, w);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -2260,7 +2260,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
case INDEX_op_bitsel_vec: case INDEX_op_bitsel_vec:
return C_O1_I3(w, w, w, w); return C_O1_I3(w, w, w, w);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -3885,7 +3885,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return C_O1_I4(x, x, x, xO, x); return C_O1_I4(x, x, x, xO, x);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -2391,7 +2391,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return C_O1_I3(w, w, w, w); return C_O1_I3(w, w, w, w);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -2292,7 +2292,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
: C_O0_I4(rZ, rZ, r, r)); : C_O0_I4(rZ, rZ, r, r));
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -4354,7 +4354,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return C_O1_I4(v, v, v, vZM, v); return C_O1_I4(v, v, v, vZM, v);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -2767,7 +2767,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
case INDEX_op_cmpsel_vec: case INDEX_op_cmpsel_vec:
return C_O1_I4(v, v, vL, vK, vK); return C_O1_I4(v, v, vL, vK, vK);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -3427,7 +3427,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
: C_O1_I4(v, v, v, vZ, v)); : C_O1_I4(v, v, v, vZ, v));
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -1627,7 +1627,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return C_O1_I2(r, r, r); return C_O1_I2(r, r, r);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }

View File

@ -862,6 +862,7 @@ static int tcg_out_pool_finalize(TCGContext *s)
#define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1, I2, I3, I4), #define C_N1_O1_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_n1_o1_i4_, O1, O2, I1, I2, I3, I4),
typedef enum { typedef enum {
C_NotImplemented = -1,
#include "tcg-target-con-set.h" #include "tcg-target-con-set.h"
} TCGConstraintSetIndex; } TCGConstraintSetIndex;
@ -3176,6 +3177,7 @@ static void process_op_defs(TCGContext *s)
const TCGTargetOpDef *tdefs; const TCGTargetOpDef *tdefs;
bool saw_alias_pair = false; bool saw_alias_pair = false;
int i, o, i2, o2, nb_args; int i, o, i2, o2, nb_args;
TCGConstraintSetIndex con_set;
if (def->flags & TCG_OPF_NOT_PRESENT) { if (def->flags & TCG_OPF_NOT_PRESENT) {
continue; continue;
@ -3188,11 +3190,11 @@ static void process_op_defs(TCGContext *s)
/* /*
* Macro magic should make it impossible, but double-check that * Macro magic should make it impossible, but double-check that
* the array index is in range. Since the signness of an enum * the array index is in range. At the same time, double-check
* is implementation defined, force the result to unsigned. * that the opcode is implemented, i.e. not C_NotImplemented.
*/ */
unsigned con_set = tcg_target_op_def(op); con_set = tcg_target_op_def(op);
tcg_debug_assert(con_set < ARRAY_SIZE(constraint_sets)); tcg_debug_assert(con_set >= 0 && con_set < ARRAY_SIZE(constraint_sets));
tdefs = &constraint_sets[con_set]; tdefs = &constraint_sets[con_set];
for (i = 0; i < nb_args; i++) { for (i = 0; i < nb_args; i++) {

View File

@ -186,7 +186,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
return TCG_TARGET_REG_BITS == 64 ? C_O0_I2(r, r) : C_O0_I4(r, r, r, r); return TCG_TARGET_REG_BITS == 64 ? C_O0_I2(r, r) : C_O0_I4(r, r, r, r);
default: default:
g_assert_not_reached(); return C_NotImplemented;
} }
} }