On Wed, 18 Aug 2021 at 22:32, Richard Henderson <richard.hender...@linaro.org> wrote: > > From armv6, the architecture supports unaligned accesses. > All we need to do is perform the correct alignment check > in tcg_out_tlb_read and not use LDRD/STRD when the access > is not aligned. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > @@ -1578,27 +1576,32 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg > addrlo, TCGReg addrhi, > > /* > * Check alignment, check comparators. > - * Do this in no more than 3 insns. Use MOVW for v7, if possible, > + * Do this in 2-4 insns. Use MOVW for v7, if possible, > * to reduce the number of sequential conditional instructions. > * Almost all guests have at least 4k pages, which means that we need > * to clear at least 9 bits even for an 8-byte memory, which means it > * isn't worth checking for an immediate operand for BIC. > */ > + /* For unaligned accesses, test the page of the last byte. */ > + t_addr = addrlo; > + if (a_mask < s_mask) { > + t_addr = TCG_REG_R0; > + tcg_out_dat_imm(s, COND_AL, ARITH_ADD, t_addr, > + addrlo, s_mask - a_mask); > + }
I don't understand what this comment means or why we're doing the addition. If we know we need to check eg whether the address is 2-aligned, why aren't we just checking whether it's 2-aligned ? Could you expand on the explanation a bit? thanks -- PMM