Hi Joern,

thanks, I believe this will help with testing.

> +proc check_effective_target_riscv_v { } {
> +    return [check_no_compiler_messages riscv_ext_v assembly {
> +       #ifndef __riscv_v
> +       #error "Not __riscv_v"
> +       #endif
> +    }]
> +}
This can be replaced by riscv_vector or vice versa.

> +# Return 1 if we can execute code when using dg-add-options riscv_v
> +
> +proc check_effective_target_riscv_v_ok { } {
> +    # If the target already supports v without any added options,
> +    # we may assume we can execute just fine.
> +    if { [check_effective_target_riscv_v] } {
> +     return 1
> +    }
> +
> +    # check if we can execute vector insns with the given hardware or
> +    # simulator
> +    set gcc_march [regsub {[[:alnum:]]*} [riscv_get_arch] &v]
> +    if { [check_runtime ${gcc_march}_exec {
> +       int main() {  asm("vsetivli t0, 9, e8, m1, tu, ma"); return 0; } } 
> "-march=${gcc_march}"] } {
> +     return 1
> +    }
> +
> +    # Possible future extensions: If the target is a simulator, 
> dg-add-options
> +    # might change its config to make it allow vector insns, or we might use
> +    # options to set special elf flags / sections to effect that.
> +
> +    return 0
> +}
So in general we would add {dg-add-options riscv_v} for every
test that requires compile-time vector support?

For a run test we would check {dg-require-effective-target riscv_v_ok}
before?

Would it make sense to skip the first check here
(check_effective_target_riscv_v) so we have a proper runtime check?
Right now we assume the runtime can execute vector instructions if
the compiler can emit them.  You could replace riscv_vector_hw and
riscv_zvfh_hw by your versions then and we'd have a clear separation
between runtime and compile time.
We would just need to make sure not to add "v" twice if it's already
in the march string.

> +    if { [string equal $gcc_march "imafd"] } {
> +     set gcc_march "g"
> +    }
Wouldn't we want to always replace "imafd" with "g" for
simplicity/consistency and not just the exact string? 

> +proc add_options_for_riscv_v { flags } {
> +    if { [lsearch $flags -march=*] >= 0 } {
> +     # If there are multiple -march flags, we have to adjust all of them.
> +     # ??? Is there a way to make the match specific to a full list element?
> +     #     as it is, we might match something inside a string.
> +     return [regsub -all -- {(-march=rv[[:digit:]]*[a-rt-uwy]*)v*} $flags 
> \\1v ]

Is iterating over the list elements and returning a new list
not an option?  Or would that break something else?

Regards
 Robin

Reply via email to