diff --git a/arm-asm.c b/arm-asm.c index a6dec4c3..2362d172 100644 --- a/arm-asm.c +++ b/arm-asm.c @@ -3075,7 +3075,6 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, tcc_error ("asm regvar requests register that's taken already"); reg = op->reg; - goto reg_found; } try_next: c = *str++; @@ -3095,7 +3094,9 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, case 'r': // general-purpose register case 'p': // loadable/storable address /* any general register */ - for (reg = 0; reg <= 8; reg++) { + if ((reg = op->reg) >= 0) + goto reg_found; + else for (reg = 0; reg <= 8; reg++) { if (!is_reg_allocated(reg)) goto reg_found; } diff --git a/i386-asm.c b/i386-asm.c index 57bd7e6d..ea734ae8 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -1342,7 +1342,6 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, if (is_reg_allocated(op->reg)) tcc_error("asm regvar requests register that's taken already"); reg = op->reg; - goto reg_found; } try_next: c = *str++; @@ -1385,12 +1384,17 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, case 'D': reg = 7; alloc_reg: + if (op->reg >= 0 && reg != op->reg) + goto try_next; if (is_reg_allocated(reg)) goto try_next; goto reg_found; case 'q': /* eax, ebx, ecx or edx */ - for(reg = 0; reg < 4; reg++) { + if (op->reg >= 0) { + if ((reg = op->reg) < 4) + goto reg_found; + } else for(reg = 0; reg < 4; reg++) { if (!is_reg_allocated(reg)) goto reg_found; } @@ -1399,7 +1403,9 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, case 'R': case 'p': /* A general address, for x86(64) any register is acceptable*/ /* any general register */ - for(reg = 0; reg < 8; reg++) { + if ((reg = op->reg) >= 0) + goto reg_found; + else for(reg = 0; reg < 8; reg++) { if (!is_reg_allocated(reg)) goto reg_found; } diff --git a/riscv64-asm.c b/riscv64-asm.c index 98faf8b5..88af663b 100644 --- a/riscv64-asm.c +++ b/riscv64-asm.c @@ -1720,7 +1720,6 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, tcc_error ("asm regvar requests register that's taken already"); reg = op->reg; - goto reg_found; } try_next: c = *str++; @@ -1739,7 +1738,9 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, case 'p': // loadable/storable address /* any general register */ /* From a0 to a7 */ - for (reg = 10; reg <= 18; reg++) { + if ((reg = op->reg) >= 0) + goto reg_found; + else for (reg = 10; reg <= 18; reg++) { if (!is_reg_allocated(reg)) goto reg_found; } @@ -1753,7 +1754,9 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, case 'f': // floating pont register /* floating point register */ /* From fa0 to fa7 */ - for (reg = 42; reg <= 50; reg++) { + if ((reg = op->reg) >= 0) + goto reg_found; + else for (reg = 42; reg <= 50; reg++) { if (!is_reg_allocated(reg)) goto reg_found; }