[0/5] RISC-V: Relax the -march string for accept any order

Message ID 20240108134738.998804-1-kito.cheng@sifive.com
Headers
Series RISC-V: Relax the -march string for accept any order |

Message

Kito Cheng Jan. 8, 2024, 1:47 p.m. UTC
  Do you know how to build a ISA string with following extension?
- g
- c
- zba
- zbs
- svnapot
- zve64d
- zvl128b

Don't trial and error with your gcc and don't read RISC-V ISA spec! OK, I believe it's impossible for most people, even I work for RISC-V so many years, I remember most of the rule of the the canonical order, it's still hard to order that right in short time...

So I think it's time to relax that for the -march string inputs, since we have so many extension today, but we still keep the canonicalization within the compiler, because we need that to handle multi-lib and also it's easier to compare different ISA string.

This patch break into serveral part:
1) Small refactor patch
2) Change the way of parsing ISA string.
3) Remove unused functions
4) Update test cases
5) Update document
  

Comments

Jeff Law Jan. 9, 2024, 6:31 p.m. UTC | #1
On 1/8/24 06:47, Kito Cheng wrote:
> 
> Do you know how to build a ISA string with following extension?
> - g
> - c
> - zba
> - zbs
> - svnapot
> - zve64d
> - zvl128b
> 
> Don't trial and error with your gcc and don't read RISC-V ISA spec! OK, I believe it's impossible for most people, even I work for RISC-V so many years, I remember most of the rule of the the canonical order, it's still hard to order that right in short time...
> 
> So I think it's time to relax that for the -march string inputs, since we have so many extension today, but we still keep the canonicalization within the compiler, because we need that to handle multi-lib and also it's easier to compare different ISA string.
> 
> This patch break into serveral part:
> 1) Small refactor patch
> 2) Change the way of parsing ISA string.
> 3) Remove unused functions
> 4) Update test cases
> 5) Update document
Just because something is hard doesn't necessarily mean we should avoid it.

A great example would be strict aliasing.  I'd bet that 90% of C/C++ 
developers would get something wrong in this space.  Similarly for 
oddities of FP arithmetic.

My biggest worry is consistency across various tools.  It's rather lame 
if GCC were on an island by itself either in being too strict or too loose.

So where are the other key tools in this regard?  Are we an outlier 
right now or will this patch make us an outlier?

jeff
  
Kito Cheng Jan. 10, 2024, 12:58 a.m. UTC | #2
Oops, I should leave more context here:

Actually we discussed that years ago, and most people agree with that, but
I guess we are just missing that, and also the ISA string isn't so
terribly long yet at that moment, however...the number of extensions are
growth so fast in last year, so I think it's time to moving this forward.

Also we (SiFive) will send patches for clang/LLVM to relax that as well :)

https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14

On Wed, Jan 10, 2024 at 2:31 AM Jeff Law <jeffreyalaw@gmail.com> wrote:

>
>
> On 1/8/24 06:47, Kito Cheng wrote:
> >
> > Do you know how to build a ISA string with following extension?
> > - g
> > - c
> > - zba
> > - zbs
> > - svnapot
> > - zve64d
> > - zvl128b
> >
> > Don't trial and error with your gcc and don't read RISC-V ISA spec! OK,
> I believe it's impossible for most people, even I work for RISC-V so many
> years, I remember most of the rule of the the canonical order, it's still
> hard to order that right in short time...
> >
> > So I think it's time to relax that for the -march string inputs, since
> we have so many extension today, but we still keep the canonicalization
> within the compiler, because we need that to handle multi-lib and also it's
> easier to compare different ISA string.
> >
> > This patch break into serveral part:
> > 1) Small refactor patch
> > 2) Change the way of parsing ISA string.
> > 3) Remove unused functions
> > 4) Update test cases
> > 5) Update document
> Just because something is hard doesn't necessarily mean we should avoid it.
>
> A great example would be strict aliasing.  I'd bet that 90% of C/C++
> developers would get something wrong in this space.  Similarly for
> oddities of FP arithmetic.
>
> My biggest worry is consistency across various tools.  It's rather lame
> if GCC were on an island by itself either in being too strict or too loose.
>
> So where are the other key tools in this regard?  Are we an outlier
> right now or will this patch make us an outlier?
>
> jeff
>
  
Fangrui Song Jan. 10, 2024, 1:38 a.m. UTC | #3
On Tue, Jan 9, 2024 at 4:59 PM Kito Cheng <kito.cheng@sifive.com> wrote:
>
> Oops, I should leave more context here:
>
> Actually we discussed that years ago, and most people agree with that, but I guess we are just missing that, and also the ISA string isn't so terribly long yet at that moment, however...the number of extensions are growth so fast in last year, so I think it's time to moving this forward.
>
> Also we (SiFive) will send patches for clang/LLVM to relax that as well :)
>
> https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14
>
> On Wed, Jan 10, 2024 at 2:31 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>>
>>
>>
>> On 1/8/24 06:47, Kito Cheng wrote:
>> >
>> > Do you know how to build a ISA string with following extension?
>> > - g
>> > - c
>> > - zba
>> > - zbs
>> > - svnapot
>> > - zve64d
>> > - zvl128b
>> >
>> > Don't trial and error with your gcc and don't read RISC-V ISA spec! OK, I believe it's impossible for most people, even I work for RISC-V so many years, I remember most of the rule of the the canonical order, it's still hard to order that right in short time...
>> >
>> > So I think it's time to relax that for the -march string inputs, since we have so many extension today, but we still keep the canonicalization within the compiler, because we need that to handle multi-lib and also it's easier to compare different ISA string.
>> >
>> > This patch break into serveral part:
>> > 1) Small refactor patch
>> > 2) Change the way of parsing ISA string.
>> > 3) Remove unused functions
>> > 4) Update test cases
>> > 5) Update document
>> Just because something is hard doesn't necessarily mean we should avoid it.
>>
>> A great example would be strict aliasing.  I'd bet that 90% of C/C++
>> developers would get something wrong in this space.  Similarly for
>> oddities of FP arithmetic.
>>
>> My biggest worry is consistency across various tools.  It's rather lame
>> if GCC were on an island by itself either in being too strict or too loose.
>>
>> So where are the other key tools in this regard?  Are we an outlier
>> right now or will this patch make us an outlier?
>>
>> jeff

If we had fewer extensions, ensuring a canonical order is better as a
code search of a fixed string will retrieve the relevant results, and
I'd wish that we did not lose the strictness.
Now that there are a hundred extensions, I agree that enforcing a
strict order has lost its goodness...
  
Jeff Law Jan. 16, 2024, 2:33 p.m. UTC | #4
On 1/9/24 17:58, Kito Cheng wrote:
> Oops, I should leave more context here:
> 
> Actually we discussed that years ago, and most people agree with that, 
> but I guess we are just missing that, and also the ISA string isn't so 
> terribly long yet at that moment, however...the number of extensions are 
> growth so fast in last year, so I think it's time to moving this forward.
> 
> Also we (SiFive) will send patches for clang/LLVM to relax that as well :)
> 
> https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14 
> <https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14>
Then let's go forward.  It seems like as good a time as any with gcc-14 
and llvm-18 both right around the corner.

jeff
  
Kito Cheng Jan. 19, 2024, 7:20 a.m. UTC | #5
Pushed to trunk :)

On Tue, Jan 16, 2024 at 10:33 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 1/9/24 17:58, Kito Cheng wrote:
> > Oops, I should leave more context here:
> >
> > Actually we discussed that years ago, and most people agree with that,
> > but I guess we are just missing that, and also the ISA string isn't so
> > terribly long yet at that moment, however...the number of extensions are
> > growth so fast in last year, so I think it's time to moving this forward.
> >
> > Also we (SiFive) will send patches for clang/LLVM to relax that as well :)
> >
> > https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14
> > <https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14>
> Then let's go forward.  It seems like as good a time as any with gcc-14
> and llvm-18 both right around the corner.
>
> jeff