Unified · Split
| @@ -62,6 +62,7 @@ static void asm_ternary_opcode(TCCState *s1, int token); · 61 unmodified lines | ||
| 62 | 62 | static void asm_unary_opcode(TCCState *s1, int token); |
| 63 | 63 | ST_FUNC void gen_expr32(ExprValue *pe); |
| 64 | 64 | static void parse_operand(TCCState *s1, Operand *op); |
| 65 | +static void parse_operands(TCCState *s1, Operand *ops, int count); | |
| 65 | 66 | ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier); |
| 66 | 67 | /* C extension */ |
| 67 | 68 | static void asm_emit_ca(int token, uint16_t opcode, const Operand *rd, const Operand *rs2); |
| @@ -209,13 +210,26 @@ static void parse_operand(TCCState *s1, Operand *op) · 141 unmodified lines | ||
| 209 | 210 | } |
| 210 | 211 | } |
| 211 | 212 | |
| 213 | +static void parse_operands(TCCState *s1, Operand* ops, int count){ | |
| 214 | + int i; | |
| 215 | + for (i = 0; i < count; i++) { | |
| 216 | + if ( i != 0 ) { | |
| 217 | + if ( tok == ',') | |
| 218 | + next(); | |
| 219 | + else | |
| 220 | + expect("','"); | |
| 221 | + } | |
| 222 | + parse_operand(s1, &ops[i]); | |
| 223 | + } | |
| 224 | +} | |
| 225 | + | |
| 212 | 226 | static void asm_unary_opcode(TCCState *s1, int token) |
| 213 | 227 | { |
| 214 | 228 | uint32_t opcode = (0x1C << 2) | 3 | (2 << 12); |
| 215 | 229 | Operand op; |
| 216 | 230 | static const Operand nil = {.type = OP_REG}; |
| 217 | 231 | |
| 218 | − parse_operand(s1, &op); | |
| 232 | + parse_operands(s1, &op, 1); | |
| 219 | 233 | /* Note: Those all map to CSR--so they are pseudo-instructions. */ |
| 220 | 234 | opcode |= ENCODE_RD(op.reg); |
| 221 | 235 | |
| @@ -280,12 +294,7 @@ static void asm_emit_u(int token, uint32_t opcode, const Operand* rd, const Oper · 58 unmodified lines | ||
| 280 | 294 | static void asm_binary_opcode(TCCState* s1, int token) |
| 281 | 295 | { |
| 282 | 296 | Operand ops[2]; |
| 283 | − parse_operand(s1, &ops[0]); | |
| 284 | − if (tok == ',') | |
| 285 | − next(); | |
| 286 | − else | |
| 287 | − expect("','"); | |
| 288 | − parse_operand(s1, &ops[1]); | |
| 297 | + parse_operands(s1, &ops[0], 2); | |
| 289 | 298 | |
| 290 | 299 | switch (token) { |
| 291 | 300 | case TOK_ASM_lui: |
| @@ -499,17 +508,7 @@ static void asm_emit_j(int token, uint32_t opcode, const Operand* rd, const Oper · 207 unmodified lines | ||
| 499 | 508 | static void asm_ternary_opcode(TCCState *s1, int token) |
| 500 | 509 | { |
| 501 | 510 | Operand ops[3]; |
| 502 | − parse_operand(s1, &ops[0]); | |
| 503 | − if (tok == ',') | |
| 504 | − next(); | |
| 505 | − else | |
| 506 | − expect("','"); | |
| 507 | − parse_operand(s1, &ops[1]); | |
| 508 | − if (tok == ',') | |
| 509 | − next(); | |
| 510 | − else | |
| 511 | − expect("','"); | |
| 512 | − parse_operand(s1, &ops[2]); | |
| 511 | + parse_operands(s1, &ops[0], 3); | |
| 513 | 512 | |
| 514 | 513 | switch (token) { |
| 515 | 514 | case TOK_ASM_sll: |