mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
tcg/i386: Split out constraint sets to tcg-target-con-set.h
This exports the constraint sets from tcg_target_op_def to a place we will be able to manipulate more in future. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
8c07f3262e
commit
4c22e84088
4 changed files with 242 additions and 127 deletions
119
tcg/tcg.c
119
tcg/tcg.c
|
@ -69,7 +69,9 @@
|
|||
/* Forward declarations for functions declared in tcg-target.c.inc and
|
||||
used here. */
|
||||
static void tcg_target_init(TCGContext *s);
|
||||
#ifndef TCG_TARGET_CON_SET_H
|
||||
static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode);
|
||||
#endif
|
||||
static void tcg_target_qemu_prologue(TCGContext *s);
|
||||
static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
|
||||
intptr_t value, intptr_t addend);
|
||||
|
@ -347,6 +349,112 @@ static void set_jmp_reset_offset(TCGContext *s, int which)
|
|||
s->tb_jmp_reset_offset[which] = tcg_current_code_size(s);
|
||||
}
|
||||
|
||||
#ifdef TCG_TARGET_CON_SET_H
|
||||
#define C_PFX1(P, A) P##A
|
||||
#define C_PFX2(P, A, B) P##A##_##B
|
||||
#define C_PFX3(P, A, B, C) P##A##_##B##_##C
|
||||
#define C_PFX4(P, A, B, C, D) P##A##_##B##_##C##_##D
|
||||
#define C_PFX5(P, A, B, C, D, E) P##A##_##B##_##C##_##D##_##E
|
||||
#define C_PFX6(P, A, B, C, D, E, F) P##A##_##B##_##C##_##D##_##E##_##F
|
||||
|
||||
/* Define an enumeration for the various combinations. */
|
||||
|
||||
#define C_O0_I1(I1) C_PFX1(c_o0_i1_, I1),
|
||||
#define C_O0_I2(I1, I2) C_PFX2(c_o0_i2_, I1, I2),
|
||||
#define C_O0_I3(I1, I2, I3) C_PFX3(c_o0_i3_, I1, I2, I3),
|
||||
#define C_O0_I4(I1, I2, I3, I4) C_PFX4(c_o0_i4_, I1, I2, I3, I4),
|
||||
|
||||
#define C_O1_I1(O1, I1) C_PFX2(c_o1_i1_, O1, I1),
|
||||
#define C_O1_I2(O1, I1, I2) C_PFX3(c_o1_i2_, O1, I1, I2),
|
||||
#define C_O1_I3(O1, I1, I2, I3) C_PFX4(c_o1_i3_, O1, I1, I2, I3),
|
||||
#define C_O1_I4(O1, I1, I2, I3, I4) C_PFX5(c_o1_i4_, O1, I1, I2, I3, I4),
|
||||
|
||||
#define C_N1_I2(O1, I1, I2) C_PFX3(c_n1_i2_, O1, I1, I2),
|
||||
|
||||
#define C_O2_I1(O1, O2, I1) C_PFX3(c_o2_i1_, O1, O2, I1),
|
||||
#define C_O2_I2(O1, O2, I1, I2) C_PFX4(c_o2_i2_, O1, O2, I1, I2),
|
||||
#define C_O2_I3(O1, O2, I1, I2, I3) C_PFX5(c_o2_i3_, O1, O2, I1, I2, I3),
|
||||
#define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I3, I4),
|
||||
|
||||
typedef enum {
|
||||
#include "tcg-target-con-set.h"
|
||||
} TCGConstraintSetIndex;
|
||||
|
||||
static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode);
|
||||
|
||||
#undef C_O0_I1
|
||||
#undef C_O0_I2
|
||||
#undef C_O0_I3
|
||||
#undef C_O0_I4
|
||||
#undef C_O1_I1
|
||||
#undef C_O1_I2
|
||||
#undef C_O1_I3
|
||||
#undef C_O1_I4
|
||||
#undef C_N1_I2
|
||||
#undef C_O2_I1
|
||||
#undef C_O2_I2
|
||||
#undef C_O2_I3
|
||||
#undef C_O2_I4
|
||||
|
||||
/* Put all of the constraint sets into an array, indexed by the enum. */
|
||||
|
||||
#define C_O0_I1(I1) { .args_ct_str = { #I1 } },
|
||||
#define C_O0_I2(I1, I2) { .args_ct_str = { #I1, #I2 } },
|
||||
#define C_O0_I3(I1, I2, I3) { .args_ct_str = { #I1, #I2, #I3 } },
|
||||
#define C_O0_I4(I1, I2, I3, I4) { .args_ct_str = { #I1, #I2, #I3, #I4 } },
|
||||
|
||||
#define C_O1_I1(O1, I1) { .args_ct_str = { #O1, #I1 } },
|
||||
#define C_O1_I2(O1, I1, I2) { .args_ct_str = { #O1, #I1, #I2 } },
|
||||
#define C_O1_I3(O1, I1, I2, I3) { .args_ct_str = { #O1, #I1, #I2, #I3 } },
|
||||
#define C_O1_I4(O1, I1, I2, I3, I4) { .args_ct_str = { #O1, #I1, #I2, #I3, #I4 } },
|
||||
|
||||
#define C_N1_I2(O1, I1, I2) { .args_ct_str = { "&" #O1, #I1, #I2 } },
|
||||
|
||||
#define C_O2_I1(O1, O2, I1) { .args_ct_str = { #O1, #O2, #I1 } },
|
||||
#define C_O2_I2(O1, O2, I1, I2) { .args_ct_str = { #O1, #O2, #I1, #I2 } },
|
||||
#define C_O2_I3(O1, O2, I1, I2, I3) { .args_ct_str = { #O1, #O2, #I1, #I2, #I3 } },
|
||||
#define C_O2_I4(O1, O2, I1, I2, I3, I4) { .args_ct_str = { #O1, #O2, #I1, #I2, #I3, #I4 } },
|
||||
|
||||
static const TCGTargetOpDef constraint_sets[] = {
|
||||
#include "tcg-target-con-set.h"
|
||||
};
|
||||
|
||||
|
||||
#undef C_O0_I1
|
||||
#undef C_O0_I2
|
||||
#undef C_O0_I3
|
||||
#undef C_O0_I4
|
||||
#undef C_O1_I1
|
||||
#undef C_O1_I2
|
||||
#undef C_O1_I3
|
||||
#undef C_O1_I4
|
||||
#undef C_N1_I2
|
||||
#undef C_O2_I1
|
||||
#undef C_O2_I2
|
||||
#undef C_O2_I3
|
||||
#undef C_O2_I4
|
||||
|
||||
/* Expand the enumerator to be returned from tcg_target_op_def(). */
|
||||
|
||||
#define C_O0_I1(I1) C_PFX1(c_o0_i1_, I1)
|
||||
#define C_O0_I2(I1, I2) C_PFX2(c_o0_i2_, I1, I2)
|
||||
#define C_O0_I3(I1, I2, I3) C_PFX3(c_o0_i3_, I1, I2, I3)
|
||||
#define C_O0_I4(I1, I2, I3, I4) C_PFX4(c_o0_i4_, I1, I2, I3, I4)
|
||||
|
||||
#define C_O1_I1(O1, I1) C_PFX2(c_o1_i1_, O1, I1)
|
||||
#define C_O1_I2(O1, I1, I2) C_PFX3(c_o1_i2_, O1, I1, I2)
|
||||
#define C_O1_I3(O1, I1, I2, I3) C_PFX4(c_o1_i3_, O1, I1, I2, I3)
|
||||
#define C_O1_I4(O1, I1, I2, I3, I4) C_PFX5(c_o1_i4_, O1, I1, I2, I3, I4)
|
||||
|
||||
#define C_N1_I2(O1, I1, I2) C_PFX3(c_n1_i2_, O1, I1, I2)
|
||||
|
||||
#define C_O2_I1(O1, O2, I1) C_PFX3(c_o2_i1_, O1, O2, I1)
|
||||
#define C_O2_I2(O1, O2, I1, I2) C_PFX4(c_o2_i2_, O1, O2, I1, I2)
|
||||
#define C_O2_I3(O1, O2, I1, I2, I3) C_PFX5(c_o2_i3_, O1, O2, I1, I2, I3)
|
||||
#define C_O2_I4(O1, O2, I1, I2, I3, I4) C_PFX6(c_o2_i4_, O1, O2, I1, I2, I3, I4)
|
||||
|
||||
#endif /* TCG_TARGET_CON_SET_H */
|
||||
|
||||
#include "tcg-target.c.inc"
|
||||
|
||||
/* compare a pointer @ptr and a tb_tc @s */
|
||||
|
@ -2424,9 +2532,20 @@ static void process_op_defs(TCGContext *s)
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef TCG_TARGET_CON_SET_H
|
||||
/*
|
||||
* Macro magic should make it impossible, but double-check that
|
||||
* the array index is in range. Since the signness of an enum
|
||||
* is implementation defined, force the result to unsigned.
|
||||
*/
|
||||
unsigned con_set = tcg_target_op_def(op);
|
||||
tcg_debug_assert(con_set < ARRAY_SIZE(constraint_sets));
|
||||
tdefs = &constraint_sets[con_set];
|
||||
#else
|
||||
tdefs = tcg_target_op_def(op);
|
||||
/* Missing TCGTargetOpDef entry. */
|
||||
tcg_debug_assert(tdefs != NULL);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < nb_args; i++) {
|
||||
const char *ct_str = tdefs->args_ct_str[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue