mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 16:36:53 +00:00
tcg: Pass the opcode width to target_parse_constraint
This will let us choose how to interpret a given constraint depending on whether the opcode is 32- or 64-bit. Which will let us share more constraint combinations between opcodes. At the same time, change the interface to return the advanced pointer instead of passing it in/out by reference. Backports commit 069ea736b50b75fdec99c9b8cc603b97bd98419e from qemu
This commit is contained in:
parent
b8c93597b4
commit
3f38611159
|
@ -119,12 +119,10 @@ static inline void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
#define TCG_CT_CONST_MONE 0x800
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str = *pct_str;
|
||||
|
||||
switch (ct_str[0]) {
|
||||
switch (*ct_str++) {
|
||||
case 'r':
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set32(ct->u.regs, 0, (1ULL << TCG_TARGET_NB_REGS) - 1);
|
||||
|
@ -154,12 +152,9 @@ static int target_parse_constraint(TCGArgConstraint *ct,
|
|||
ct->ct |= TCG_CT_CONST_ZERO;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
static inline bool is_aimm(uint64_t val)
|
||||
|
|
|
@ -124,12 +124,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
#define TCG_CT_CONST_ZERO 0x800
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str;
|
||||
|
||||
ct_str = *pct_str;
|
||||
switch (ct_str[0]) {
|
||||
switch (*ct_str++) {
|
||||
case 'I':
|
||||
ct->ct |= TCG_CT_CONST_ARM;
|
||||
break;
|
||||
|
@ -182,12 +180,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
static inline uint32_t rotl(uint32_t val, int n)
|
||||
|
|
|
@ -173,12 +173,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
}
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str;
|
||||
|
||||
ct_str = *pct_str;
|
||||
switch(ct_str[0]) {
|
||||
switch(*ct_str++) {
|
||||
case 'a':
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set_reg(ct->u.regs, TCG_REG_EAX);
|
||||
|
@ -256,11 +254,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
/* test if a constant matches the constraint */
|
||||
|
|
|
@ -186,12 +186,10 @@ static inline bool is_p2m1(tcg_target_long val)
|
|||
}
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str;
|
||||
|
||||
ct_str = *pct_str;
|
||||
switch(ct_str[0]) {
|
||||
switch(*ct_str++) {
|
||||
case 'r':
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set(ct->u.regs, 0xffffffff);
|
||||
|
@ -238,11 +236,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
ct->ct |= TCG_CT_CONST_ZERO;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
/* test if a constant matches the constraint */
|
||||
|
|
|
@ -265,12 +265,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
}
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str;
|
||||
|
||||
ct_str = *pct_str;
|
||||
switch (ct_str[0]) {
|
||||
switch (*ct_str++) {
|
||||
case 'A': case 'B': case 'C': case 'D':
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set_reg(ct->u.regs, 3 + ct_str[0] - 'A');
|
||||
|
@ -317,11 +315,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
ct->ct |= TCG_CT_CONST_ZERO;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
/* test if a constant matches the constraint */
|
||||
|
|
|
@ -365,11 +365,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
}
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str = *pct_str;
|
||||
|
||||
switch (ct_str[0]) {
|
||||
switch (*ct_str++) {
|
||||
case 'r': /* all registers */
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set32(ct->u.regs, 0, 0xffff);
|
||||
|
@ -410,12 +409,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
ct->ct |= TCG_CT_CONST_ZERO;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
/* Immediates to be used with logical OR. This is an optimization only,
|
||||
|
|
|
@ -321,12 +321,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type,
|
|||
}
|
||||
|
||||
/* parse target specific constraints */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type)
|
||||
{
|
||||
const char *ct_str;
|
||||
|
||||
ct_str = *pct_str;
|
||||
switch (ct_str[0]) {
|
||||
switch (*ct_str++) {
|
||||
case 'r':
|
||||
ct->ct |= TCG_CT_REG;
|
||||
tcg_regset_set32(ct->u.regs, 0, 0xffffffff);
|
||||
|
@ -362,11 +360,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
|
|||
ct->ct |= TCG_CT_CONST_ZERO;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
ct_str++;
|
||||
*pct_str = ct_str;
|
||||
return 0;
|
||||
return ct_str;
|
||||
}
|
||||
|
||||
/* test if a constant matches the constraint */
|
||||
|
|
|
@ -92,7 +92,8 @@ QEMU_PACK( typedef struct {
|
|||
}) DebugFrameHeader;
|
||||
|
||||
/* Forward declarations for functions declared and used in tcg-target.inc.c. */
|
||||
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str);
|
||||
static const char *target_parse_constraint(TCGArgConstraint *ct,
|
||||
const char *ct_str, TCGType type);
|
||||
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
|
||||
intptr_t arg2);
|
||||
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg);
|
||||
|
@ -1276,7 +1277,8 @@ static void process_op_defs(TCGContext *s)
|
|||
for (op = 0; op < NB_OPS; op++) {
|
||||
TCGOpDef *def = &s->tcg_op_defs[op];
|
||||
const TCGTargetOpDef *tdefs;
|
||||
int i, nb_args, ok;
|
||||
TCGType type;
|
||||
int i, nb_args;
|
||||
|
||||
if (def->flags & TCG_OPF_NOT_PRESENT) {
|
||||
continue;
|
||||
|
@ -1291,6 +1293,7 @@ static void process_op_defs(TCGContext *s)
|
|||
/* Missing TCGTargetOpDef entry. */
|
||||
tcg_debug_assert(tdefs != NULL);
|
||||
|
||||
type = (def->flags & TCG_OPF_64BIT ? TCG_TYPE_I64 : TCG_TYPE_I32);
|
||||
for (i = 0; i < nb_args; i++) {
|
||||
const char *ct_str = tdefs->args_ct_str[i];
|
||||
/* Incomplete TCGTargetOpDef entry. */
|
||||
|
@ -1324,9 +1327,10 @@ static void process_op_defs(TCGContext *s)
|
|||
ct_str++;
|
||||
break;
|
||||
default:
|
||||
ok = target_parse_constraint(&def->args_ct[i], &ct_str);
|
||||
ct_str = target_parse_constraint(&def->args_ct[i],
|
||||
ct_str, type);
|
||||
/* Typo in TCGTargetOpDef constraint. */
|
||||
tcg_debug_assert(ok == 0);
|
||||
tcg_debug_assert(ct_str != NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue