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]

[PATCH, committed] POWER5 popcntb, xl-compat, and options fixes.


	This patch adds the POWER5 popcntb instruction.  POWER5 introduces
a popcount byte instruction whose result can be merged to calculate
popcount for the entire register.

	This patch moves the xl-compat option to common code.  All
configurations that use the AIX ABI (AIX, PPC64 Linux, and Darwin),
including IBM long double, should have this option available for
compatibility with IBM XL compilers.

	This patch fixes a problem introduced by the earlier options
change.  Default settings for rs6000_sched_restricted_insns_priority and
rs6000_sched_costly_dep were commented out although they do have an
effect.

Bootstrapped and regression tested on powerpc-ibm-aix5.2.0.0.

David


	* config.gcc ({powerpc,rs6000}-ibm-aix*): Remove rs6000/aix.opt
	from extra_options.
	* config.in (HAVE_AS_POPCNTB): New.
	* configure.ac (HAVE_AS_MFCRF): Add .machine "pwr5" to AIX test.
	(HAVE_AS_POPCNTB): New.
	* configure: Regenerated.
	* config/rs6000/aix.h (TARGET_XL_COMPAT): Delete.
	* config/rs6000/rs6000.c (rs6000_override_options, power5): Add
	MASK_POPCNTB.  Uncomment rs6000_sched_restricted_insns_priority
	and rs6000_sched_costly_dep.
	* config/rs6000/rs6000.h (TARGET_POPCNTB): New.
	(TARGET_XL_COMPAT): Delete.
	* config/rs6000/rs6000.md (UNSPEC_POPCNTB): New.
	(popcount<mode>2): New.
	(popcntb<mode>2): New.
	* config/rs6000/rs6000.opt (mpopcntb): New.

Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.543
diff -c -p -r1.543 config.gcc
*** config.gcc	5 May 2005 20:54:15 -0000	1.543
--- config.gcc	7 May 2005 18:34:46 -0000
*************** powerpcle-*-kaos*)
*** 1768,1774 ****
  rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4.[12]*)
  	tm_file="${tm_file} rs6000/aix.h rs6000/aix41.h rs6000/xcoff.h"
  	tmake_file="rs6000/t-fprules rs6000/t-newas"
! 	extra_options="${extra_options} rs6000/aix.opt rs6000/aix41.opt"
  	use_collect2=yes
  	extra_headers=
  	use_fixproto=yes
--- 1768,1774 ----
  rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4.[12]*)
  	tm_file="${tm_file} rs6000/aix.h rs6000/aix41.h rs6000/xcoff.h"
  	tmake_file="rs6000/t-fprules rs6000/t-newas"
! 	extra_options="${extra_options} rs6000/aix41.opt"
  	use_collect2=yes
  	extra_headers=
  	use_fixproto=yes
*************** rs6000-ibm-aix4.[12]* | powerpc-ibm-aix4
*** 1776,1789 ****
  rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
  	tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix43.h rs6000/xcoff.h"
  	tmake_file=rs6000/t-aix43
! 	extra_options="${extra_options} rs6000/aix.opt rs6000/aix64.opt"
  	use_collect2=yes
  	thread_file='aix'
  	extra_headers=
  	;;
  rs6000-ibm-aix5.1.* | powerpc-ibm-aix5.1.*)
  	tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix51.h rs6000/xcoff.h"
! 	extra_options="${extra_options} rs6000/aix.opt rs6000/aix64.opt"
  	tmake_file=rs6000/t-aix43
  	use_collect2=yes
  	thread_file='aix'
--- 1776,1789 ----
  rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*)
  	tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix43.h rs6000/xcoff.h"
  	tmake_file=rs6000/t-aix43
! 	extra_options="${extra_options} rs6000/aix64.opt"
  	use_collect2=yes
  	thread_file='aix'
  	extra_headers=
  	;;
  rs6000-ibm-aix5.1.* | powerpc-ibm-aix5.1.*)
  	tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix51.h rs6000/xcoff.h"
! 	extra_options="${extra_options} rs6000/aix64.opt"
  	tmake_file=rs6000/t-aix43
  	use_collect2=yes
  	thread_file='aix'
*************** rs6000-ibm-aix5.1.* | powerpc-ibm-aix5.1
*** 1792,1798 ****
  rs6000-ibm-aix[56789].* | powerpc-ibm-aix[56789].*)
  	tm_file="${tm_file} rs6000/aix.h rs6000/aix52.h rs6000/xcoff.h"
  	tmake_file=rs6000/t-aix52
! 	extra_options="${extra_options} rs6000/aix.opt rs6000/aix64.opt"
  	use_collect2=yes
  	thread_file='aix'
  	extra_headers=
--- 1792,1798 ----
  rs6000-ibm-aix[56789].* | powerpc-ibm-aix[56789].*)
  	tm_file="${tm_file} rs6000/aix.h rs6000/aix52.h rs6000/xcoff.h"
  	tmake_file=rs6000/t-aix52
! 	extra_options="${extra_options} rs6000/aix64.opt"
  	use_collect2=yes
  	thread_file='aix'
  	extra_headers=
Index: config.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.in,v
retrieving revision 1.209
diff -c -p -r1.209 config.in
*** config.in	4 May 2005 01:14:41 -0000	1.209
--- config.in	7 May 2005 18:34:46 -0000
***************
*** 119,124 ****
--- 119,127 ----
  /* Define if your assembler supports offsetable %lo(). */
  #undef HAVE_AS_OFFSETABLE_LO10
  
+ /* Define if your assembler supports popcntb field. */
+ #undef HAVE_AS_POPCNTB
+ 
  /* Define if your assembler supports .register. */
  #undef HAVE_AS_REGISTER_PSEUDO_OP
  
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.ac,v
retrieving revision 2.107
diff -c -p -r2.107 configure.ac
*** configure.ac	4 May 2005 01:14:48 -0000	2.107
--- configure.ac	7 May 2005 18:34:48 -0000
*************** foo:	nop
*** 2768,2774 ****
  
    powerpc*-*-*)
      case $target in
!       *-*-aix*) conftest_s='	.csect .text[[PR]]
  	mfcr 3,128';;
        *-*-darwin*)
  	gcc_GAS_CHECK_FEATURE([.machine directive support],
--- 2768,2775 ----
  
    powerpc*-*-*)
      case $target in
!       *-*-aix*) conftest_s='	.machine "pwr5"
! 	.csect .text[[PR]]
  	mfcr 3,128';;
        *-*-darwin*)
  	gcc_GAS_CHECK_FEATURE([.machine directive support],
*************** foo:	nop
*** 2791,2796 ****
--- 2792,2813 ----
        [$conftest_s],,
        [AC_DEFINE(HAVE_AS_MFCRF, 1,
  	  [Define if your assembler supports mfcr field.])])
+ 
+     case $target in
+       *-*-aix*) conftest_s='	.machine "pwr5"
+ 	.csect .text[[PR]]
+ 	popcntb 3,3';;
+       *) conftest_s='	.machine power5
+ 	.text
+ 	popcntb 3,3';;
+     esac
+ 
+     gcc_GAS_CHECK_FEATURE([popcntb support],
+       gcc_cv_as_powerpc_popcntb, [2,17,0],,
+       [$conftest_s],,
+       [AC_DEFINE(HAVE_AS_POPCNTB, 1,
+ 	  [Define if your assembler supports popcntb field.])])
+ 
      ;;
  
    mips*-*-*)
Index: config/rs6000/aix.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/aix.h,v
retrieving revision 1.53
diff -c -p -r1.53 aix.h
*** config/rs6000/aix.h	5 May 2005 20:54:21 -0000	1.53
--- config/rs6000/aix.h	7 May 2005 18:34:48 -0000
***************
*** 194,203 ****
  
  #define JUMP_TABLES_IN_TEXT_SECTION 1
  
- /* Enable AIX XL compiler calling convention breakage compatibility.  */
- #undef  TARGET_XL_COMPAT
- #define	TARGET_XL_COMPAT	has_xl_compat_option
- 
  /* Define any extra SPECS that the compiler needs to generate.  */
  #undef  SUBTARGET_EXTRA_SPECS
  #define SUBTARGET_EXTRA_SPECS						\
--- 194,199 ----
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.821
diff -c -p -r1.821 rs6000.c
*** config/rs6000/rs6000.c	6 May 2005 13:40:30 -0000	1.821
--- config/rs6000/rs6000.c	7 May 2005 18:34:48 -0000
*************** rs6000_override_options (const char *def
*** 1114,1120 ****
  	 {"power4", PROCESSOR_POWER4,
  	  POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
  	 {"power5", PROCESSOR_POWER5,
! 	  POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
  	 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
  	 {"powerpc64", PROCESSOR_POWERPC64,
  	  POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
--- 1114,1121 ----
  	 {"power4", PROCESSOR_POWER4,
  	  POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POWERPC64},
  	 {"power5", PROCESSOR_POWER5,
! 	  POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GFXOPT
! 	  | MASK_MFCRF | MASK_POPCNTB},
  	 {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK},
  	 {"powerpc64", PROCESSOR_POWERPC64,
  	  POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64},
*************** rs6000_override_options (const char *def
*** 1312,1329 ****
    rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
  			 || rs6000_cpu == PROCESSOR_POWER5);
  
-   /* ?? I see no need for this.  This variable was always initialized to 0,
-      except when explicitly set.  It's not set in any .h file either.
    rs6000_sched_restricted_insns_priority
      = (rs6000_sched_groups ? 1 : 0);
-   */
  
    /* Handle -msched-costly-dep option.  */
-   /* ?? Same goes for this.  When would rs6000_sched_costly_dep ever have
-      a nonzero value upon entry to this function.  ??
    rs6000_sched_costly_dep
      = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
!   */
    if (rs6000_sched_costly_dep_str)
      {
        if (! strcmp (rs6000_sched_costly_dep_str, "no"))
--- 1313,1325 ----
    rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
  			 || rs6000_cpu == PROCESSOR_POWER5);
  
    rs6000_sched_restricted_insns_priority
      = (rs6000_sched_groups ? 1 : 0);
  
    /* Handle -msched-costly-dep option.  */
    rs6000_sched_costly_dep
      = (rs6000_sched_groups ? store_to_load_dep_costly : no_dep_costly);
! 
    if (rs6000_sched_costly_dep_str)
      {
        if (! strcmp (rs6000_sched_costly_dep_str, "no"))
*************** rs6000_override_options (const char *def
*** 1341,1346 ****
--- 1337,1343 ----
    /* Handle -minsert-sched-nops option.  */
    rs6000_sched_insert_nops
      = (rs6000_sched_groups ? sched_finish_regroup_exact : sched_finish_none);
+ 
    if (rs6000_sched_insert_nops_str)
      {
        if (! strcmp (rs6000_sched_insert_nops_str, "no"))
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.363
diff -c -p -r1.363 rs6000.h
*** config/rs6000/rs6000.h	5 May 2005 20:54:25 -0000	1.363
--- config/rs6000/rs6000.h	7 May 2005 18:34:48 -0000
***************
*** 132,141 ****
     optional field operand for mfcr.  */
  
  #ifndef HAVE_AS_MFCRF
! #undef TARGET_MFCRF
  #define TARGET_MFCRF 0
  #endif
  
  #define TARGET_32BIT		(! TARGET_64BIT)
  
  /* Emit a dtp-relative reference to a TLS variable.  */
--- 132,146 ----
     optional field operand for mfcr.  */
  
  #ifndef HAVE_AS_MFCRF
! #undef  TARGET_MFCRF
  #define TARGET_MFCRF 0
  #endif
  
+ #ifndef HAVE_AS_POPCNTB
+ #undef  TARGET_POPCNTB
+ #define TARGET_POPCNTB 0
+ #endif
+ 
  #define TARGET_32BIT		(! TARGET_64BIT)
  
  /* Emit a dtp-relative reference to a TLS variable.  */
***************
*** 166,173 ****
      /* The option machinery will define this.  */
  #endif
  
- #define TARGET_XL_COMPAT 0
- 
  #define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE | MASK_STRING)
  
  /* Processor type.  Order must match cpu attribute in MD file.  */
--- 171,176 ----
Index: config/rs6000/rs6000.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.364
diff -c -p -r1.364 rs6000.md
*** config/rs6000/rs6000.md	5 May 2005 05:09:12 -0000	1.364
--- config/rs6000/rs6000.md	7 May 2005 18:34:48 -0000
***************
*** 57,62 ****
--- 57,63 ----
     (UNSPEC_SYNC_SWAP		35)
     (UNSPEC_LWSYNC		36)
     (UNSPEC_ISYNC		37)
+    (UNSPEC_POPCNTB		38)
    ])
  
  ;;
***************
*** 1716,1721 ****
--- 1717,1747 ----
       operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
    })
  
+ (define_expand "popcount<mode>2"
+   [(set (match_dup 2)
+ 	(unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
+ 		     UNSPEC_POPCNTB))
+    (set (match_dup 3)
+ 	(mult:GPR (match_dup 2) (match_dup 4)))
+    (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+ 	(lshiftrt:GPR (match_dup 3) (match_dup 5)))]
+   "TARGET_POPCNTB"
+   {
+     operands[2] = gen_reg_rtx (<MODE>mode);
+     operands[3] = gen_reg_rtx (<MODE>mode);
+     operands[4] = force_reg (<MODE>mode, <MODE>mode == SImode
+ 					 ? GEN_INT (0x01010101)
+ 					 : GEN_INT (0x0101010101010101LL));
+     operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
+   })
+ 
+ (define_insn "popcntb<mode>2"
+   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+         (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
+                      UNSPEC_POPCNTB))]
+   "TARGET_POPCNTB"
+   "popcntb %0,%1")
+ 
  (define_expand "mulsi3"
    [(use (match_operand:SI 0 "gpc_reg_operand" ""))
     (use (match_operand:SI 1 "gpc_reg_operand" ""))
Index: config/rs6000/rs6000.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.opt,v
retrieving revision 1.1
diff -c -p -r1.1 rs6000.opt
*** config/rs6000/rs6000.opt	5 May 2005 20:54:21 -0000	1.1
--- config/rs6000/rs6000.opt	7 May 2005 18:34:48 -0000
*************** mpowerpc64
*** 44,53 ****
--- 44,77 ----
  Target Report Mask(POWERPC64)
  Use PowerPC-64 instruction set
  
+ mpowerpc-gpopt
+ Target Report Mask(PPC_GPOPT)
+ Use PowerPC General Purpose group optional instructions
+ 
+ mpowerpc-gfxopt
+ Target Report Mask(PPC_GFXOPT)
+ Use PowerPC Graphics group optional instructions
+ 
+ mmfcrf
+ Target Report Mask(MFCRF)
+ Generate single field mfcr instruction
+ 
+ mpopcntb
+ Target Report Mask(POPCNTB)
+ Use PowerPC/AS popcntb instruction
+ 
  maltivec
  Target Report Mask(ALTIVEC)
  Use AltiVec instructions
  
+ mmultiple
+ Target Report Mask(MULTIPLE)
+ Generate load/store multiple instructions
+ 
+ mstring
+ Target Report Mask(STRING)
+ Generate string instructions for block moves
+ 
  mnew-mnemonics
  Target Report RejectNegative Mask(NEW_MNEMONICS)
  Use new mnemonics for PowerPC architecture
*************** mold-mnemonics
*** 56,90 ****
  Target Report RejectNegative InverseMask(NEW_MNEMONICS)
  Use old mnemonics for PowerPC architecture
  
- mno-fp-in-toc
- Target Report RejectNegative Mask(NO_FP_IN_TOC)
- Do not place floating point constants in TOC
- 
- mfp-in-toc
- Target Report RejectNegative InverseMask(NO_FP_IN_TOC)
- Place floating point constants in TOC
- 
- mno-sum-in-toc
- Target RejectNegative Mask(NO_SUM_IN_TOC)
- Do not place symbol+offset constants in TOC
- 
- msum-in-toc
- Target RejectNegative InverseMask(NO_SUM_IN_TOC)
- Place symbol+offset constants in TOC
- 
- ;; ?? Where should we put documentation like this ??
- ;;
- ;  Output only one TOC entry per module.  Normally linking fails if
- ;   there are more than 16K unique variables/constants in an executable.  With
- ;   this option, linking fails only if there are more than 16K modules, or
- ;   if there are more than 16K unique variables/constant in a single module.
- ;
- ;   This is at the cost of having 2 extra loads and one extra store per
- ;   function, and one less allocable register.
- mminimal-toc
- Target Report Mask(MINIMAL_TOC)
- Use only one TOC entry per procedure
- 
  msoft-float
  Target Report RejectNegative Mask(SOFT_FLOAT)
  Do not use hardware floating point
--- 80,85 ----
*************** mhard-float
*** 93,106 ****
  Target Report RejectNegative InverseMask(SOFT_FLOAT, HARD_FLOAT)
  Use hardware floating point
  
- mmultiple
- Target Report Mask(MULTIPLE)
- Generate load/store multiple instructions
- 
- mstring
- Target Report Mask(STRING)
- Generate string instructions for block moves
- 
  mno-update
  Target Report RejectNegative Mask(NO_UPDATE)
  Do not generate load/store with update instructions
--- 88,93 ----
*************** msvr4-struct-return
*** 132,148 ****
  Target Report InverseMask(AIX_STRUCT_RET)
  Return small structures in registers (SVR4 default)
  
! mmfcrf
! Target Report Mask(MFCRF)
! Generate single field mfcr instruction
  
! mpowerpc-gpopt
! Target Report Mask(PPC_GPOPT)
! Use PowerPC General Purpose group optional instructions
  
! mpowerpc-gfxopt
! Target Report Mask(PPC_GFXOPT)
! Use PowerPC Graphics group optional instructions
  
  mfull-toc
  Target Report
--- 119,154 ----
  Target Report InverseMask(AIX_STRUCT_RET)
  Return small structures in registers (SVR4 default)
  
! mxl-compat
! Target Var(TARGET_XL_COMPAT)
! Conform more closely to IBM XLC semantics
  
! mno-fp-in-toc
! Target Report RejectNegative Mask(NO_FP_IN_TOC)
! Do not place floating point constants in TOC
  
! mfp-in-toc
! Target Report RejectNegative InverseMask(NO_FP_IN_TOC)
! Place floating point constants in TOC
! 
! mno-sum-in-toc
! Target RejectNegative Mask(NO_SUM_IN_TOC)
! Do not place symbol+offset constants in TOC
! 
! msum-in-toc
! Target RejectNegative InverseMask(NO_SUM_IN_TOC)
! Place symbol+offset constants in TOC
! 
! ;  Output only one TOC entry per module.  Normally linking fails if
! ;   there are more than 16K unique variables/constants in an executable.  With
! ;   this option, linking fails only if there are more than 16K modules, or
! ;   if there are more than 16K unique variables/constant in a single module.
! ;
! ;   This is at the cost of having 2 extra loads and one extra store per
! ;   function, and one less allocable register.
! mminimal-toc
! Target Report Mask(MINIMAL_TOC)
! Use only one TOC entry per procedure
  
  mfull-toc
  Target Report


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