qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-riscv] [RFC v2 24/24] WIP: Try to patch longer branches


From: Richard Henderson
Subject: Re: [Qemu-riscv] [RFC v2 24/24] WIP: Try to patch longer branches
Date: Wed, 28 Nov 2018 12:39:54 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

On 11/27/18 1:10 PM, Alistair Francis wrote:
> +        if (short_jmp) {
> +            reloc_sbimm12(code_ptr, (tcg_insn_unit *)value);
> +        } else {
> +            /* Invert the condition */
> +            insn = insn ^ (1 << 12);
> +            /* Clear the offset */
> +            insn &= 0xFFF;
> +            /* Set the offset to the PC + 8 */
> +            insn |= ((unsigned int)(code_ptr + 8)) << 12;

This isn't a pc-relative value you're storing.

    reloc_sbimm12(code_ptr, code_ptr + 2);

> +            /* Overwrite the NOP with jal x0,value */
> +            insn = encode_uj(OPC_JAL, TCG_REG_ZERO, value);

This isn't pc-relative either.  Perhaps best as

    code_ptr[1] = encode_uj(OPC_JAL, TCG_REG_ZERO, 0);
    reloc_jimm20(code_ptr + 1, (tcg_insn_unit *)value);


r~





reply via email to

[Prev in Thread] Current Thread [Next in Thread]