[PATCH v2] RISC-V: map zext.h to pack/packw if Zbkb is enabled
Nelson Chu
nelson@rivosinc.com
Tue Aug 6 08:13:57 GMT 2024
Andrew, thanks for clarifying, so committed after passing
rv32/64gc-elf/linux binutils test cases.
Nelson
On Tue, Aug 6, 2024 at 3:54 PM Andrew Waterman <andrew@sifive.com> wrote:
> LGTM.
>
> There has been some confusion about which extensions contain the
> zext.h instruction. According to the ISA spec, Zbb contains zext.h,
> and Zbkb contains pack[w]. But pack[w] with rs2=x0 _is_ zext.h. By
> implication, it is correct to say that Zbkb contains zext.h, even
> though the spec does not say so explicitly. To this end, I'll propose
> a non-normative clarification to the ISA spec. Regardless, this patch
> seems like the way to go.
>
>
> On Mon, Aug 5, 2024 at 8:56 PM Hau Hsu <hau.hsu@sifive.com> wrote:
> >
> > `zext.h` is zero-extend halfword instruction that belongs to Zbb.
> > Currently `zext.h` falls back to 2 shifts if Zbb is not enabled.
> > However the encoding and operation is a special case of
> > `pack/packw rd, rs1, rs2`, which belongs to Zbkb. The instructions pack
> > the low halves of rs1 and rs2 into rd. When rs2 is zero (x0), they
> > behave like zero-extend instruction, and the encoding are exactly the
> > same as zext.h.
> >
> > Thus we can map `zext.h` to `pack` or `packw` (rv64) if Zbkb is enabled,
> > instead of 2 shifts. This reduces one instruction.
> >
> > This patch does this by making `zext.h` also available for Zbkb.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20240806/c77d05d1/attachment-0001.htm>
More information about the Binutils
mailing list