___
}
+{
+my ($ret) = ('a0');
+$code .= <<___;
+################################################################################
+# size_t riscv_vlen_asm(void)
+# Return VLEN (i.e. the length of a vector register in bits).
+.p2align 3
+.globl riscv_vlen_asm
+.type riscv_vlen_asm,\@function
+riscv_vlen_asm:
+ csrr $ret, vlenb
+ slli $ret, $ret, 3
+ ret
+.size riscv_vlen_asm,.-riscv_vlen_asm
+___
+}
print $code;
close STDOUT or die "error closing STDOUT: $!";
#define OPENSSL_RISCVCAP_IMPL
#include "crypto/riscv_arch.h"
+extern size_t riscv_vlen_asm(void);
+
static void parse_env(const char *envstr);
static void strtoupper(char *str);
+static size_t vlen = 0;
+
uint32_t OPENSSL_rdtsc(void)
{
return 0;
}
}
+size_t riscv_vlen(void)
+{
+ return vlen;
+}
+
# if defined(__GNUC__) && __GNUC__>=2
__attribute__ ((constructor))
# endif
if ((e = getenv("OPENSSL_riscvcap"))) {
parse_env(e);
- return;
+ }
+
+ if (RISCV_HAS_V()) {
+ vlen = riscv_vlen_asm();
}
}
RISCV_DEFINE_CAP(ZKSH, 0, 11)
RISCV_DEFINE_CAP(ZKR, 0, 12)
RISCV_DEFINE_CAP(ZKT, 0, 13)
+RISCV_DEFINE_CAP(V, 0, 14)
/*
* In the future ...
#define RISCV_HAS_ZBKB_AND_ZKND_AND_ZKNE() (RISCV_HAS_ZBKB() && RISCV_HAS_ZKND() && RISCV_HAS_ZKNE())
#define RISCV_HAS_ZKND_AND_ZKNE() (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE())
+/*
+ * Get the size of a vector register in bits (VLEN).
+ * If RISCV_HAS_V() is false, then this returns 0.
+ */
+size_t riscv_vlen(void);
+
#endif