Go to the documentation of this file.
19 #ifndef AVUTIL_RISCV_INTMATH_H
20 #define AVUTIL_RISCV_INTMATH_H
31 #define av_clip_int8 av_clip_int8_rvi
34 union { uint8_t
u; int8_t
s; }
u = { .u =
a };
37 a = ((
a >> 31) ^ 0x7F);
41 #define av_clip_int16 av_clip_int16_rvi
44 union { uint16_t
u; int16_t
s; }
u = { .u =
a };
47 a = ((
a >> 31) ^ 0x7FFF);
51 #define av_clipl_int32 av_clipl_int32_rvi
57 a = ((
a >> 63) ^ 0x7FFFFFFF);
61 #define av_clip_intp2 av_clip_intp2_rvi
64 const int shift = 31 - p;
68 b = (
a >> 31) ^ ((1 << p) - 1);
72 #if defined (__riscv_zbb) && (__riscv_zbb > 0) && HAVE_INLINE_ASM
74 #define av_popcount av_popcount_rvb
79 #if (__riscv_xlen >= 64)
80 __asm__ (
"cpopw %0, %1\n" :
"=r" (
ret) :
"r" (x));
82 __asm__ (
"cpop %0, %1\n" :
"=r" (
ret) :
"r" (x));
87 #if (__riscv_xlen >= 64)
88 #define av_popcount64 av_popcount64_rvb
93 #if (__riscv_xlen >= 128)
94 __asm__ (
"cpopd %0, %1\n" :
"=r" (
ret) :
"r" (x));
96 __asm__ (
"cpop %0, %1\n" :
"=r" (
ret) :
"r" (x));
#define u(width, name, range_min, range_max)
static av_always_inline av_const int32_t av_clipl_int32_rvi(int64_t a)
static av_always_inline av_const int8_t av_clip_int8_rvi(int a)
static int shift(int a, int b)
static av_always_inline av_const int av_clip_intp2_rvi(int a, int p)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
static av_always_inline av_const int16_t av_clip_int16_rvi(int a)