This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

x86 configure machinery update



Hi,
this patch makes the x86 configuration machinery even more complex, but I hope
more robust.  The main goal is to allow configure gcc default to given cpu
submodel.  This is needed to allow gcc generate prefetch instruction by default
at least on pentium2/pentium3 chips.

I now force ix86_cpu_string to be set eighter to the default or by user.
This makes the PTA_* flags to be parsed always.  I've also taken
oppurtunity to attempt avoid of magic numbers to communicate between config.gcc
and the rest.

I've tested the patch relativly briefly (but bootstrapped/regtested and
verified in one default setup (k6) to work properly), as I am in time pressure
I didn't tested the rest of possible configuration.  I will do more testing of
all combinations tommorow and let you know if something breaks.

Thu Dec 13 21:50:05 CET 2001  Jan Hubicka  <jh@suse.cz>
	* config.gcc: Revamp target_cpu_default2 to strings;
	support new x86 variants.
	* i386.c (override_options): Default x86_cpu_string and x86_arch_string
	properly; set prefetch_sse.
	* i386.h (x86_prefetch_sse): Declare.
	(TARGET_PREFETCH_SSE): New.
	(CPP_CPU_DEFAULT_SPEC): Define according to the new macros.
	(TARGET_CPU_DEFAULT_*): New.

Index: config.gcc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config.gcc,v
retrieving revision 1.128
diff -c -3 -p -r1.128 config.gcc
*** config.gcc	2001/12/13 00:27:30	1.128
--- config.gcc	2001/12/13 20:47:59
*************** esac
*** 3275,3301 ****
  target_cpu_default2=
  case $machine in
  i486-*-*)
! 	target_cpu_default2=1
  	;;
  i586-*-*)
  	case $target_alias in
  		k6-*)
! 			target_cpu_default2=4
  			;;
  		*)
! 			target_cpu_default2=2
  			;;
  	esac
  	;;
  i686-*-* | i786-*-*)
  	case $target_alias in
! 		athlon-*)
! 			target_cpu_default2=5
  			;;
  		*)
! 			target_cpu_default2=3
  			;;
  	esac
  	;;
  alpha*-*-*)
  	case $machine in
--- 3275,3325 ----
  target_cpu_default2=
  case $machine in
  i486-*-*)
! 	target_cpu_default2=TARGET_CPU_DEFAULT_i486
  	;;
  i586-*-*)
  	case $target_alias in
+ 		k6_2-*)
+ 			target_cpu_default2=TARGET_CPU_DEFAULT_k6-2
+ 			;;
+ 		k6_3-*)
+ 			target_cpu_default2=TARGET_CPU_DEFAULT_k6-3
+ 			;;
  		k6-*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_k6
  			;;
  		*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_i386
  			;;
  	esac
  	;;
  i686-*-* | i786-*-*)
  	case $target_alias in
! 		athlon_xp-*|athlon_mp-*|athlon_4-*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
! 			;;
! 		athlon_tbird-*|athlon-*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_athlon
! 			;;
! 		pentium2-*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_pentium2
  			;;
+ 		pentium3-*)
+ 			target_cpu_default2=TARGET_CPU_DEFAULT_pentium3
+ 			;;
+ 		pentium4-*)
+ 			target_cpu_default2=TARGET_CPU_DEFAULT_pentium4
+ 			;;
  		*)
! 			target_cpu_default2=TARGET_CPU_DEFAULT_pentiumpro
  			;;
  	esac
+ 	;;
+ x86_64-*-*)
+ 	# We should have hammer chip here, but it does not exist yet and
+ 	# thus it is not supported.  Athlon_SSE is probably equivalent feature
+ 	# wise to hammer from our point of view except for 64bit mode.
+ 	target_cpu_default2=TARGET_CPU_DEFAULT_athlon_sse
  	;;
  alpha*-*-*)
  	case $machine in
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.345
diff -c -3 -p -r1.345 i386.c
*** i386.c	2001/12/13 11:34:08	1.345
--- i386.c	2001/12/13 20:48:04
*************** override_options ()
*** 813,818 ****
--- 832,838 ----
        {&pentium4_cost, 0, 0, 0, 0, 0, 0, 0, 1}
      };
  
+   const char *cpu_names[] = TARGET_CPU_DEFAULT_NAMES;
    static struct pta
      {
        const char *const name;		/* processor name or nickname.  */
*************** override_options ()
*** 822,828 ****
  	  PTA_SSE = 1,
  	  PTA_SSE2 = 2,
  	  PTA_MMX = 4,
! 	  PTA_SSEPREFETCH = 8,
  	  PTA_3DNOW = 16,
  	  PTA_3DNOW_A = 64
  	} flags;
--- 842,848 ----
  	  PTA_SSE = 1,
  	  PTA_SSE2 = 2,
  	  PTA_MMX = 4,
! 	  PTA_PREFETCH_SSE = 8,
  	  PTA_3DNOW = 16,
  	  PTA_3DNOW_A = 64
  	} flags;
*************** override_options ()
*** 837,857 ****
        {"i686", PROCESSOR_PENTIUMPRO, 0},
        {"pentiumpro", PROCESSOR_PENTIUMPRO, 0},
        {"pentium2", PROCESSOR_PENTIUMPRO, PTA_MMX},
!       {"pentium3", PROCESSOR_PENTIUMPRO, PTA_MMX | PTA_SSE | PTA_SSEPREFETCH},
        {"pentium4", PROCESSOR_PENTIUM4, PTA_SSE | PTA_SSE2 |
! 				       PTA_MMX | PTA_SSEPREFETCH},
        {"k6", PROCESSOR_K6, PTA_MMX},
        {"k6-2", PROCESSOR_K6, PTA_MMX | PTA_3DNOW},
        {"k6-3", PROCESSOR_K6, PTA_MMX | PTA_3DNOW},
!       {"athlon", PROCESSOR_ATHLON, PTA_MMX | PTA_SSEPREFETCH | PTA_3DNOW
  				   | PTA_3DNOW_A},
!       {"athlon-tbird", PROCESSOR_ATHLON, PTA_MMX | PTA_SSEPREFETCH
  					 | PTA_3DNOW | PTA_3DNOW_A},
!       {"athlon-4", PROCESSOR_ATHLON, PTA_MMX | PTA_SSEPREFETCH | PTA_3DNOW
  				    | PTA_3DNOW_A | PTA_SSE},
!       {"athlon-xp", PROCESSOR_ATHLON, PTA_MMX | PTA_SSEPREFETCH | PTA_3DNOW
  				      | PTA_3DNOW_A | PTA_SSE},
!       {"athlon-mp", PROCESSOR_ATHLON, PTA_MMX | PTA_SSEPREFETCH | PTA_3DNOW
  				      | PTA_3DNOW_A | PTA_SSE},
      };
  
--- 857,877 ----
        {"i686", PROCESSOR_PENTIUMPRO, 0},
        {"pentiumpro", PROCESSOR_PENTIUMPRO, 0},
        {"pentium2", PROCESSOR_PENTIUMPRO, PTA_MMX},
!       {"pentium3", PROCESSOR_PENTIUMPRO, PTA_MMX | PTA_SSE | PTA_PREFETCH_SSE},
        {"pentium4", PROCESSOR_PENTIUM4, PTA_SSE | PTA_SSE2 |
! 				       PTA_MMX | PTA_PREFETCH_SSE},
        {"k6", PROCESSOR_K6, PTA_MMX},
        {"k6-2", PROCESSOR_K6, PTA_MMX | PTA_3DNOW},
        {"k6-3", PROCESSOR_K6, PTA_MMX | PTA_3DNOW},
!       {"athlon", PROCESSOR_ATHLON, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
  				   | PTA_3DNOW_A},
!       {"athlon-tbird", PROCESSOR_ATHLON, PTA_MMX | PTA_PREFETCH_SSE
  					 | PTA_3DNOW | PTA_3DNOW_A},
!       {"athlon-4", PROCESSOR_ATHLON, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
  				    | PTA_3DNOW_A | PTA_SSE},
!       {"athlon-xp", PROCESSOR_ATHLON, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
  				      | PTA_3DNOW_A | PTA_SSE},
!       {"athlon-mp", PROCESSOR_ATHLON, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
  				      | PTA_3DNOW_A | PTA_SSE},
      };
  
*************** override_options ()
*** 861,868 ****
    SUBTARGET_OVERRIDE_OPTIONS;
  #endif
  
!   ix86_arch = PROCESSOR_I386;
!   ix86_cpu = (enum processor_type) TARGET_CPU_DEFAULT;
  
    if (ix86_cmodel_string != 0)
      {
--- 881,895 ----
    SUBTARGET_OVERRIDE_OPTIONS;
  #endif
  
!   if (!ix86_arch_string)
!     {
!       if (ix86_cpu_string)
! 	ix86_arch_string = ix86_arch_string)
!       else
! 	ix86_arch_string = TARGET_64BIT ? "athlon-4" : "i386";
!     }
!   if (!ix86_cpu_string)
!     ix86_cpu_string = cpu_names [TARGET_CPU_DEFAULT];
  
    if (ix86_cmodel_string != 0)
      {
*************** override_options ()
*** 896,942 ****
      sorry ("%i-bit mode not compiled in",
  	   (target_flags & MASK_64BIT) ? 64 : 32);
  
!   if (ix86_arch_string != 0)
!     {
!       for (i = 0; i < pta_size; i++)
! 	if (! strcmp (ix86_arch_string, processor_alias_table[i].name))
! 	  {
! 	    ix86_arch = processor_alias_table[i].processor;
! 	    /* Default cpu tuning to the architecture.  */
! 	    ix86_cpu = ix86_arch;
! 	    if (processor_alias_table[i].flags & PTA_MMX
! 	        && !(target_flags & MASK_MMX_SET))
! 	      target_flags |= MASK_MMX;
! 	    if (processor_alias_table[i].flags & PTA_3DNOW
! 	        && !(target_flags & MASK_3DNOW_SET))
! 	      target_flags |= MASK_3DNOW;
! 	    if (processor_alias_table[i].flags & PTA_3DNOW_A
! 	        && !(target_flags & MASK_3DNOW_A_SET))
! 	      target_flags |= MASK_3DNOW_A;
! 	    if (processor_alias_table[i].flags & PTA_SSE
! 	        && !(target_flags & MASK_SSE_SET))
! 	      target_flags |= MASK_SSE;
! 	    if (processor_alias_table[i].flags & PTA_SSE2
! 	        && !(target_flags & MASK_SSE2_SET))
! 	      target_flags |= MASK_SSE2;
! 	    break;
! 	  }
  
!       if (i == pta_size)
! 	error ("bad value (%s) for -march= switch", ix86_arch_string);
!     }
  
!   if (ix86_cpu_string != 0)
!     {
!       for (i = 0; i < pta_size; i++)
! 	if (! strcmp (ix86_cpu_string, processor_alias_table[i].name))
! 	  {
! 	    ix86_cpu = processor_alias_table[i].processor;
! 	    break;
! 	  }
!       if (i == pta_size)
! 	error ("bad value (%s) for -mcpu= switch", ix86_cpu_string);
!     }
  
    if (optimize_size)
      ix86_cost = &size_cost;
--- 923,965 ----
      sorry ("%i-bit mode not compiled in",
  	   (target_flags & MASK_64BIT) ? 64 : 32);
  
!   for (i = 0; i < pta_size; i++)
!     if (! strcmp (ix86_arch_string, processor_alias_table[i].name))
!       {
! 	ix86_arch = processor_alias_table[i].processor;
! 	/* Default cpu tuning to the architecture.  */
! 	ix86_cpu = ix86_arch;
! 	if (processor_alias_table[i].flags & PTA_MMX
! 	    && !(target_flags & MASK_MMX_SET))
! 	  target_flags |= MASK_MMX;
! 	if (processor_alias_table[i].flags & PTA_3DNOW
! 	    && !(target_flags & MASK_3DNOW_SET))
! 	  target_flags |= MASK_3DNOW;
! 	if (processor_alias_table[i].flags & PTA_3DNOW_A
! 	    && !(target_flags & MASK_3DNOW_A_SET))
! 	  target_flags |= MASK_3DNOW_A;
! 	if (processor_alias_table[i].flags & PTA_SSE
! 	    && !(target_flags & MASK_SSE_SET))
! 	  target_flags |= MASK_SSE;
! 	if (processor_alias_table[i].flags & PTA_SSE2
! 	    && !(target_flags & MASK_SSE2_SET))
! 	  target_flags |= MASK_SSE2;
! 	break;
!       }
  
!   if (i == pta_size)
!     error ("bad value (%s) for -march= switch", ix86_arch_string);
  
!   for (i = 0; i < pta_size; i++)
!     if (! strcmp (ix86_cpu_string, processor_alias_table[i].name))
!       {
! 	ix86_cpu = processor_alias_table[i].processor;
! 	break;
!       }
!   if (processor_alias_table[i].flags & PTA_PREFETCH_SSE)
!     x86_prefetch_sse = true;
!   if (i == pta_size)
!     error ("bad value (%s) for -mcpu= switch", ix86_cpu_string);
  
    if (optimize_size)
      ix86_cost = &size_cost;
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.222
diff -c -3 -p -r1.222 i386.h
*** i386.h	2001/12/13 11:34:10	1.222
--- i386.h	2001/12/13 20:48:04
*************** extern const int x86_add_esp_4, x86_add_
*** 224,229 ****
--- 227,233 ----
  extern const int x86_partial_reg_dependency, x86_memory_mismatch_stall;
  extern const int x86_accumulate_outgoing_args, x86_prologue_using_move;
  extern const int x86_epilogue_using_move, x86_decompose_lea;
+ extern int x86_prefetch_sse;
  
  #define TARGET_USE_LEAVE (x86_use_leave & CPUMASK)
  #define TARGET_PUSH_MEMORY (x86_push_memory & CPUMASK)
*************** extern const int x86_epilogue_using_move
*** 262,267 ****
--- 266,272 ----
  #define TARGET_PROLOGUE_USING_MOVE (x86_prologue_using_move & CPUMASK)
  #define TARGET_EPILOGUE_USING_MOVE (x86_epilogue_using_move & CPUMASK)
  #define TARGET_DECOMPOSE_LEA (x86_decompose_lea & CPUMASK)
+ #define TARGET_PREFETCH_SSE (x86_prefetch_sse)
  
  #define TARGET_STACK_PROBE (target_flags & MASK_STACK_PROBE)
  
*************** extern int ix86_arch;
*** 474,497 ****
  %n`-mpentiumpro' is deprecated. Use `-march=pentiumpro' or `-mcpu=pentiumpro' instead.\n}}"
  #endif
  
  #ifndef CPP_CPU_DEFAULT_SPEC
! #if TARGET_CPU_DEFAULT == 1
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i486__"
  #endif
! #if TARGET_CPU_DEFAULT == 2
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i586__ -D__tune_pentium__"
  #endif
! #if TARGET_CPU_DEFAULT == 3
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i686__ -D__tune_pentiumpro__"
  #endif
! #if TARGET_CPU_DEFAULT == 4
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_k6__"
  #endif
! #if TARGET_CPU_DEFAULT == 5
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_athlon__"
  #endif
! #if TARGET_CPU_DEFAULT == 6
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_pentium4__"
  #endif
  #ifndef CPP_CPU_DEFAULT_SPEC
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i386__"
--- 479,535 ----
  %n`-mpentiumpro' is deprecated. Use `-march=pentiumpro' or `-mcpu=pentiumpro' instead.\n}}"
  #endif
  
+ #define TARGET_CPU_DEFAULT_i386 0
+ #define TARGET_CPU_DEFAULT_i486 1
+ #define TARGET_CPU_DEFAULT_pentium 2
+ #define TARGET_CPU_DEFAULT_pentiumpro 3
+ #define TARGET_CPU_DEFAULT_pentium2 4
+ #define TARGET_CPU_DEFAULT_pentium3 5
+ #define TARGET_CPU_DEFAULT_pentium4 6
+ #define TARGET_CPU_DEFAULT_k6 7
+ #define TARGET_CPU_DEFAULT_k6_2 8
+ #define TARGET_CPU_DEFAULT_k6_3 9
+ #define TARGET_CPU_DEFAULT_athlon 10
+ #define TARGET_CPU_DEFAULT_athlon_sse 11
+ 
+ #define TARGET_CPU_DEFAULT_NAMES {"i386", "i486", "i586", "pentiumpro", "pentium2",\
+ 				  "pentium3", "pentium4", "k6", "k6-2", "k6-3",\
+ 				  "athlon", "athlon-4"}
  #ifndef CPP_CPU_DEFAULT_SPEC
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_i486
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i486__"
  #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_pentium
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i586__ -D__tune_pentium__"
  #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_pentiumpro
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i686__ -D__tune_pentiumpro__"
  #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_pentium2
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_i686__ -D__tune_pentiumpro__\
! -D__tune_pentium2__"
! #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_pentium3
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_i686__ -D__tune_pentiumpro__\
! -D__tune_pentium2__ -D__tune_pentium3__"
! #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_pentium4
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_pentium4__"
! #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_k6
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_k6__"
+ #endif
+ #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_k6_2
+ #define CPP_CPU_DEFAULT_SPEC "-D__tune_k6__ -D__tune_k6_2__"
  #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_k6_3
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_k6__ -D__tune_k6_3__"
! #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_athlon
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_athlon__"
  #endif
! #if TARGET_CPU_DEFAULT == TARGET_CPU_DEFAULT_athlon_sse
! #define CPP_CPU_DEFAULT_SPEC "-D__tune_athlon__ -D__tune_athlon_sse__"
  #endif
  #ifndef CPP_CPU_DEFAULT_SPEC
  #define CPP_CPU_DEFAULT_SPEC "-D__tune_i386__"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]