History

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).

Michael Matz committed 10 years ago

Commit f9423ff1 parent 10c35142 files · +13 −5Browse files

Unified · Split

2 files
  1. i386-asm.c +9 −1
  2. tccasm.c +4 −4
i386-asm.c+9−1
@@ -1285,7 +1285,8 @@ ST_FUNC void subst_asm_operand(CString *add_str, · 1284 unmodified lines
12851285
12861286 r = sv->r;
12871287 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')
12891290 cstr_ccat(add_str, '$');
12901291 if (r & VT_SYM) {
12911292 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
14891490 #ifdef TCC_TARGET_X86_64
14901491 } else if (reg >= TOK_ASM_rax && reg <= TOK_ASM_rdi) {
14911492 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;
14921499 #endif
14931500 } else {
14941501 tcc_error("invalid clobber register '%s'", str);
14951502 }
14961503 clobber_regs[reg] = 1;
1504+end:;
14971505 }
tccasm.c+4−4
@@ -1043,10 +1043,10 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands, · 1042 unmodified lines
10431043 }
10441044 modifier = 0;
10451045 if (*str == 'c' || *str == 'n' ||
1046− *str == 'b' || *str == 'w' ||
1047− *str == 'h' || *str == 'k' || *str == 'q' ||
1048− /* P in GCC would add "@PLT" to symbol refs in PIC mode
1049− Ignore this in TCC. */
1046+ *str == 'b' || *str == 'w' || *str == 'h' || *str == 'k' ||
1047+ *str == 'q' ||
1048+ /* P in GCC would add "@PLT" to symbol refs in PIC mode,
1049+ and make literal operands not be decorated with '$'. */
10501050 *str == 'P')
10511051 modifier = *str++;
10521052 index = find_constraint(operands, nb_operands, str, &str);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t