Skip to content

Commit c0bd84c

Browse files
sunyuechipablodelara
authored andcommitted
add R-V V build check
Signed-off-by: sunyuechi <[email protected]>
1 parent 027be4b commit c0bd84c

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

configure.ac

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,7 @@ AM_CONDITIONAL([CPU_AARCH64], [test "$CPU" = "aarch64"])
3939
AM_CONDITIONAL([CPU_PPC64LE], [test "$CPU" = "ppc64le"])
4040
AM_CONDITIONAL([CPU_RISCV64], [test "$CPU" = "riscv64"])
4141
AM_CONDITIONAL([CPU_UNDEFINED], [test "x$CPU" = "x"])
42-
43-
if test "$CPU" = "x86_64"; then
44-
is_x86=yes
45-
else
46-
if test "$CPU" = "x86_32"; then
47-
is_x86=yes
48-
else
49-
is_x86=no
50-
fi
51-
fi
42+
AM_CONDITIONAL([HAVE_RVV], [false])
5243

5344
# Check for programs
5445
AC_PROG_CC_STDC
@@ -59,6 +50,40 @@ AC_PREFIX_DEFAULT([/usr])
5950
AC_PROG_SED
6051
AC_PROG_MKDIR_P
6152

53+
case "${CPU}" in
54+
55+
x86_64)
56+
57+
is_x86=yes
58+
;;
59+
60+
x86_32)
61+
62+
is_x86=yes
63+
;;
64+
65+
riscv64)
66+
67+
AC_MSG_CHECKING([checking RVV support])
68+
AC_COMPILE_IFELSE(
69+
[AC_LANG_PROGRAM([], [
70+
__asm__ volatile(
71+
".option arch, +v\n"
72+
"vsetivli zero, 0, e8, m1, ta, ma\n"
73+
);
74+
])],
75+
[AC_DEFINE([HAVE_RVV], [1], [Enable RVV instructions])
76+
AM_CONDITIONAL([HAVE_RVV], [true]) rvv=yes],
77+
[AM_CONDITIONAL([HAVE_RVV], [false]) rvv=no]
78+
)
79+
AC_MSG_RESULT([$rvv])
80+
;;
81+
82+
*)
83+
is_x86=no
84+
85+
esac
86+
6287
# Options
6388
AC_ARG_ENABLE([debug],
6489
AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),

igzip/riscv64/igzip_isal_adler32_rvv.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
**********************************************************************/
29+
#if HAVE_RVV
2930
.option arch, +v
3031
.global adler32_rvv
3132
.type adler32_rvv, %function
@@ -74,3 +75,4 @@ adler32_rvv:
7475
add a0, t2, t3 // a0 = A + B
7576

7677
ret
78+
#endif

igzip/riscv64/igzip_multibinary_riscv64.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
#include "riscv64_multibinary.h"
3131

32-
mbin_interface isal_adler32
32+
#if HAVE_RVV
33+
mbin_interface isal_adler32
34+
#else
35+
mbin_interface_base isal_adler32, adler32_base
36+
#endif
3337

3438
mbin_interface_base gen_icf_map_lh1, gen_icf_map_h1_base
3539
mbin_interface_base decode_huffman_code_block_stateless, decode_huffman_code_block_stateless_base

igzip/riscv64/igzip_multibinary_riscv64_dispatcher.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030

3131
DEFINE_INTERFACE_DISPATCHER(isal_adler32)
3232
{
33+
#if HAVE_RVV
3334
const unsigned long hwcap = getauxval(AT_HWCAP);
3435
if (hwcap & HWCAP_RV('V'))
3536
return PROVIDER_INFO(adler32_rvv);
3637
else
38+
#endif
3739
return PROVIDER_BASIC(adler32);
3840
}

0 commit comments

Comments
 (0)