From 28a095763f48725900eb86f7b4ee1b17c2e7afff Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 27 Nov 2018 12:26:06 +1030 Subject: [PATCH] [RS6000] PowerPC -mcpu=native support The -mcpu=native support has bit-rotted a little, in particular the fallback when the native cpu couldn't be determined. This patch fixes the bit-rot and reorganizes ASM_CPU_SPEC so that it should be a little easier to keep the -mcpu=native data up to date. The patch also changes the fix for PR63177 (-mpower9-vector being passed by the user when the default is -mpower8) to also apply when -mcpu=powerpc64le and -mcpu=native is given. I'll note that the hack for PR63177 should probably be extended to lots of other options, if we're going to continue supporting all those sub-architecture options (-mpower9-vector, -mpower8-vector, -mcrypto, -mdirect-move, -mhtm, -mvsx and others) in the positive sense. I think those should have only been supported in their -mno- variants.. * config/rs6000/aix71.h (ASM_SPEC): Don't select default -maix64 cpu here. (ASM_CPU_SPEC): Do so here. Rewrite using if .. else if .. specs form. Error on missing -mcpu case. * config/rs6000/driver-rs6000.c (asm_names <_AIX>): Update NULL case. (asm_names ): Add missing cpus. Update NULL case. Apply PR63177 fix for -mcpu=power8 and -mcpu=powerpc64le. * config/rs6000/rs6000.h (ASM_CPU_SPEC): Rewrite using if .. else if .. specs form. Error on missing -mcpu case. Don't output duplicate -maltivec. Apply PR63177 fix for -mcpu=powerpc64le. From-SVN: r266502 --- gcc/ChangeLog | 13 ++++ gcc/config/rs6000/aix71.h | 50 ++++++------ gcc/config/rs6000/driver-rs6000.c | 38 ++++++---- gcc/config/rs6000/rs6000.h | 122 +++++++++++++++--------------- 4 files changed, 121 insertions(+), 102 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4ec5565408..d8e374fb15f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2018-11-27 Alan Modra + + * config/rs6000/aix71.h (ASM_SPEC): Don't select default -maix64 + cpu here. + (ASM_CPU_SPEC): Do so here. Rewrite using if .. else if .. specs + form. Error on missing -mcpu case. + * config/rs6000/driver-rs6000.c (asm_names <_AIX>): Update NULL case. + (asm_names ): Add missing cpus. Update NULL case. Apply + PR63177 fix for -mcpu=power8 and -mcpu=powerpc64le. + * config/rs6000/rs6000.h (ASM_CPU_SPEC): Rewrite using if .. + else if .. specs form. Error on missing -mcpu case. Don't output + duplicate -maltivec. Apply PR63177 fix for -mcpu=powerpc64le. + 2018-11-26 David Malcolm * dump-context.h (dump_context::dump_loc): Convert 1st param from diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h index 8150552ebf3..2398ed64baa 100644 --- a/gcc/config/rs6000/aix71.h +++ b/gcc/config/rs6000/aix71.h @@ -59,7 +59,7 @@ do { \ } while (0) #undef ASM_SPEC -#define ASM_SPEC "-u %{maix64:-a64 %{!mcpu*:-mppc64}} %(asm_cpu)" +#define ASM_SPEC "-u %{maix64:-a64} %(asm_cpu)" /* Common ASM definitions used by ASM_SPEC amongst the various targets for handling -mcpu=xxx switches. There is a parallel list in driver-rs6000.c to @@ -67,31 +67,29 @@ do { \ you make changes here, make them there also. */ #undef ASM_CPU_SPEC #define ASM_CPU_SPEC \ -"%{!mcpu*: %{!maix64: \ - %{mpowerpc64: -mppc64} \ - %{maltivec: -m970} \ - %{!maltivec: %{!mpowerpc64: %(asm_default)}}}} \ -%{mcpu=native: %(asm_cpu_native)} \ -%{mcpu=power3: -m620} \ -%{mcpu=power4: -mpwr4} \ -%{mcpu=power5: -mpwr5} \ -%{mcpu=power5+: -mpwr5x} \ -%{mcpu=power6: -mpwr6} \ -%{mcpu=power6x: -mpwr6} \ -%{mcpu=power7: -mpwr7} \ -%{mcpu=power8: -mpwr8} \ -%{mcpu=power9: -mpwr9} \ -%{mcpu=powerpc: -mppc} \ -%{mcpu=rs64a: -mppc} \ -%{mcpu=603: -m603} \ -%{mcpu=603e: -m603} \ -%{mcpu=604: -m604} \ -%{mcpu=604e: -m604} \ -%{mcpu=620: -m620} \ -%{mcpu=630: -m620} \ -%{mcpu=970: -m970} \ -%{mcpu=G5: -m970} \ -%{mvsx: %{!mcpu*: -mpwr6}} \ +"%{mcpu=native: %(asm_cpu_native); \ + mcpu=power9: -mpwr9; \ + mcpu=power8: -mpwr8; \ + mcpu=power7: -mpwr7; \ + mcpu=power6x|mcpu=power6: -mpwr6; \ + mcpu=power5+: -mpwr5x; \ + mcpu=power5: -mpwr5; \ + mcpu=power4: -mpwr4; \ + mcpu=power3: -m620; \ + mcpu=powerpc: -mppc; \ + mcpu=rs64a: -mppc; \ + mcpu=603: -m603; \ + mcpu=603e: -m603; \ + mcpu=604: -m604; \ + mcpu=604e: -m604; \ + mcpu=620: -m620; \ + mcpu=630: -m620; \ + mcpu=970|mcpu=G5: -m970; \ + !mcpu*: %{mvsx: -mpwr6; \ + maltivec: -m970; \ + maix64|mpowerpc64: -mppc64; \ + : %(asm_default)}; \ + :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \ -many" #undef ASM_DEFAULT_SPEC diff --git a/gcc/config/rs6000/driver-rs6000.c b/gcc/config/rs6000/driver-rs6000.c index 948888b4c79..0a48d46d658 100644 --- a/gcc/config/rs6000/driver-rs6000.c +++ b/gcc/config/rs6000/driver-rs6000.c @@ -459,10 +459,10 @@ static const struct asm_name asm_names[] = { { "970", "-m970" }, { "G5", "-m970" }, { NULL, "\ -%{!maix64: \ -%{mpowerpc64: -mppc64} \ -%{maltivec: -m970} \ -%{!maltivec: %{!mpowerpc64: %(asm_default)}}}" }, + %{mvsx: -mpwr6; \ + maltivec: -m970; \ + maix64|mpowerpc64: -mppc64; \ + : %(asm_default)}" }, #else { "cell", "-mcell" }, @@ -470,12 +470,14 @@ static const struct asm_name asm_names[] = { { "power4", "-mpower4" }, { "power5", "-mpower5" }, { "power5+", "-mpower5" }, - { "power6", "-mpower6 -maltivec" }, - { "power6x", "-mpower6 -maltivec" }, + { "power6", "-mpower6 %{!mvsx:%{!maltivec:-maltivec}}" }, + { "power6x", "-mpower6 %{!mvsx:%{!maltivec:-maltivec}}" }, { "power7", "-mpower7" }, - { "power8", "-mpower8" }, + { "power8", "%{mpower9-vector:-mpower9;:-mpower8}" }, { "power9", "-mpower9" }, + { "a2", "-ma2" }, { "powerpc", "-mppc" }, + { "powerpc64le", "%{mpower9-vector:-mpower9;:-mpower8}" }, { "rs64a", "-mppc64" }, { "401", "-mppc" }, { "403", "-m403" }, @@ -485,6 +487,8 @@ static const struct asm_name asm_names[] = { { "440fp", "-m440" }, { "464", "-m440" }, { "464fp", "-m440" }, + { "476", "-m476" }, + { "476fp", "-m476" }, { "505", "-mppc" }, { "601", "-m601" }, { "602", "-mppc" }, @@ -498,23 +502,29 @@ static const struct asm_name asm_names[] = { { "740", "-mppc" }, { "750", "-mppc" }, { "G3", "-mppc" }, - { "7400", "-mppc -maltivec" }, - { "7450", "-mppc -maltivec" }, - { "G4", "-mppc -maltivec" }, + { "7400", "-mppc %{!mvsx:%{!maltivec:-maltivec}}" }, + { "7450", "-mppc %{!mvsx:%{!maltivec:-maltivec}}" }, + { "G4", "-mppc %{!mvsx:%{!maltivec:-maltivec}}" }, { "801", "-mppc" }, { "821", "-mppc" }, { "823", "-mppc" }, { "860", "-mppc" }, - { "970", "-mpower4 -maltivec" }, - { "G5", "-mpower4 -maltivec" }, + { "970", "-mpower4 %{!mvsx:%{!maltivec:-maltivec}}" }, + { "G5", "-mpower4 %{!mvsx:%{!maltivec:-maltivec}}" }, { "8540", "-me500" }, { "8548", "-me500" }, { "e300c2", "-me300" }, { "e300c3", "-me300" }, { "e500mc", "-me500mc" }, + { "e500mc64", "-me500mc64" }, + { "e5500", "-me5500" }, + { "e6500", "-me6500" }, { NULL, "\ -%{mpowerpc64*: -mppc64} \ -%{!mpowerpc64*: %(asm_default)}" }, +%{mpower9-vector: -mpower9; \ + mpower8-vector|mcrypto|mdirect-move|mhtm: -mpower8; \ + mvsx: -mpower7; \ + mpowerpc64: -mppc64; \ + : %(asm_default)}" }, #endif }; diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 9e8f0da4d22..e62664fe2fb 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -76,68 +76,66 @@ you make changes here, make them also there. PR63177: Do not pass -mpower8 to the assembler if -mpower9-vector was also used. */ #define ASM_CPU_SPEC \ -"%{!mcpu*: \ - %{mpowerpc64*: -mppc64} \ - %{!mpowerpc64*: %(asm_default)}} \ -%{mcpu=native: %(asm_cpu_native)} \ -%{mcpu=cell: -mcell} \ -%{mcpu=power3: -mppc64} \ -%{mcpu=power4: -mpower4} \ -%{mcpu=power5: -mpower5} \ -%{mcpu=power5+: -mpower5} \ -%{mcpu=power6: -mpower6 -maltivec} \ -%{mcpu=power6x: -mpower6 -maltivec} \ -%{mcpu=power7: -mpower7} \ -%{mcpu=power8: %{!mpower9-vector: -mpower8}} \ -%{mcpu=power9: -mpower9} \ -%{mcpu=a2: -ma2} \ -%{mcpu=powerpc: -mppc} \ -%{mcpu=powerpc64le: -mpower8} \ -%{mcpu=rs64a: -mppc64} \ -%{mcpu=401: -mppc} \ -%{mcpu=403: -m403} \ -%{mcpu=405: -m405} \ -%{mcpu=405fp: -m405} \ -%{mcpu=440: -m440} \ -%{mcpu=440fp: -m440} \ -%{mcpu=464: -m440} \ -%{mcpu=464fp: -m440} \ -%{mcpu=476: -m476} \ -%{mcpu=476fp: -m476} \ -%{mcpu=505: -mppc} \ -%{mcpu=601: -m601} \ -%{mcpu=602: -mppc} \ -%{mcpu=603: -mppc} \ -%{mcpu=603e: -mppc} \ -%{mcpu=ec603e: -mppc} \ -%{mcpu=604: -mppc} \ -%{mcpu=604e: -mppc} \ -%{mcpu=620: -mppc64} \ -%{mcpu=630: -mppc64} \ -%{mcpu=740: -mppc} \ -%{mcpu=750: -mppc} \ -%{mcpu=G3: -mppc} \ -%{mcpu=7400: -mppc -maltivec} \ -%{mcpu=7450: -mppc -maltivec} \ -%{mcpu=G4: -mppc -maltivec} \ -%{mcpu=801: -mppc} \ -%{mcpu=821: -mppc} \ -%{mcpu=823: -mppc} \ -%{mcpu=860: -mppc} \ -%{mcpu=970: -mpower4 -maltivec} \ -%{mcpu=G5: -mpower4 -maltivec} \ -%{mcpu=8540: -me500} \ -%{mcpu=8548: -me500} \ -%{mcpu=e300c2: -me300} \ -%{mcpu=e300c3: -me300} \ -%{mcpu=e500mc: -me500mc} \ -%{mcpu=e500mc64: -me500mc64} \ -%{mcpu=e5500: -me5500} \ -%{mcpu=e6500: -me6500} \ -%{maltivec: -maltivec} \ -%{mvsx: -mvsx %{!maltivec: -maltivec} %{!mcpu*: -mpower7}} \ -%{mpower8-vector|mcrypto|mdirect-move|mhtm: %{!mcpu*: -mpower8}} \ -%{mpower9-vector: %{!mcpu*|mcpu=power8: -mpower9}} \ +"%{mcpu=native: %(asm_cpu_native); \ + mcpu=power9: -mpower9; \ + mcpu=power8|mcpu=powerpc64le: %{mpower9-vector: -mpower9;: -mpower8}; \ + mcpu=power7: -mpower7; \ + mcpu=power6x: -mpower6 %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=power6: -mpower6 %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=power5+: -mpower5; \ + mcpu=power5: -mpower5; \ + mcpu=power4: -mpower4; \ + mcpu=power3: -mppc64; \ + mcpu=powerpc: -mppc; \ + mcpu=a2: -ma2; \ + mcpu=cell: -mcell; \ + mcpu=rs64a: -mppc64; \ + mcpu=401: -mppc; \ + mcpu=403: -m403; \ + mcpu=405: -m405; \ + mcpu=405fp: -m405; \ + mcpu=440: -m440; \ + mcpu=440fp: -m440; \ + mcpu=464: -m440; \ + mcpu=464fp: -m440; \ + mcpu=476: -m476; \ + mcpu=476fp: -m476; \ + mcpu=505: -mppc; \ + mcpu=601: -m601; \ + mcpu=602: -mppc; \ + mcpu=603: -mppc; \ + mcpu=603e: -mppc; \ + mcpu=ec603e: -mppc; \ + mcpu=604: -mppc; \ + mcpu=604e: -mppc; \ + mcpu=620: -mppc64; \ + mcpu=630: -mppc64; \ + mcpu=740: -mppc; \ + mcpu=750: -mppc; \ + mcpu=G3: -mppc; \ + mcpu=7400: -mppc %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=7450: -mppc %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=G4: -mppc %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=801: -mppc; \ + mcpu=821: -mppc; \ + mcpu=823: -mppc; \ + mcpu=860: -mppc; \ + mcpu=970: -mpower4 %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=G5: -mpower4 %{!mvsx:%{!maltivec:-maltivec}}; \ + mcpu=8540: -me500; \ + mcpu=8548: -me500; \ + mcpu=e300c2: -me300; \ + mcpu=e300c3: -me300; \ + mcpu=e500mc: -me500mc; \ + mcpu=e500mc64: -me500mc64; \ + mcpu=e5500: -me5500; \ + mcpu=e6500: -me6500; \ + !mcpu*: %{mpower9-vector: -mpower9; \ + mpower8-vector|mcrypto|mdirect-move|mhtm: -mpower8; \ + mvsx: -mpower7; \ + mpowerpc64: -mppc64;: %(asm_default)}; \ + :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \ +%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \ -many" #define CPP_DEFAULT_SPEC "" -- 2.30.2