Handle 'register long r10 __asm__("%r10")' without %, too. Using GCC the % is optional. The musl source code does not use the % prefix. The GCC source code uses both variants.
Unified · Split
| @@ -1233,8 +1233,8 @@ static const char *skip_constraint_modifiers(const char *p) · 1232 unmodified lines | |||
| 1233 | return p; | 1233 | return p; |
| 1234 | } | 1234 | } |
| 1235 | 1235 | ||
| 1236 | /* If T (a token) is of the form "%reg" returns the register | 1236 | /* If t (a token) is of the form "%reg" or "reg" return the register number and |
| 1237 | number and type, otherwise return -1. */ | 1237 | type, otherwise return -1. With GCC the % is optional, too. */ |
| 1238 | ST_FUNC int asm_parse_regvar (int t) | 1238 | ST_FUNC int asm_parse_regvar (int t) |
| 1239 | { | 1239 | { |
| 1240 | const char *s; | 1240 | const char *s; |
| @@ -1242,13 +1242,14 @@ ST_FUNC int asm_parse_regvar (int t) · 1 unmodified line | |||
| 1242 | if (t < TOK_IDENT || (t & SYM_FIELD)) | 1242 | if (t < TOK_IDENT || (t & SYM_FIELD)) |
| 1243 | return -1; | 1243 | return -1; |
| 1244 | s = table_ident[t - TOK_IDENT]->str; | 1244 | s = table_ident[t - TOK_IDENT]->str; |
| 1245 | if (s[0] != '%') | 1245 | if (s[0] == '%') |
| 1246 | return -1; | 1246 | ++s; |
| 1247 | t = tok_alloc_const(s + 1); | 1247 | t = tok_alloc_const(s); |
| 1248 | unget_tok(t); | 1248 | unget_tok(t); |
| 1249 | /* Internally the % prefix is required. */ | ||
| 1249 | unget_tok('%'); | 1250 | unget_tok('%'); |
| 1250 | parse_operand(tcc_state, &op); | 1251 | parse_operand(tcc_state, &op); |
| 1251 | /* Accept only integer regs for now. */ | 1252 | /* Accept only integer regs for now. */ |
| 1252 | if (op.type & OP_REG) | 1253 | if (op.type & OP_REG) |
| 1253 | return op.reg; | 1254 | return op.reg; |
| 1254 | else | 1255 | else |