Hi Robin,
+# Return 1 if the we can build a vector example with proper -march flags
+# and the current target can execute it, 0 otherwise. Cache the result.
+
+proc check_effective_target_riscv_vector_hw { } {
+
+ return [check_runtime riscv_vector_hw32 {
+ int main (void)
+ {
+ asm ("vsetivli zero,8,e16,m1,ta,ma");
+ asm ("vadd.vv v8,v8,v16" : : : "v8");
+ return 0;
+ }
+ } "-march=rv32gcv -mabi=ilp32d"] || [check_runtime riscv_vector_hw64 {
+ int main (void)
+ {
+ asm ("vsetivli zero,8,e16,m1,ta,ma");
+ asm ("vadd.vv v8,v8,v16" : : : "v8");
+ return 0;
+ }
+ } "-march=rv64gcv -mabi=lp64d"]
+}
+
+# Return 1 if the we can build a Zvfh vector example with proper -march flags
+# and the current target can execute it, 0 otherwise. Cache the result.
+
+proc check_effective_target_riscv_zvfh_hw { } {
+ if ![check_effective_target_riscv_vector_hw] then {
+ return 0
+ }
+
+ return [check_runtime riscv_zvfh_hw32 {
+ int main (void)
+ {
+ asm ("vsetivli zero,8,e16,m1,ta,ma");
+ asm ("vfadd.vv v8,v8,v16" : : : "v8");
+ return 0;
+ }
+ } "-march=rv32gcv_zvfh -mabi=ilp32d"]
+ || [check_runtime riscv_zvfh_hw64 {
+ int main (void)
+ {
+ asm ("vsetivli zero,8,e16,m1,ta,ma");
+ asm ("vfadd.vv v8,v8,v16" : : : "v8");
+ return 0;
+ }
+ } "-march=rv64gcv_zvfh -mabi=lp64d"]
May I ask if the compiler options "-march=rv64gcv_zvfh -mabi=lp64d"
should be removed? Because we don't specify -march and -mabi when we run
testcase (so but why we need to specify the -march and -mabi in this
target check?), we run it with the default values. Assuming that the
default is rv64gcv_zvfh_zfh, `riscv_vector` check will fail because
compile and link with -march=rv64gcv will throw the following error if I
doesn't compile a multilibs compilers. But in fact rv64gcv_zvfh_zfh
contains rv64gcv, we should not let this case report link error.:
riscv64-unknown-elf-gcc: fatal error: Cannot find suitable multilib set
for
'-march=rv64imafdcv_zicsr_zifencei_zve32f_zve32x_zve64d_zve64f_zve64x_zvl128b_zvl32b_zvl64b'/'-mabi=lp64d'
I think we should use the default march and mabi to check whether we can
compile and execute specified instructions.
--
Best,
Lehua