ffmpeg/libavcodec/riscv
Rémi Denis-Courmont 378d1b06c3 riscv: probe for Zbb extension at load time
Due to hysterical raisins, most RISC-V Linux distributions target a
RV64GC baseline excluding the Bit-manipulation ISA extensions, most
notably:
- Zba: address generation extension and
- Zbb: basic bit manipulation extension.
Most CPUs that would make sense to run FFmpeg on support Zba and Zbb
(including the current FATE runner), so it makes sense to optimise for
them. In fact a large chunk of existing assembler optimisations relies
on Zba and/or Zbb.

Since we cannot patch shared library code, the next best thing is to
carry a flag initialised at load-time and check it on need basis.
This results in 3 instructions overhead on isolated use, e.g.:
1:  AUIPC rd, %pcrel_hi(ff_rv_zbb_supported)
    LBU   rd, %pcrel_lo(1b)(rd)
    BEQZ  rd, non_Zbb_fallback_code
    // Zbb code here

The C compiler will typically load the flag ahead of time to reducing
latency, and can also keep it around if Zbb is used multiple times in a
single optimisation scope. For this to work, the flag symbol must be
hidden; otherwise the optimisation degrades with a GOT look-up to
support interposition:
1:  AUIPC rd, GOT_OFFSET_HI
    LD    rd, GOT_OFFSET_LO(rd)
    LBU   rd, (rd)
    BEQZ  rd, non_Zbb_fallback_code
    // Zbb code here

This patch adds code to provision the flag in libraries using bit
manipulation functions from libavutil: byte-swap, bit-weight and
counting leading or trailing zeroes.
2024-06-11 20:12:37 +03:00
..
aacencdsp_init.c lavc/aacencdsp: R-V V quant_bands 2024-06-03 22:43:37 +03:00
aacencdsp_rvv.S lavc/aacencdsp: fix rounding in R-V V quantize_bands 2024-06-08 18:30:43 +03:00
aacpsdsp_init.c
aacpsdsp_rvv.S
ac3dsp_init.c
ac3dsp_rvb.S
ac3dsp_rvv.S
ac3dsp_rvvb.S
alacdsp_init.c
alacdsp_rvv.S
audiodsp_init.c
audiodsp_rvf.S
audiodsp_rvv.S
blockdsp_init.c
blockdsp_rvv.S
bswapdsp_init.c
bswapdsp_rvb.S
bswapdsp_rvv.S
cpu_common.c riscv: probe for Zbb extension at load time 2024-06-11 20:12:37 +03:00
exrdsp_init.c
exrdsp_rvv.S
flacdsp_init.c lavc/flacdsp: R-V Zvl256b lpc33 2024-05-27 22:07:29 +03:00
flacdsp_rvv.S lavc/flacdsp: fix sign extension in R-V V wasted33 2024-06-07 17:53:05 +03:00
fmtconvert_init.c
fmtconvert_rvv.S
g722dsp_init.c
g722dsp_rvv.S
h263dsp_init.c
h263dsp_rvv.S
h264_chroma_init_riscv.c
h264_mc_chroma.S
h264dsp_init.c
huffyuvdsp_init.c
huffyuvdsp_rvv.S
idctdsp_init.c
idctdsp_rvv.S
jpeg2000dsp_init.c
jpeg2000dsp_rvv.S
llauddsp_init.c
llauddsp_rvv.S
llviddsp_init.c
llviddsp_rvv.S
llvidencdsp_init.c
llvidencdsp_rvv.S
lpc_init.c lavc/lpc: optimise RVV vector type for compute_autocorr 2024-05-29 16:57:02 +03:00
lpc_rvv.S riscv: allow passing addend to vtype_vli macro 2024-05-30 18:30:52 +03:00
Makefile riscv: probe for Zbb extension at load time 2024-06-11 20:12:37 +03:00
me_cmp_init.c
me_cmp_rvv.S
opusdsp_init.c
opusdsp_rvv.S
pixblockdsp_init.c
pixblockdsp_rvi.S
pixblockdsp_rvv.S
rv34dsp_init.c
rv34dsp_rvv.S lavc/rv34dsp: remove stray load immediate 2024-05-26 19:20:45 +03:00
rv40dsp_init.c
rv40dsp_rvv.S
sbrdsp_init.c lavc/sbrdsp: add support for 256-bit vectors 2024-05-31 22:22:43 +03:00
sbrdsp_rvv.S lavc/sbrdsp: fold immediate offset into relocation 2024-05-28 19:44:11 +03:00
startcode_rvb.S
startcode_rvv.S lavc/startcode: fix RVV return value on no match 2024-05-28 19:43:40 +03:00
svqenc_init.c
svqenc_rvv.S
takdsp_init.c
takdsp_rvv.S
utvideodsp_init.c
utvideodsp_rvv.S
vc1dsp_init.c lavc/vc1dsp: R-V V vc1_inv_trans_4x4 2024-06-07 17:53:05 +03:00
vc1dsp_rvi.S
vc1dsp_rvv.S lavc/vc1dsp: match C block layout in inv_trans_4x8_rvv 2024-06-11 17:15:09 +03:00
vorbisdsp_init.c
vorbisdsp_rvv.S
vp7dsp_init.c lavc/vp7dsp: add R-V V vp7_idct_dc_add4uv 2024-06-04 17:42:07 +03:00
vp7dsp_rvv.S lavc/vp7dsp: add R-V V vp7_idct_dc_add4uv 2024-06-04 17:42:07 +03:00
vp8dsp_init.c lavc/vp8dsp: R-V V vp8_idct_add 2024-06-08 18:30:43 +03:00
vp8dsp_rvi.S
vp8dsp_rvv.S lavc/vp8dsp: R-V V vp8_idct_add 2024-06-08 18:30:43 +03:00
vp8dsp.h
vp9_intra_rvi.S
vp9_intra_rvv.S
vp9_mc_rvi.S
vp9_mc_rvv.S lavc/vp9dsp: R-V V rename ff_avg to ff_vp9_avg 2024-05-30 18:30:52 +03:00
vp9dsp_init.c lavc/vp9dsp: R-V V rename ff_avg to ff_vp9_avg 2024-05-30 18:30:52 +03:00
vp9dsp.h lavc/vp9dsp: R-V V rename ff_avg to ff_vp9_avg 2024-05-30 18:30:52 +03:00