Oops, I just saw #3 was slightly bigger because I accidentally reverted a previous patch of mine. Here's it all pulled out.

On 08/13/18 20:15, Ben Elliston wrote:
I have applied patches 0001 and 0002, thanks. 0003 is quite large and
I want to spend some time examining it more closely.
Sound good. I might pull out more single component things, more aggressively now too as the canonicalization tests can keep us safer.
You know, a bit of awk or Perl would allow us to write out a list of
accepted patterns from which we could make the testsuite exhaustive.
Heh, well if only we had arrays of arrays, I'd put the patterns->normalization in as data, and then just source it to build the test cases. But yes, some automation would be nice. I think that would be easier after the refactors so I'll get cranking pulling out those single-component ones.

John
>From 22015b2837e53a9f310a0973adfca112884bcfe1 Mon Sep 17 00:00:00 2001
Message-Id: 
<22015b2837e53a9f310a0973adfca112884bcfe1.1534206979.git.John.Ericson@Obsidian.Systems>
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Fri, 22 Jun 2018 17:40:14 -0400
Subject: [PATCH]     * config.sub: Deduplicate `basic_machine` by filling in a
 stub vendor.
To: config-patches@gnu.org

---
 ChangeLog  |  24 ++++++
 config.sub | 212 ++++++++++++++---------------------------------------
 2 files changed, 78 insertions(+), 158 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b06386f..14dce34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2018-08-14  John Ericson  <john.ericson@obsidian.systems>
+
+       * config.sub: Deduplicate `basic_machine` by filling in a stub vendor.
+
+       Instead of having both `foo` and `foo-*` as redundant patterns, we
+       always make sure basic_machine is initialized in the form `*-*` by
+       adding a trailing `-unknown` where needed.
+
+       There was one complication to doing this that should be noted. For
+       x86, the default is `-pc` instead of `-unknown`. That means we
+       can't just always append 1-component `basic_machine`s with
+       `-unknown` and assume 2-component everywhere.  Furthermore, an
+       explicitly passed `*-unknown` for x86 is not normalized by that
+       rule but instead left as-is. That means we cannot just append and
+       also conditionally replace `-unknown` with `-pc` as a final step,
+       either.
+
+       The solution is to continue duplicating the rules which would
+       output a `(i386|x86_64)-pc` so we can ensure the special case is
+       maintained, while defaulting to `-unknown` otherwise so the `*-*`
+       rules are sufficient. This isn't ideal, but at least most of the
+       `basic_machine` rules aren't implicated and can still be
+       deduplicated.
+
 2018-08-14  John Ericson  <john.ericson@obsidian.systems>
 
        * config.sub (sequent): Make this a one-component alias.
diff --git a/config.sub b/config.sub
index 6e8fa65..8264524 100755
--- a/config.sub
+++ b/config.sub
@@ -639,15 +639,45 @@ case $1 in
                ;;
 esac
 
+case $basic_machine in
+       *-*)
+               ;;
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+               basic_machine=$basic_machine-pc
+               ;;
+       # These rules are duplicated from below for sake of the special case 
above;
+       # i.e. things that normalized to x86 arches should also default to "pc"
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       x64 | amd64)
+               basic_machine=x86_64-pc
+               ;;
+       # These are improper single component basic machines, as they should
+       # drop the vendor for just the CPU instead of the CPU for just the
+       # vendor as they in fact do. But they are tested to occur as part of
+       # multi-component configs, so we can't move them to the single
+       # component alises whitelist above.
+       sde)
+               basic_machine=mipsisa32-sde
+               os=${os:-elf}
+               ;;
+       *)
+               basic_machine=$basic_machine-unknown
+esac
+
 # Decode aliases for certain CPU-COMPANY combinations.
 case $basic_machine in
        # Here we handle the default manufacturer of certain CPU types.  It is 
in
        # some cases the only manufacturer, in others, it is the most popular.
-       craynv)
+       craynv-unknown)
                basic_machine=craynv-cray
                os=${os:-unicosmp}
                ;;
-       fx80)
+       fx80-unknown)
                basic_machine=fx80-alliant
                ;;
        w89k)
@@ -659,31 +689,31 @@ case $basic_machine in
        op60c)
                basic_machine=hppa1.1-oki
                ;;
-       romp)
+       romp-unknown)
                basic_machine=romp-ibm
                ;;
-       mmix)
+       mmix-unknown)
                basic_machine=mmix-knuth
                ;;
-       rs6000)
+       rs6000-unknown)
                basic_machine=rs6000-ibm
                ;;
-       vax)
+       vax-unknown)
                basic_machine=vax-dec
                ;;
-       pdp11)
+       pdp11-unknown)
                basic_machine=pdp11-dec
                ;;
-       we32k)
+       we32k-unknown)
                basic_machine=we32k-att
                ;;
-       cydra)
+       cydra-unknown)
                basic_machine=cydra-cydrome
                ;;
        i370-ibm* | ibm*)
                basic_machine=i370-ibm
                ;;
-       orion)
+       orion-unknown)
                basic_machine=orion-highlevel
                ;;
        orion105)
@@ -695,131 +725,10 @@ case $basic_machine in
        pmac | pmac-mpw)
                basic_machine=powerpc-apple
                ;;
-       xps | xps100)
+       xps-unknown | xps100-unknown)
                basic_machine=xps100-honeywell
                ;;
 
-       # Recognize the basic CPU types without company name.
-       # Some are omitted here because they have special meanings below.
-       1750a | 580 \
-       | a29k \
-       | aarch64 | aarch64_be \
-       | abacus \
-       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | 
alpha64pca5[67] \
-       | am33_2.0 \
-       | arc | arceb \
-       | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | 
armv[78][arm] \
-       | avr | avr32 \
-       | asmjs \
-       | ba \
-       | be32 | be64 \
-       | bfin \
-       | c4x | c8051 | clipper | csky \
-       | d10v | d30v | dlx | dsp16xx \
-       | e2k | epiphany \
-       | fido | fr30 | frv | ft32 \
-       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-       | hexagon \
-       | i370 | i860 | i960 | ia16 | ia64 \
-       | ip2k | iq2000 \
-       | k1om \
-       | le32 | le64 \
-       | lm32 \
-       | m32c | m32r | m32rle | m68000 | m68k | m88k \
-       | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip \
-       | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
-       | mips | mipsbe | mipseb | mipsel | mipsle \
-       | mips16 \
-       | mips64 | mips64el \
-       | mips64octeon | mips64octeonel \
-       | mips64orion | mips64orionel \
-       | mips64r5900 | mips64r5900el \
-       | mips64vr | mips64vrel \
-       | mips64vr4100 | mips64vr4100el \
-       | mips64vr4300 | mips64vr4300el \
-       | mips64vr5000 | mips64vr5000el \
-       | mips64vr5900 | mips64vr5900el \
-       | mipsisa32 | mipsisa32el \
-       | mipsisa32r2 | mipsisa32r2el \
-       | mipsisa32r6 | mipsisa32r6el \
-       | mipsisa64 | mipsisa64el \
-       | mipsisa64r2 | mipsisa64r2el \
-       | mipsisa64r6 | mipsisa64r6el \
-       | mipsisa64sb1 | mipsisa64sb1el \
-       | mipsisa64sr71k | mipsisa64sr71kel \
-       | mipsr5900 | mipsr5900el \
-       | mipstx39 | mipstx39el \
-       | mn10200 | mn10300 \
-       | moxie \
-       | mt \
-       | msp430 \
-       | nds32 | nds32le | nds32be \
-       | nfp \
-       | nios | nios2 | nios2eb | nios2el \
-       | ns16k | ns32k \
-       | open8 | or1k | or1knd | or32 \
-       | pdp10 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle \
-       | pru \
-       | pyramid \
-       | riscv | riscv32 | riscv64 \
-       | rl78 | rx \
-       | score \
-       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | 
shbe | shle | sh[1234]le | sh[23]ele \
-       | sh64 | sh64le \
-       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | 
sparclite \
-       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-       | spu \
-       | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
-       | ubicom32 \
-       | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
-       | visium \
-       | wasm32 \
-       | x86 | xc16x | xstormy16 | xgate | xtensa \
-       | z8k | z80)
-               basic_machine=$basic_machine-unknown
-               ;;
-       c54x)
-               basic_machine=tic54x-unknown
-               ;;
-       c55x)
-               basic_machine=tic55x-unknown
-               ;;
-       c6x)
-               basic_machine=tic6x-unknown
-               ;;
-       leon|leon[3-9])
-               basic_machine=sparc-$basic_machine
-               ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
-               ;;
-       m9s12z | m68hcs12z | hcs12z | s12z)
-               basic_machine=s12z-unknown
-               ;;
-       m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
-               basic_machine=s12z-`echo "$basic_machine" | sed 's/^[^-]*-//'`
-               ;;
-       ms1)
-               basic_machine=mt-unknown
-               ;;
-       strongarm | thumb | xscale)
-               basic_machine=arm-unknown
-               ;;
-       xscaleeb)
-               basic_machine=armeb-unknown
-               ;;
-
-       xscaleel)
-               basic_machine=armel-unknown
-               ;;
-
-       # We use `pc' rather than `unknown'
-       # because (1) that's what they normally are, and
-       # (2) the word "unknown" tends to confuse beginning users.
-       i*86 | x86_64)
-         basic_machine=$basic_machine-pc
-         ;;
        # Recognize the basic CPU types with company name.
        1750a-* | 580-* \
        | a29k-* \
@@ -915,10 +824,6 @@ case $basic_machine in
        | ymp-* \
        | z8k-* | z80-*)
                ;;
-       # Recognize the basic CPU types without company name, with glob match.
-       xtensa*)
-               basic_machine=$basic_machine-unknown
-               ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
        3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -927,9 +832,6 @@ case $basic_machine in
        3b*)
                basic_machine=we32k-att
                ;;
-       amd64)
-               basic_machine=x86_64-pc
-               ;;
        amd64-*)
                basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
@@ -954,14 +856,14 @@ case $basic_machine in
                basic_machine=c90-cray
                os=${os:-unicos}
                ;;
-       cr16 | cr16-*)
+       cr16-*)
                basic_machine=cr16-unknown
                os=${os:-elf}
                ;;
-       crisv32 | crisv32-* | etraxfs*)
+       crisv32-* | etraxfs*)
                basic_machine=crisv32-axis
                ;;
-       cris | cris-* | etrax*)
+       cris-* | etrax*)
                basic_machine=cris-axis
                ;;
        crx)
@@ -980,7 +882,7 @@ case $basic_machine in
              | 3300-motorola | delta-motorola)
                basic_machine=m68k-motorola
                ;;
-       dpx20 | dpx20-*)
+       dpx20-*)
                basic_machine=rs6000-bull
                os=${os:-bosx}
                ;;
@@ -1079,6 +981,10 @@ case $basic_machine in
                basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                os=linux
                ;;
+       m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+               basic_machine=s12z-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=${os:-none}
+               ;;
        microblaze*)
                basic_machine=microblaze-xilinx
                ;;
@@ -1154,12 +1060,9 @@ case $basic_machine in
        pbb)
                basic_machine=m68k-tti
                ;;
-       pc532 | pc532-*)
+       pc532-*)
                basic_machine=ns32k-pc532
                ;;
-       pc98)
-               basic_machine=i386-pc
-               ;;
        pc98-*)
                basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
@@ -1234,12 +1137,8 @@ case $basic_machine in
        sb1el)
                basic_machine=mipsisa64sb1el-unknown
                ;;
-       sde)
-               basic_machine=mipsisa32-sde
-               os=${os:-elf}
-               ;;
-       sh5el)
-               basic_machine=sh5le-unknown
+       sh5e[lb]-*)
+               basic_machine=`echo "$basic_machine" | sed 
's/^\(sh.\)e\(.\)-/\1\2e-/'`
                ;;
        sh5el-*)
                basic_machine=sh5le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
@@ -1255,9 +1154,6 @@ case $basic_machine in
                basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        tile*-*)
-               ;;
-       tile*)
-               basic_machine=$basic_machine-unknown
                os=${os:-linux-gnu}
                ;;
        tx39)
@@ -1280,8 +1176,8 @@ case $basic_machine in
                basic_machine=hppa1.1-winbond
                os=proelf
                ;;
-       x64)
-               basic_machine=x86_64-pc
+       x64-*)
+               basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        xscale-* | xscalee[bl]-*)
                basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
-- 
2.17.1

_______________________________________________
config-patches mailing list
config-patches@gnu.org
https://lists.gnu.org/mailman/listinfo/config-patches

Reply via email to