{"zve64f", &gcc_options::x_target_flags, MASK_VECTOR},
{"zve64d", &gcc_options::x_target_flags, MASK_VECTOR},
- /* We don't need to put complete EEW/EEW_FP info here, due to the
+ /* We don't need to put complete ELEN/ELEN_FP info here, due to the
implication relation of vector extension.
- e.g. v -> zve64d ... zve32x, so v has set MASK_VECTOR_EEW_FP_64,
- MASK_VECTOR_EEW_FP_32, MASK_VECTOR_EEW_64 and MASK_VECTOR_EEW_32
+ e.g. v -> zve64d ... zve32x, so v has set MASK_VECTOR_ELEN_FP_64,
+ MASK_VECTOR_ELEN_FP_32, MASK_VECTOR_ELEN_64 and MASK_VECTOR_ELEN_32
due to the extension implication. */
- {"zve32x", &gcc_options::x_riscv_vector_eew_flags, MASK_VECTOR_EEW_32},
- {"zve32f", &gcc_options::x_riscv_vector_eew_flags, MASK_VECTOR_EEW_FP_32},
- {"zve64x", &gcc_options::x_riscv_vector_eew_flags, MASK_VECTOR_EEW_64},
- {"zve64f", &gcc_options::x_riscv_vector_eew_flags, MASK_VECTOR_EEW_FP_32},
- {"zve64d", &gcc_options::x_riscv_vector_eew_flags, MASK_VECTOR_EEW_FP_64},
+ {"zve32x", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_32},
+ {"zve32f", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_32},
+ {"zve64x", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_64},
+ {"zve64f", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_32},
+ {"zve64d", &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_64},
{"zvl32b", &gcc_options::x_riscv_zvl_flags, MASK_ZVL32B},
{"zvl64b", &gcc_options::x_riscv_zvl_flags, MASK_ZVL64B},
}
+ if (TARGET_MIN_VLEN != 0)
+ builtin_define_with_int_value ("__riscv_v_min_vlen", TARGET_MIN_VLEN);
+
+ if (TARGET_VECTOR_ELEN_64)
+ builtin_define_with_int_value ("__riscv_v_elen", 64);
+ else if (TARGET_VECTOR_ELEN_32)
+ builtin_define_with_int_value ("__riscv_v_elen", 32);
+
+ if (TARGET_VECTOR_ELEN_FP_64)
+ builtin_define_with_int_value ("__riscv_v_elen_fp", 64);
+ else if (TARGET_VECTOR_ELEN_FP_32)
+ builtin_define_with_int_value ("__riscv_v_elen_fp", 32);
+ else if (TARGET_MIN_VLEN != 0)
+ builtin_define_with_int_value ("__riscv_v_elen_fp", 0);
+
+ if (TARGET_MIN_VLEN)
+ builtin_define ("__riscv_vector");
+
/* Define architecture extension test macros. */
builtin_define_with_int_value ("__riscv_arch_test", 1);
#define TARGET_ZKSH ((riscv_zk_subext & MASK_ZKSH) != 0)
#define TARGET_ZKT ((riscv_zk_subext & MASK_ZKT) != 0)
-#define MASK_VECTOR_EEW_32 (1 << 0)
-#define MASK_VECTOR_EEW_64 (1 << 1)
-#define MASK_VECTOR_EEW_FP_32 (1 << 2)
-#define MASK_VECTOR_EEW_FP_64 (1 << 3)
+#define MASK_VECTOR_ELEN_32 (1 << 0)
+#define MASK_VECTOR_ELEN_64 (1 << 1)
+#define MASK_VECTOR_ELEN_FP_32 (1 << 2)
+#define MASK_VECTOR_ELEN_FP_64 (1 << 3)
+
+#define TARGET_VECTOR_ELEN_32 \
+ ((riscv_vector_elen_flags & MASK_VECTOR_ELEN_32) != 0)
+#define TARGET_VECTOR_ELEN_64 \
+ ((riscv_vector_elen_flags & MASK_VECTOR_ELEN_64) != 0)
+#define TARGET_VECTOR_ELEN_FP_32 \
+ ((riscv_vector_elen_flags & MASK_VECTOR_ELEN_FP_32) != 0)
+#define TARGET_VECTOR_ELEN_FP_64 \
+ ((riscv_vector_elen_flags & MASK_VECTOR_ELEN_FP_64) != 0)
#define MASK_ZVL32B (1 << 0)
#define MASK_ZVL64B (1 << 1)
#define TARGET_ZVL32768B ((riscv_zvl_flags & MASK_ZVL32768B) != 0)
#define TARGET_ZVL65536B ((riscv_zvl_flags & MASK_ZVL65536B) != 0)
+/* Bit of riscv_zvl_flags will set contintuly, N-1 bit will set if N-bit is
+ set, e.g. MASK_ZVL64B has set then MASK_ZVL32B is set, so we can use
+ popcount to caclulate the minimal VLEN. */
+#define TARGET_MIN_VLEN \
+ ((riscv_zvl_flags == 0) \
+ ? 0 \
+ : 32 << (__builtin_popcount (riscv_zvl_flags) - 1))
+
#endif /* ! GCC_RISCV_OPTS_H */
int riscv_zk_subext
TargetVariable
-int riscv_vector_eew_flags
+int riscv_vector_elen_flags
TargetVariable
int riscv_zvl_flags
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32gcv -mabi=ilp32 -mcmodel=medlow" } */
+int foo()
+{
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32gc_zve64f_zvl128b -mabi=ilp32 -mcmodel=medlow" } */
+int foo()
+{
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32gcv_zvl128b -mabi=ilp32 -mcmodel=medlow" } */
+int foo()
+{
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gcv -mabi=lp64d -mcmodel=medlow -misa-spec=2.2" } */
+
+int main () {
+
+#ifndef __riscv_arch_test
+#error "__riscv_arch_test"
+#endif
+
+#if __riscv_xlen != 64
+#error "__riscv_xlen"
+#endif
+
+#if !defined(__riscv_i)
+#error "__riscv_i"
+#endif
+
+#if !defined(__riscv_c)
+#error "__riscv_c"
+#endif
+
+#if defined(__riscv_e)
+#error "__riscv_e"
+#endif
+
+#if !defined(__riscv_a)
+#error "__riscv_a"
+#endif
+
+#if !defined(__riscv_m)
+#error "__riscv_m"
+#endif
+
+#if !defined(__riscv_f)
+#error "__riscv_f"
+#endif
+
+#if !defined(__riscv_d)
+#error "__riscv_d"
+#endif
+
+#if !defined(__riscv_v)
+#error "__riscv_v"
+#endif
+
+#if !defined(__riscv_zvl128b)
+#error "__riscv_zvl128b"
+#endif
+
+#if !defined(__riscv_zvl64b)
+#error "__riscv_zvl64b"
+#endif
+
+#if !defined(__riscv_zvl32b)
+#error "__riscv_zvl32b"
+#endif
+
+#if !defined(__riscv_vector)
+#error "__riscv_vector"
+#endif
+
+#if !defined(__riscv_v_min_vlen)
+#error "__riscv_v_min_vlen"
+#if __riscv_v_min_vlen != 128
+#error "__riscv_v_elen != 128"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen)
+#error "__riscv_v_elen"
+#if __riscv_v_elen != 64
+#error "__riscv_v_elen != 64"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen_fp)
+#error "__riscv_v_elen_fp"
+#if __riscv_v_elen_fp != 64
+#error "__riscv_v_elen_fp != 64"
+#endif
+#endif
+
+ return 0;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gc_zve32x -mabi=lp64d -mcmodel=medlow -misa-spec=2.2" } */
+
+int main () {
+
+#ifndef __riscv_arch_test
+#error "__riscv_arch_test"
+#endif
+
+#if __riscv_xlen != 64
+#error "__riscv_xlen"
+#endif
+
+#if !defined(__riscv_i)
+#error "__riscv_i"
+#endif
+
+#if !defined(__riscv_c)
+#error "__riscv_c"
+#endif
+
+#if defined(__riscv_e)
+#error "__riscv_e"
+#endif
+
+#if !defined(__riscv_a)
+#error "__riscv_a"
+#endif
+
+#if !defined(__riscv_m)
+#error "__riscv_m"
+#endif
+
+#if !defined(__riscv_f)
+#error "__riscv_f"
+#endif
+
+#if !defined(__riscv_d)
+#error "__riscv_d"
+#endif
+
+#if defined(__riscv_v)
+#error "__riscv_v"
+#endif
+
+#if defined(__riscv_zvl128b)
+#error "__riscv_zvl128b"
+#endif
+
+#if defined(__riscv_zvl64b)
+#error "__riscv_zvl64b"
+#endif
+
+#if !defined(__riscv_zvl32b)
+#error "__riscv_zvl32b"
+#endif
+
+#if !defined(__riscv_zve32x)
+#error "__riscv_zve32x"
+#endif
+
+#if !defined(__riscv_vector)
+#error "__riscv_vector"
+#endif
+
+#if !defined(__riscv_v_min_vlen)
+#error "__riscv_v_min_vlen"
+#if __riscv_v_min_vlen != 32
+#error "__riscv_v_elen != 32"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen)
+#error "__riscv_v_elen"
+#if __riscv_v_elen != 32
+#error "__riscv_v_elen != 32"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen_fp)
+#error "__riscv_v_elen_fp"
+#if __riscv_v_elen_fp != 0
+#error "__riscv_v_elen_fp != 0"
+#endif
+#endif
+
+ return 0;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gcv_zvl512b -mabi=lp64d -mcmodel=medlow -misa-spec=2.2" } */
+
+int main () {
+
+#ifndef __riscv_arch_test
+#error "__riscv_arch_test"
+#endif
+
+#if __riscv_xlen != 64
+#error "__riscv_xlen"
+#endif
+
+#if !defined(__riscv_i)
+#error "__riscv_i"
+#endif
+
+#if !defined(__riscv_c)
+#error "__riscv_c"
+#endif
+
+#if defined(__riscv_e)
+#error "__riscv_e"
+#endif
+
+#if !defined(__riscv_a)
+#error "__riscv_a"
+#endif
+
+#if !defined(__riscv_m)
+#error "__riscv_m"
+#endif
+
+#if !defined(__riscv_f)
+#error "__riscv_f"
+#endif
+
+#if !defined(__riscv_d)
+#error "__riscv_d"
+#endif
+
+#if !defined(__riscv_v)
+#error "__riscv_v"
+#endif
+
+#if !defined(__riscv_zvl128b)
+#error "__riscv_zvl128b"
+#endif
+
+#if !defined(__riscv_zvl64b)
+#error "__riscv_zvl64b"
+#endif
+
+#if !defined(__riscv_zvl32b)
+#error "__riscv_zvl32b"
+#endif
+
+#if !defined(__riscv_vector)
+#error "__riscv_vector"
+#endif
+
+#if !defined(__riscv_v_min_vlen)
+#error "__riscv_v_min_vlen"
+#if __riscv_v_min_vlen != 512
+#error "__riscv_v_elen != 512"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen)
+#error "__riscv_v_elen"
+#if __riscv_v_elen != 64
+#error "__riscv_v_elen != 64"
+#endif
+#endif
+
+#if !defined(__riscv_v_elen_fp)
+#error "__riscv_v_elen_fp"
+#if __riscv_v_elen_fp != 64
+#error "__riscv_v_elen_fp != 64"
+#endif
+#endif
+
+ return 0;
+}