Hi Jiawei:

I would prefer to have full verification on arch-canonicalize side,
could you extract profile list to a def file like riscv-cores.def or
riscv-ext.def and then read that in arch-canonicalize?

On Mon, Sep 1, 2025 at 6:03 PM Christoph Müllner
<[email protected]> wrote:
>
>
>
> On Tue, Aug 26, 2025 at 11:26 AM Jiawei <[email protected]> wrote:
>>
>> This patch allows profiles input in '--with-arch'.  With this change,
>> profile names such as `rva22*`, `rvb23*`, or `rvi*` can be passed
>> directly to `--with-arch` without triggering configure errors.  This
>> makes it easier to configure and build a toolchain targeting RISC-V
>> profiles, since the input can match the profile name directly instead
>> of requiring manual mapping to base ISA strings.
>
>
> The validation of the profiles (string starts with "rvi", "rva", or "rvb") 
> seems a bit weak.
> On the one hand, that means the validation is future-proof. But what happens 
> if "rva19" is provided as a profile?
> I don't see a way around validating the exact profile name (and only allowing 
> supported profiles).
>
> BR
> Christoph
>
>
>>
>> gcc/ChangeLog:
>>
>>         * config.gcc: Accept RISC-V profiles in `--with-arch`.
>>         * config/riscv/arch-canonicalize: Add profile detection and
>>         skip canonicalization for profiles.
>>
>> ---
>>  gcc/config.gcc                     | 6 ++++--
>>  gcc/config/riscv/arch-canonicalize | 8 +++++++-
>>  2 files changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/config.gcc b/gcc/config.gcc
>> index 04e88cce00d..a209c64958b 100644
>> --- a/gcc/config.gcc
>> +++ b/gcc/config.gcc
>> @@ -4775,7 +4775,8 @@ case "${target}" in
>>
>>                 # Infer arch from --with-arch, --target, and --with-abi.
>>                 case "${with_arch}" in
>> -               rv32e* | rv32i* | rv32g* | rv64e* | rv64i* | rv64g*)
>> +               rv32e* | rv32i* | rv32g* | rv64e* | rv64i* | rv64g* \
>> +               | rvi* | rva* | rvb*)
>>                         # OK.
>>                         ;;
>>                 "")
>> @@ -4829,7 +4830,8 @@ case "${target}" in
>>                 | ilp32d,rv32*d* | ilp32d,rv32g* \
>>                 | lp64,rv64* | lp64e,rv64e* \
>>                 | lp64f,rv64*f* | lp64f,rv64g* \
>> -               | lp64d,rv64*d* | lp64d,rv64g*)
>> +               | lp64d,rv64*d* | lp64d,rv64g* \
>> +               | lp64d,rvi* | lp64d,rva* | lp64d,rvb*)
>>                         ;;
>>                 *)
>>                         echo "--with-abi=${with_abi} is not supported for 
>> ISA ${with_arch}" 1>&2
>> diff --git a/gcc/config/riscv/arch-canonicalize 
>> b/gcc/config/riscv/arch-canonicalize
>> index 15a398502b3..76951261452 100755
>> --- a/gcc/config/riscv/arch-canonicalize
>> +++ b/gcc/config/riscv/arch-canonicalize
>> @@ -341,6 +341,9 @@ def get_all_extensions():
>>  #
>>  IMPLIED_EXT = parse_def_files()
>>
>> +def is_profile_arch(arch):
>> +    return arch.startswith(("rva", "rvb", "rvi"))
>> +
>>  def arch_canonicalize(arch, isa_spec):
>>    # TODO: Support extension version.
>>    is_isa_spec_2p2 = isa_spec == '2.2'
>> @@ -608,7 +611,10 @@ if __name__ == "__main__":
>>      sys.exit(run_unit_tests())
>>    elif args.arch_strs:
>>      for arch in args.arch_strs:
>> -      print (arch_canonicalize(arch, args.misa_spec))
>> +        if is_profile_arch(arch):
>> +            print(arch)
>> +        else:
>> +            print(arch_canonicalize(arch, args.misa_spec))
>>    else:
>>      parser.print_help()
>>      sys.exit(1)
>> --
>> 2.43.0
>>

Reply via email to