public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC: PATCH: Require and use int64 for x86 options
@ 2011-07-27 17:00 H.J. Lu
  2011-07-27 17:40 ` Uros Bizjak
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: H.J. Lu @ 2011-07-27 17:00 UTC (permalink / raw)
  To: Ian Lance Taylor, Joseph S. Myers, Uros Bizjak; +Cc: Igor Zamyatin, gcc

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

On Wed, Jul 13, 2011 at 6:22 AM, Ian Lance Taylor <iant@google.com> wrote:
> Igor Zamyatin <izamyatin@gmail.com> writes:
>
>> As you may see pta_flags enum in i386.c is almost full. So there is a
>> risk of overflow in quite near future. Comment in source code advises
>> "widen struct pta flags" which is now defined as unsigned. But it
>> looks not optimal.
>>
>> What will be the most proper solution for this problem?
>
> Why is widening pta_flags "not optimal?"
>
> It's hard for me to believe that we still care about bootstrapping a
> i386-*-* compiler with a compiler which doesn't support any 64-bit type.
> So I don't see any problem with setting need_64bit_hwint=yes in
> config.gcc for i386-*-*, changing pta_flags to be unsigned
> HOST_WIDE_INT, and letting pta_flags go up to (unsigned HOST_WIDE_INT) 1
> << 63.
>
> If anybody doesn't like that idea, we can simply add a flags2 field and
> a pta_flags2 enum with PTA2_xxx constants.
>

Hi,

We are also running out of bits in ix86_isa_flags.  This patch uses
int64 on both ix86_isa_flags and PTA.  I added a new option to opt:

; Maximum number of mask bits in a variable.
MaxMaskBits
ix86_isa_flags = 64

It mark ix86_isa_flags as 64bit.  Any comments?

Thanks.


-- 
H.J.
---
gcc/

2011-07-27  H.J. Lu  <hongjiu.lu@intel.com>

	* config.gcc: Set need_64bit_hwint to yes for x86 targets.

	* opt-read.awk (BEGIN): Set max_mask_bits[var] and
	var_mask_1[var].

	* opth-gen.awk: Use var_mask_1[var] instead of 1.  Check
	max_mask_bits[var] instead of 31.

	* config/i386/i386.c (pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

	* config/i386/i386.opt (MaxMaskBits): New.
	(ix86_isa_flags): Replace int with HOST_WIDE_INT.
	(ix86_isa_flags_explicit): Likewise.
	(x_ix86_isa_flags_explicit): Likewise.

libcpp/

2011-07-27  H.J. Lu  <hongjiu.lu@intel.com>

	* configure.ac: Set need_64bit_hwint to yes for x86 targets.
	* configure: Regenerated.

[-- Attachment #2: gcc-x86-int64-1.patch --]
[-- Type: text/x-diff, Size: 6862 bytes --]

gcc/

2011-07-27  H.J. Lu  <hongjiu.lu@intel.com>

	* config.gcc: Set need_64bit_hwint to yes for x86 targets.

	* opt-read.awk (BEGIN): Set max_mask_bits[var] and
	var_mask_1[var].

	* opth-gen.awk: Use var_mask_1[var] instead of 1.  Check
	max_mask_bits[var] instead of 31. 

	* config/i386/i386.c (pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

	* config/i386/i386.opt (MaxMaskBits): New.
	(ix86_isa_flags): Replace int with HOST_WIDE_INT.
	(ix86_isa_flags_explicit): Likewise.
	(x_ix86_isa_flags_explicit): Likewise.

libcpp/

2011-07-27  H.J. Lu  <hongjiu.lu@intel.com>

	* configure.ac: Set need_64bit_hwint to yes for x86 targets.
	* configure: Regenerated.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d7cf895..54ac985 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -345,6 +345,7 @@ i[34567]86-*-*)
 	cpu_type=i386
 	c_target_objs="i386-c.o"
 	cxx_target_objs="i386-c.o"
+	need_64bit_hwint=yes
 	extra_options="${extra_options} fused-madd.opt"
 	extra_headers="cpuid.h mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h
 		       pmmintrin.h tmmintrin.h ammintrin.h smmintrin.h
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 96263ed..c5dd881 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2918,7 +2918,7 @@ ix86_option_override_internal (bool main_args_p)
       PTA_F16C = 1 << 26,
       PTA_BMI = 1 << 27,
       PTA_TBM = 1 << 28
-      /* if this reaches 32, need to widen struct pta flags below */
+      /* if this reaches 64, need to widen struct pta flags below */
     };
 
   static struct pta
@@ -2926,7 +2926,7 @@ ix86_option_override_internal (bool main_args_p)
       const char *const name;		/* processor name or nickname.  */
       const enum processor_type processor;
       const enum attr_cpu schedule;
-      const unsigned /*enum pta_flags*/ flags;
+      const unsigned HOST_WIDE_INT /*enum pta_flags*/ flags;
     }
   const processor_alias_table[] =
     {
@@ -24016,7 +24016,7 @@ static GTY(()) tree ix86_builtins[(int) IX86_BUILTIN_MAX];
 struct builtin_isa {
   const char *name;		/* function name */
   enum ix86_builtin_func_type tcode; /* type to use in the declaration */
-  int isa;			/* isa_flags this builtin is defined for */
+  HOST_WIDE_INT isa;		/* isa_flags this builtin is defined for */
   bool const_p;			/* true if the declaration is constant */
   bool set_and_not_built_p;
 };
@@ -24041,7 +24041,8 @@ static struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX];
    errors if a builtin is added in the middle of a function scope.  */
 
 static inline tree
-def_builtin (int mask, const char *name, enum ix86_builtin_func_type tcode,
+def_builtin (HOST_WIDE_INT mask, const char *name,
+	     enum ix86_builtin_func_type tcode,
 	     enum ix86_builtins code)
 {
   tree decl = NULL_TREE;
@@ -24079,7 +24080,7 @@ def_builtin (int mask, const char *name, enum ix86_builtin_func_type tcode,
 /* Like def_builtin, but also marks the function decl "const".  */
 
 static inline tree
-def_builtin_const (int mask, const char *name,
+def_builtin_const (HOST_WIDE_INT mask, const char *name,
 		   enum ix86_builtin_func_type tcode, enum ix86_builtins code)
 {
   tree decl = def_builtin (mask, name, tcode, code);
@@ -24130,7 +24131,7 @@ ix86_add_new_builtins (int isa)
 
 struct builtin_description
 {
-  const unsigned int mask;
+  const HOST_WIDE_INT mask;
   const enum insn_code icode;
   const char *const name;
   const enum ix86_builtins code;
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 5e6b5df..281fec3 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -22,14 +22,18 @@
 HeaderInclude
 config/i386/i386-opts.h
 
+; Maximum number of mask bits in a variable.
+MaxMaskBits
+ix86_isa_flags = 64
+
 ; Bit flags that specify the ISA we are compiling for.
 Variable
-int ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT
+HOST_WIDE_INT ix86_isa_flags = TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_ISA_DEFAULT
 
 ; A mask of ix86_isa_flags that includes bit X if X was set or cleared
 ; on the command line.
 Variable
-int ix86_isa_flags_explicit
+HOST_WIDE_INT ix86_isa_flags_explicit
 
 ;; Definitions to add to the cl_target_option structure
 ;; -march= processor
@@ -50,7 +54,7 @@ unsigned char branch_cost
 
 ;; which flags were passed by the user
 TargetSave
-int x_ix86_isa_flags_explicit
+HOST_WIDE_INT x_ix86_isa_flags_explicit
 
 ;; which flags were passed by the user
 TargetSave
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index c488ed5..9884175 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -101,6 +101,15 @@ BEGIN {
 			  "  { " quote string quote ", " value ", " val_flags \
 			  " },\n"
 		}
+		if ($1 == "MaxMaskBits") {
+			max = $2 
+			var = max; 
+			sub(" *=.*", "", var)
+			sub(".*=", "", max)
+			max_mask_bits[var] = max
+			if (max == 64)
+			  var_mask_1[var] = "1LL"
+		}
 		else {
 			name = opt_args("Mask", $1)
 			if (name == "") {
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 876e0f6..c4f7b1d 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -300,18 +300,25 @@ for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
 	vname = var_name(flags[i])
 	mask = "MASK_"
+	mask_1 = ""
 	if (vname != "") {
 		mask = "OPTION_MASK_"
+		mask_1 = var_mask_1[vname]
 	}
+	if (mask_1 == "")
+	  mask_1 = "1"
 	if (name != "" && !flag_set_p("MaskExists", flags[i]))
-		print "#define " mask name " (1 << " masknum[vname]++ ")"
+		print "#define " mask name " (" mask_1 " << " masknum[vname]++ ")"
 }
 for (i = 0; i < n_extra_masks; i++) {
 	print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")"
 }
 
 for (var in masknum) {
-	if (masknum[var] > 31) {
+	max = max_mask_bits[var]
+	if (max == "")
+	  max = 32
+	if (masknum[var] >= max) {
 		if (var == "")
 			print "#error too many target masks"
 		else
diff --git a/libcpp/configure b/libcpp/configure
index b453a7b..27a867c 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7312,9 +7312,7 @@ case $target in
 	x86_64-*-* | \
 	ia64-*-* | \
 	hppa*64*-*-* | \
-	i[34567]86-*-darwin* | \
-	i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]* | \
-	i[34567]86-w64-mingw* | \
+	i[34567]86-*-* | x86_64-*-solaris2.1[0-9]* | \
 	mips*-*-* | \
 	mmix-*-* | \
 	powerpc*-*-* | \
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 170932c..6e9adbf 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -150,9 +150,7 @@ case $target in
 	x86_64-*-* | \
 	ia64-*-* | \
 	hppa*64*-*-* | \
-	i[34567]86-*-darwin* | \
-	i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]* | \
-	i[34567]86-w64-mingw* | \
+	i[34567]86-*-* | x86_64-*-solaris2.1[0-9]* | \
 	mips*-*-* | \
 	mmix-*-* | \
 	powerpc*-*-* | \

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-08-05  0:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27 17:00 RFC: PATCH: Require and use int64 for x86 options H.J. Lu
2011-07-27 17:40 ` Uros Bizjak
2011-07-27 18:05   ` H.J. Lu
2011-07-27 21:37 ` Joseph S. Myers
2011-07-27 22:00   ` H.J. Lu
2011-07-28 14:34     ` H.J. Lu
2011-08-04 18:08   ` H.J. Lu
2011-08-04 22:09     ` H.J. Lu
2011-08-04 22:46       ` Joseph S. Myers
2011-08-04 23:44         ` H.J. Lu
2011-08-05  0:50           ` H.J. Lu
2011-07-29  9:53 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).