mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
inline asm: Fix 'P' and accept some r<nr> registers
A 'P' template modifier should avoid adding a '$' to literal arguments. Also accept the numbered r8+ registers in an inline asm clobber list (ignoring them for now).
This commit is contained in:
parent
10c3514889
commit
f9423ff3fa
10
i386-asm.c
10
i386-asm.c
@ -1285,7 +1285,8 @@ ST_FUNC void subst_asm_operand(CString *add_str,
|
||||
|
||||
r = sv->r;
|
||||
if ((r & VT_VALMASK) == VT_CONST) {
|
||||
if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n')
|
||||
if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n' &&
|
||||
modifier != 'P')
|
||||
cstr_ccat(add_str, '$');
|
||||
if (r & VT_SYM) {
|
||||
cstr_cat(add_str, get_tok_str(sv->sym->v, NULL), -1);
|
||||
@ -1489,9 +1490,16 @@ ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
} else if (reg >= TOK_ASM_rax && reg <= TOK_ASM_rdi) {
|
||||
reg -= TOK_ASM_rax;
|
||||
} else if (1 && str[0] == 'r' &&
|
||||
(((str[1] == '8' || str[1] == '9') && str[2] == 0) ||
|
||||
(str[1] == '1' && str[2] >= '0' && str[2] <= '5' &&
|
||||
str[3] == 0))) {
|
||||
/* Do nothing for now. We can't parse the high registers. */
|
||||
goto end;
|
||||
#endif
|
||||
} else {
|
||||
tcc_error("invalid clobber register '%s'", str);
|
||||
}
|
||||
clobber_regs[reg] = 1;
|
||||
end:;
|
||||
}
|
||||
|
8
tccasm.c
8
tccasm.c
@ -1043,10 +1043,10 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands,
|
||||
}
|
||||
modifier = 0;
|
||||
if (*str == 'c' || *str == 'n' ||
|
||||
*str == 'b' || *str == 'w' ||
|
||||
*str == 'h' || *str == 'k' || *str == 'q' ||
|
||||
/* P in GCC would add "@PLT" to symbol refs in PIC mode
|
||||
Ignore this in TCC. */
|
||||
*str == 'b' || *str == 'w' || *str == 'h' || *str == 'k' ||
|
||||
*str == 'q' ||
|
||||
/* P in GCC would add "@PLT" to symbol refs in PIC mode,
|
||||
and make literal operands not be decorated with '$'. */
|
||||
*str == 'P')
|
||||
modifier = *str++;
|
||||
index = find_constraint(operands, nb_operands, str, &str);
|
||||
|
Loading…
Reference in New Issue
Block a user