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).
Unified · Split
| @@ -1285,7 +1285,8 @@ ST_FUNC void subst_asm_operand(CString *add_str, · 1284 unmodified lines | |||
| 1285 | 1285 | ||
| 1286 | r = sv->r; | 1286 | r = sv->r; |
| 1287 | if ((r & VT_VALMASK) == VT_CONST) { | 1287 | if ((r & VT_VALMASK) == VT_CONST) { |
| 1288 | if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n') | 1288 | if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n' && |
| 1289 | modifier != 'P') | ||
| 1289 | cstr_ccat(add_str, '$'); | 1290 | cstr_ccat(add_str, '$'); |
| 1290 | if (r & VT_SYM) { | 1291 | if (r & VT_SYM) { |
| 1291 | cstr_cat(add_str, get_tok_str(sv->sym->v, NULL), -1); | 1292 | 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) · 197 unmodified lines | |||
| 1489 | #ifdef TCC_TARGET_X86_64 | 1490 | #ifdef TCC_TARGET_X86_64 |
| 1490 | } else if (reg >= TOK_ASM_rax && reg <= TOK_ASM_rdi) { | 1491 | } else if (reg >= TOK_ASM_rax && reg <= TOK_ASM_rdi) { |
| 1491 | reg -= TOK_ASM_rax; | 1492 | reg -= TOK_ASM_rax; |
| 1493 | } else if (1 && str[0] == 'r' && | ||
| 1494 | (((str[1] == '8' || str[1] == '9') && str[2] == 0) || | ||
| 1495 | (str[1] == '1' && str[2] >= '0' && str[2] <= '5' && | ||
| 1496 | str[3] == 0))) { | ||
| 1497 | /* Do nothing for now. We can't parse the high registers. */ | ||
| 1498 | goto end; | ||
| 1492 | #endif | 1499 | #endif |
| 1493 | } else { | 1500 | } else { |
| 1494 | tcc_error("invalid clobber register '%s'", str); | 1501 | tcc_error("invalid clobber register '%s'", str); |
| 1495 | } | 1502 | } |
| 1496 | clobber_regs[reg] = 1; | 1503 | clobber_regs[reg] = 1; |
| 1504 | end:; | ||
| 1497 | } | 1505 | } |
| @@ -1043,10 +1043,10 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands, · 1042 unmodified lines | |||
| 1043 | } | 1043 | } |
| 1044 | modifier = 0; | 1044 | modifier = 0; |
| 1045 | if (*str == 'c' || *str == 'n' || | 1045 | if (*str == 'c' || *str == 'n' || |
| 1046 | *str == 'b' || *str == 'w' || | 1046 | *str == 'b' || *str == 'w' || *str == 'h' || *str == 'k' || |
| 1047 | *str == 'h' || *str == 'k' || *str == 'q' || | 1047 | *str == 'q' || |
| 1048 | /* P in GCC would add "@PLT" to symbol refs in PIC mode | 1048 | /* P in GCC would add "@PLT" to symbol refs in PIC mode, |
| 1049 | Ignore this in TCC. */ | 1049 | and make literal operands not be decorated with '$'. */ |
| 1050 | *str == 'P') | 1050 | *str == 'P') |
| 1051 | modifier = *str++; | 1051 | modifier = *str++; |
| 1052 | index = find_constraint(operands, nb_operands, str, &str); | 1052 | index = find_constraint(operands, nb_operands, str, &str); |