tcg: Merge tcg_register_helper into tcg_context_init
Eliminates the repeated checks for having created the s->helpers hash table. Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
4953ee6271
commit
84fd9dd3f7
21
tcg/tcg.c
21
tcg/tcg.c
@ -288,6 +288,7 @@ void tcg_context_init(TCGContext *s)
|
|||||||
TCGOpDef *def;
|
TCGOpDef *def;
|
||||||
TCGArgConstraint *args_ct;
|
TCGArgConstraint *args_ct;
|
||||||
int *sorted_args;
|
int *sorted_args;
|
||||||
|
GHashTable *helper_table;
|
||||||
|
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
s->nb_globals = 0;
|
s->nb_globals = 0;
|
||||||
@ -314,8 +315,12 @@ void tcg_context_init(TCGContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register helpers. */
|
/* Register helpers. */
|
||||||
|
/* Use g_direct_hash/equal for direct pointer comparisons on func. */
|
||||||
|
s->helpers = helper_table = g_hash_table_new(NULL, NULL);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
|
for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
|
||||||
tcg_register_helper(all_helpers[i].func, all_helpers[i].name);
|
g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
|
||||||
|
(gpointer)all_helpers[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcg_target_init(s);
|
tcg_target_init(s);
|
||||||
@ -653,20 +658,6 @@ int tcg_check_temp_count(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void tcg_register_helper(void *func, const char *name)
|
|
||||||
{
|
|
||||||
TCGContext *s = &tcg_ctx;
|
|
||||||
GHashTable *table = s->helpers;
|
|
||||||
|
|
||||||
if (table == NULL) {
|
|
||||||
/* Use g_direct_hash/equal for direct pointer comparisons on func. */
|
|
||||||
table = g_hash_table_new(NULL, NULL);
|
|
||||||
s->helpers = table;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_insert(table, (gpointer)func, (gpointer)name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note: we convert the 64 bit args to 32 bit and do some alignment
|
/* Note: we convert the 64 bit args to 32 bit and do some alignment
|
||||||
and endian swap. Maybe it would be better to do the alignment
|
and endian swap. Maybe it would be better to do the alignment
|
||||||
and endian swap in tcg_reg_alloc_call(). */
|
and endian swap in tcg_reg_alloc_call(). */
|
||||||
|
@ -672,7 +672,6 @@ TCGArg *tcg_optimize(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg *args,
|
|||||||
TCGOpDef *tcg_op_def);
|
TCGOpDef *tcg_op_def);
|
||||||
|
|
||||||
/* only used for debugging purposes */
|
/* only used for debugging purposes */
|
||||||
void tcg_register_helper(void *func, const char *name);
|
|
||||||
void tcg_dump_ops(TCGContext *s);
|
void tcg_dump_ops(TCGContext *s);
|
||||||
|
|
||||||
void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
|
void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user