py/asmarm: Fix locals address loading code generation with large imm.
This commit fixes code generation for loading a local's address if its index is greater than 63. The old code blindly encoded the offset into an `ADD Rd, Rn, #imm` opcode, but only the lowest 8 bits would be put into the opcode itself. This commit instead generates a two-opcodes sequence, a constant load into R8, and then an `ADD Rd, Rn, R8` opcode. This fixes `tests/float/math_domain.py` for the qemu/SABRELITE board. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
committed by
Damien George
parent
e84c9abfc2
commit
928c71638c
11
py/asmarm.c
11
py/asmarm.c
@@ -292,8 +292,15 @@ void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num) {
|
void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num) {
|
||||||
// add rd, sp, #local_num*4
|
if (local_num >= 0x40) {
|
||||||
emit_al(as, asm_arm_op_add_imm(rd, ASM_ARM_REG_SP, local_num << 2));
|
// mov r8, #local_num*4
|
||||||
|
// add rd, sp, r8
|
||||||
|
asm_arm_mov_reg_i32_optimised(as, ASM_ARM_REG_R8, local_num << 2);
|
||||||
|
emit_al(as, asm_arm_op_add_reg(rd, ASM_ARM_REG_SP, ASM_ARM_REG_R8));
|
||||||
|
} else {
|
||||||
|
// add rd, sp, #local_num*4
|
||||||
|
emit_al(as, asm_arm_op_add_imm(rd, ASM_ARM_REG_SP, local_num << 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void asm_arm_mov_reg_pcrel(asm_arm_t *as, uint reg_dest, uint label) {
|
void asm_arm_mov_reg_pcrel(asm_arm_t *as, uint reg_dest, uint label) {
|
||||||
|
|||||||
Reference in New Issue
Block a user