compiler thoughts

All | Personal | Sun
« inlining | Main | inline assembler »
20060421 Friday April 21, 2006

gcc flag compatibility

As you know gcc4ss accepts all the flags that plain gcc has. In the first release we mapped -mcpu flags to their -xarch equivalents, but didn't do any backwards mapping from studio flags (-xarch, -xtarget, -xchip) to gcc flags (-mcpu,-mtune) and it caused some confusion. Some users noticed -mcpu=v7 passed to 'cc1' component and made a conclusion that gcc4ss generates v7 code. That's not the case. Sun IR generation in cc1 is the same for any -mcpu flag and actual architecture and tuning is controlled by backend flags passed to 'cg' component.

For the next gcc4ss update the flag mapping -x* <-> -m* is going to be more consistent. The draft for new mapping is here: http://cooltools.sunsource.net/gcc/mcpu.html

The default architecture is still v8plus (for 32-bit) and v9 (for 64-bit).
In GCC terminology v8plus architecture is -mcpu=v9.
Don't confuse it with gcc's -mv8plus flag. v8plus mode in gcc is actually default on solaris, but it gets overwritten by -mcpu=v7 default. So gcc 4.0 and 4.1 default on solaris is v7 isa. Confusing right? gcc 4.2 is switching to -mcpu=v9 for solaris 7+, so it's going to generate v8plus isa by default.
For gcc4ss -mv8plus is going to work as its name would intend. -mv8plus in gcc4ss will turn v8plus isa on, whereas in plain gcc 4.x -mv8plus makes no difference at all. GCC docs don't help here. Docs quote:
"With -mv8plus, GCC generates code for the SPARC-V8+ ABI. The difference from the V8 ABI is that the global and out registers are considered 64-bit wide. This is enabled by default on Solaris in 32-bit mode for all SPARC-V9 processors."
So it's natural to expect that and I've seen quite a few gcc users adding -mv8plus hoping to get v8plus isa and disappointed that their code didn't improve. The problem is that the gcc driver is passing -mcpu=v7 to cc1 and it overwrites -mv8plus flag and v8plus default. Even if gcc driver didn't pass it, cc1 internal default of -mcpu=v7 is stronger than -mv8plus flag, so the users don't see any v8plus code unless they specify -mcpu=v9. At least -mno-v8plus is working as expected.
gcc4ss's -mv8plus is going to really change isa to v8plus.

Posted by alexey ( Apr 21 2006, 05:22:44 PM PDT ) Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

Disclaimer:

This site is a personal blog and is to be used for informational purposes only. The views expressed on this blog are those of the author only, and should not be attributed to any past or present employers.

Calendar

RSS Feeds

Search

Links

Navigation

Referers