What macro are predefined by gcc for different SPARC processors?
What macroses are predefined for C programms by GCC complier running on different SPARC processors. OS is the Linux.
So how can I distingui开发者_开发技巧sh between UltraSPARC, SuperSPARC, Niagara, SPARC64, etc in compile time.
Thanks
The easiest way to find out is to test it, e.g.:
$ gcc <whatever you need to specify first CPU> -dM -E - < /dev/null &> cpu1.txt
$ gcc <whatever you need to specify second CPU> -dM -E - < /dev/null &> cpu2.txt
$ sdiff -s cpu1.txt cpu2.txt
Take a look on gcc specs:
gcc -dumpspecs
...skip...
%{msoft-float:-D_SOFT_FLOAT} %{mcypress:} %{msparclite:-D__sparclite__} %{mf930:-D__sparclite__} %{mf934:-D__sparclite__} %{mv8:-D__sparc_v8__} %{msupersparc:-D__supersparc__ -D__sparc_v8__} %{mcpu=sparclet:-D__sparclet__} %{mcpu=tsc701:-D__sparclet__} %{mcpu=sparclite:-D__sparclite__} %{mcpu=f930:-D__sparclite__} %{mcpu=f934:-D__sparclite__} %{mcpu=v8:-D__sparc_v8__} %{mcpu=supersparc:-D__supersparc__ -D__sparc_v8__} %{mcpu=hypersparc:-D__hypersparc__ -D__sparc_v8__} %{mcpu=sparclite86x:-D__sparclite86x__} %{mcpu=v9:-D__sparc_v9__} %{mcpu=ultrasparc:-D__sparc_v9__} %{mcpu=ultrasparc3:-D__sparc_v9__} %{mcpu=niagara:-D__sparc_v9__} %{mcpu=niagara2:-D__sparc_v9__} %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(cpp_cpu_default)}}}}}}}
There are a list of recognized mcpu
's with the list of -D
macroses.
And the next is
%{mcpu=sparclet:-Asparclet} %{mcpu=tsc701:-Asparclet} %{msparclite:-Asparclite} %{mf930:-Asparclite} %{mf934:-Asparclite} %{mcpu=sparclite:-Asparclite} %{mcpu=sparclite86x:-Asparclite} %{mcpu=f930:-Asparclite} %{mcpu=f934:-Asparclite} %{mv8plus:-Av8plus} %{mcpu=v9:-Av9} %{mcpu=ultrasparc:%{!mv8plus:-Av9a}} %{mcpu=ultrasparc3:%{!mv8plus:-Av9b}} %{mcpu=niagara:%{!mv8plus:-Av9b}} %{mcpu=niagara2:%{!mv8plus:-Av9b}} %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(asm_cpu_default)}}}}}}}
for translating -mcpu
to -A
Hope this helps
精彩评论