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

* Re: RFC: PATCH: Require and use int64 for x86 options
  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-29  9:53 ` Paolo Bonzini
  2 siblings, 1 reply; 12+ messages in thread
From: Uros Bizjak @ 2011-07-27 17:40 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Ian Lance Taylor, Joseph S. Myers, Igor Zamyatin, gcc

On Wed, Jul 27, 2011 at 6:42 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> 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?

We should just introduce ix86_isa_flags2.  We shouldn't stop at 128 flags. ;)

Uros.

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-07-27 17:40 ` Uros Bizjak
@ 2011-07-27 18:05   ` H.J. Lu
  0 siblings, 0 replies; 12+ messages in thread
From: H.J. Lu @ 2011-07-27 18:05 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: Ian Lance Taylor, Joseph S. Myers, Igor Zamyatin, gcc

On Wed, Jul 27, 2011 at 10:00 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Wed, Jul 27, 2011 at 6:42 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>>> 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?
>
> We should just introduce ix86_isa_flags2.  We shouldn't stop at 128 flags. ;)
>

It is used to control which insns are are available. See
OPTION_MASK_ISA_XXX_SET and OPTION_MASK_ISA_XXX_UNSET
in common/config/i386/i386-common.c.  Adding ix86_isa_flags2
makes it very complicated:

1. We need to turn on a set of ISAs for -mXXX.
2. We need to turn off a set of ISAs for -mno-XXX.
3. We need to check 2 fields in def_builtin to see if an insn is
available.

As a side benefit,  need_64bit_hwint=yes will resolve
many 32bit code generation differences on ia32 and x86-64 hosts.
We can close a bunch of bugs, like

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43226



-- 
H.J.

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  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 21:37 ` Joseph S. Myers
  2011-07-27 22:00   ` H.J. Lu
  2011-08-04 18:08   ` H.J. Lu
  2011-07-29  9:53 ` Paolo Bonzini
  2 siblings, 2 replies; 12+ messages in thread
From: Joseph S. Myers @ 2011-07-27 21:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

On Wed, 27 Jul 2011, H.J. Lu wrote:

> ; Maximum number of mask bits in a variable.
> MaxMaskBits
> ix86_isa_flags = 64
> 
> It mark ix86_isa_flags as 64bit.  Any comments?

The patch won't work as is.  set_option, for example, casts a pointer to 
(int *), and stores a mask that came from option->var_value, which is an 
int, so this won't work with option fields not of type int or values that 
don't fit in int; you'd need to check all uses of CLVC_BIT_CLEAR and 
CLVC_BIT_SET in the source tree to adapt things for the possibility of 
wider mask fields, and track the type of each such field.

Independently, I approve of setting need_64bit_hwint for all x86 targets, 
but your patch doesn't achieve the expected simplification.  In 
config.gcc, there are settings for various individual targets that should 
be removed once it's set in one place for all x86 targets.  In 
libcpp/configure.ac, similarly the cases for 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-*-linux* (the last only if 
--enable-targets=all) should all be removed as obsolete once 
i[34567]86-*-* is there along with x86_64-*-*.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  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
  1 sibling, 1 reply; 12+ messages in thread
From: H.J. Lu @ 2011-07-27 22:00 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

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

On Wed, Jul 27, 2011 at 2:23 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Wed, 27 Jul 2011, H.J. Lu wrote:
>
>> ; Maximum number of mask bits in a variable.
>> MaxMaskBits
>> ix86_isa_flags = 64
>>
>> It mark ix86_isa_flags as 64bit.  Any comments?
>
> The patch won't work as is.  set_option, for example, casts a pointer to
> (int *), and stores a mask that came from option->var_value, which is an
> int, so this won't work with option fields not of type int or values that
> don't fit in int; you'd need to check all uses of CLVC_BIT_CLEAR and
> CLVC_BIT_SET in the source tree to adapt things for the possibility of
> wider mask fields, and track the type of each such field.

We will prepare a separate patch.

> Independently, I approve of setting need_64bit_hwint for all x86 targets,
> but your patch doesn't achieve the expected simplification.  In
> config.gcc, there are settings for various individual targets that should
> be removed once it's set in one place for all x86 targets.  In
> libcpp/configure.ac, similarly the cases for 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-*-linux* (the last only if
> --enable-targets=all) should all be removed as obsolete once
> i[34567]86-*-* is there along with x86_64-*-*.
>

Is this patch OK for trunk?

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.

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-2.patch --]
[-- Type: text/x-diff, Size: 3450 bytes --]

gcc/

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

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

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..02cc556 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
@@ -1211,7 +1212,6 @@ hppa[12]*-*-hpux11*)
 	fi
 	;;
 i[34567]86-*-darwin*)
-	need_64bit_hwint=yes
 	need_64bit_isa=yes
 	# Baseline choice for a machine that allows m64 support.
 	with_cpu=${with_cpu:-core2}
@@ -1293,7 +1293,6 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 				esac
 			done
 			TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
-			need_64bit_hwint=yes
 			need_64bit_isa=yes
 			case X"${with_cpu}" in
 			Xgeneric|Xatom|Xcore2|Xcorei7|Xcorei7-avx|Xnocona|Xx86-64|Xbdver2|Xbdver1|Xbtver1|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx|Xathlon64-sse3|Xk8-sse3|Xopteron-sse3)
@@ -1415,7 +1414,6 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
 		tm_file="${tm_file} i386/x86-64.h i386/sol2-bi.h sol2-bi.h"
 		tm_defines="${tm_defines} TARGET_BI_ARCH=1"
 		tmake_file="$tmake_file i386/t-sol2-64"
-		need_64bit_hwint=yes
 		need_64bit_isa=yes
 		case X"${with_cpu}" in
 		Xgeneric|Xatom|Xcore2|Xcorei7|Xcorei7-avx|Xnocona|Xx86-64|Xbdver2|Xbdver1|Xbtver1|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx|Xathlon64-sse3|Xk8-sse3|Xopteron-sse3)
@@ -1478,7 +1476,6 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	case ${target} in
 		x86_64-*-* | *-w64-*)
-			need_64bit_hwint=yes
 			need_64bit_isa=yes
 			;;
 		*)
diff --git a/libcpp/configure b/libcpp/configure
index b453a7b..c400d23 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*-*-* | \
@@ -7324,13 +7322,6 @@ case $target in
 	spu-*-* | \
 	sh[123456789lbe]*-*-* | sh-*-*)
 		need_64bit_hwint=yes ;;
-	i[34567]86-*-linux*)
-		if test "x$enable_targets" = xall; then
-			need_64bit_hwint=yes
-		else
-			need_64bit_hwint=no
-		fi
-		;;
 	*)
 		need_64bit_hwint=no ;;
 esac
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 170932c..e1d8851 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*-*-* | \
@@ -162,13 +160,6 @@ case $target in
 	spu-*-* | \
 	sh[123456789lbe]*-*-* | sh-*-*)
 		need_64bit_hwint=yes ;;
-	i[34567]86-*-linux*)
-		if test "x$enable_targets" = xall; then
-			need_64bit_hwint=yes
-		else
-			need_64bit_hwint=no
-		fi
-		;;
 	*)
 		need_64bit_hwint=no ;;
 esac

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-07-27 22:00   ` H.J. Lu
@ 2011-07-28 14:34     ` H.J. Lu
  0 siblings, 0 replies; 12+ messages in thread
From: H.J. Lu @ 2011-07-28 14:34 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

On Wed, Jul 27, 2011 at 2:37 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jul 27, 2011 at 2:23 PM, Joseph S. Myers
> <joseph@codesourcery.com> wrote:
>> On Wed, 27 Jul 2011, H.J. Lu wrote:
>>
>>> ; Maximum number of mask bits in a variable.
>>> MaxMaskBits
>>> ix86_isa_flags = 64
>>>
>>> It mark ix86_isa_flags as 64bit.  Any comments?
>>
>> The patch won't work as is.  set_option, for example, casts a pointer to
>> (int *), and stores a mask that came from option->var_value, which is an
>> int, so this won't work with option fields not of type int or values that
>> don't fit in int; you'd need to check all uses of CLVC_BIT_CLEAR and
>> CLVC_BIT_SET in the source tree to adapt things for the possibility of
>> wider mask fields, and track the type of each such field.
>
> We will prepare a separate patch.
>
>> Independently, I approve of setting need_64bit_hwint for all x86 targets,
>> but your patch doesn't achieve the expected simplification.  In
>> config.gcc, there are settings for various individual targets that should
>> be removed once it's set in one place for all x86 targets.  In
>> libcpp/configure.ac, similarly the cases for 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-*-linux* (the last only if
>> --enable-targets=all) should all be removed as obsolete once
>> i[34567]86-*-* is there along with x86_64-*-*.
>>
>
> Is this patch OK for trunk?
>
> 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.
>
> libcpp/
>
> 2011-07-27  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * configure.ac: Set need_64bit_hwint to yes for x86 targets.
>        * configure: Regenerated.
>

Bootstrapped on Linux/ia32.  I am checking it in.

Thanks.

-- 
H.J.

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  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 21:37 ` Joseph S. Myers
@ 2011-07-29  9:53 ` Paolo Bonzini
  2 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2011-07-29  9:53 UTC (permalink / raw)
  To: gcc; +Cc: Ian Lance Taylor, Joseph S. Myers, Uros Bizjak, Igor Zamyatin, gcc

On 07/27/2011 06:42 PM, H.J. Lu wrote:
> +			if (max == 64)
> +			  var_mask_1[var] = "1LL"

This must be ((HOST_WIDE_INT)1).

Paolo

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-07-27 21:37 ` Joseph S. Myers
  2011-07-27 22:00   ` H.J. Lu
@ 2011-08-04 18:08   ` H.J. Lu
  2011-08-04 22:09     ` H.J. Lu
  1 sibling, 1 reply; 12+ messages in thread
From: H.J. Lu @ 2011-08-04 18:08 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

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

On Wed, Jul 27, 2011 at 2:23 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Wed, 27 Jul 2011, H.J. Lu wrote:
>
>> ; Maximum number of mask bits in a variable.
>> MaxMaskBits
>> ix86_isa_flags = 64
>>
>> It mark ix86_isa_flags as 64bit.  Any comments?
>
> The patch won't work as is.  set_option, for example, casts a pointer to
> (int *), and stores a mask that came from option->var_value, which is an
> int, so this won't work with option fields not of type int or values that
> don't fit in int; you'd need to check all uses of CLVC_BIT_CLEAR and
> CLVC_BIT_SET in the source tree to adapt things for the possibility of
> wider mask fields, and track the type of each such field.
>

Here is the updated patch.  Tested on Linux/ia32 and Linux/x86-64. I
used (1LL < X) for HOST_WIDE_INT instead of ((HOST_WIDE_INT) 1 << x)
since we have

#define OPTION_MASK_ISA_64BIT (1LL << 2)
...
#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
...

#if TARGET_64BIT_DEFAULT
#define OPT_ARCH64 "!m32"
#define OPT_ARCH32 "m32"
#else
#define OPT_ARCH64 "m64|mx32"
#define OPT_ARCH32 "m64|mx32:;"
#endif

and C preprocessor doesn't support ((HOST_WIDE_INT) 1 << x).

OK for trunk?

Thanks.

-- 
H.J.
---
2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* opt-functions/awk (switch_bit_fields): Initialization
	of the host_wide_int field.
	(host_wide_int_var_name): New.
	var_type_struct): Return HOST_WIDE_INT on 64bit integer.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use 1LL for 64bit integer.  Check max_mask_bits
	instead of 31 for target masks.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

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

2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* opt-functions/awk (switch_bit_fields): Initialization
	of the host_wide_int field.
	(host_wide_int_var_name): New.
	var_type_struct): Return HOST_WIDE_INT on 64bit integer.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use 1LL for 64bit integer.  Check max_mask_bits
	instead of 31 for target masks.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index 1fc333c..c5a770f 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -34,14 +34,14 @@ along with GCC; see the file COPYING3.  If not see
 
 static bool ix86_pragma_target_parse (tree, tree);
 static void ix86_target_macros_internal
-  (int, enum processor_type, enum processor_type, enum fpmath_unit,
+  (HOST_WIDE_INT, enum processor_type, enum processor_type, enum fpmath_unit,
    void (*def_or_undef) (cpp_reader *, const char *));
 
 \f
 /* Internal function to either define or undef the appropriate system
    macros.  */
 static void
-ix86_target_macros_internal (int isa_flag,
+ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
 			     enum processor_type arch,
 			     enum processor_type tune,
 			     enum fpmath_unit fpmath,
@@ -301,9 +301,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
   tree cur_tree;
   struct cl_target_option *prev_opt;
   struct cl_target_option *cur_opt;
-  int prev_isa;
-  int cur_isa;
-  int diff_isa;
+  HOST_WIDE_INT prev_isa;
+  HOST_WIDE_INT cur_isa;
+  HOST_WIDE_INT diff_isa;
   enum processor_type prev_arch;
   enum processor_type prev_tune;
   enum processor_type cur_arch;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a7f8ee5..a940deb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2500,7 +2500,7 @@ static int ix86_function_regparm (const_tree, const_tree);
 static void ix86_compute_frame_layout (struct ix86_frame *);
 static bool ix86_expand_vector_init_one_nonzero (bool, enum machine_mode,
 						 rtx, rtx, int);
-static void ix86_add_new_builtins (int);
+static void ix86_add_new_builtins (HOST_WIDE_INT);
 static rtx ix86_expand_vec_perm_builtin (tree);
 static tree ix86_canonical_va_list_type (tree);
 static void predict_jump (int);
@@ -2514,7 +2514,7 @@ enum ix86_function_specific_strings
   IX86_FUNCTION_SPECIFIC_MAX
 };
 
-static char *ix86_target_string (int, int, const char *, const char *,
+static char *ix86_target_string (HOST_WIDE_INT, int, const char *, const char *,
 				 enum fpmath_unit, bool);
 static void ix86_debug_options (void) ATTRIBUTE_UNUSED;
 static void ix86_function_specific_save (struct cl_target_option *);
@@ -2633,13 +2633,14 @@ ix86_using_red_zone (void)
    responsible for freeing the string.  */
 
 static char *
-ix86_target_string (int isa, int flags, const char *arch, const char *tune,
-		    enum fpmath_unit fpmath, bool add_nl_p)
+ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
+		    const char *tune, enum fpmath_unit fpmath,
+		    bool add_nl_p)
 {
   struct ix86_target_opts
   {
     const char *option;		/* option string */
-    int mask;			/* isa mask options */
+    HOST_WIDE_INT mask;		/* isa mask options */
   };
 
   /* This table is ordered so that options like -msse4.2 that imply
@@ -2747,7 +2748,8 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
   if (isa && add_nl_p)
     {
       opts[num++][0] = isa_other;
-      sprintf (isa_other, "(other isa: %#x)", isa);
+      sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)",
+	       isa);
     }
 
   /* Add flag options.  */
@@ -2888,47 +2890,44 @@ ix86_option_override_internal (bool main_args_p)
   const char *suffix;
   const char *sw;
 
-  enum pta_flags
-    {
-      PTA_SSE = 1 << 0,
-      PTA_SSE2 = 1 << 1,
-      PTA_SSE3 = 1 << 2,
-      PTA_MMX = 1 << 3,
-      PTA_PREFETCH_SSE = 1 << 4,
-      PTA_3DNOW = 1 << 5,
-      PTA_3DNOW_A = 1 << 6,
-      PTA_64BIT = 1 << 7,
-      PTA_SSSE3 = 1 << 8,
-      PTA_CX16 = 1 << 9,
-      PTA_POPCNT = 1 << 10,
-      PTA_ABM = 1 << 11,
-      PTA_SSE4A = 1 << 12,
-      PTA_NO_SAHF = 1 << 13,
-      PTA_SSE4_1 = 1 << 14,
-      PTA_SSE4_2 = 1 << 15,
-      PTA_AES = 1 << 16,
-      PTA_PCLMUL = 1 << 17,
-      PTA_AVX = 1 << 18,
-      PTA_FMA = 1 << 19,
-      PTA_MOVBE = 1 << 20,
-      PTA_FMA4 = 1 << 21,
-      PTA_XOP = 1 << 22,
-      PTA_LWP = 1 << 23,
-      PTA_FSGSBASE = 1 << 24,
-      PTA_RDRND = 1 << 25,
-      PTA_F16C = 1 << 26,
-      PTA_BMI = 1 << 27,
-      PTA_TBM = 1 << 28,
-      PTA_LZCNT = 1 << 29
-      /* if this reaches 32, need to widen struct pta flags below */
-    };
+#define PTA_3DNOW	 	(1LL << 0)
+#define PTA_3DNOW_A	 	(1LL << 1)
+#define PTA_64BIT		(1LL << 2)
+#define PTA_ABM			(1LL << 3)
+#define PTA_AES		 	(1LL << 4)
+#define PTA_AVX			(1LL << 5)
+#define PTA_BMI		 	(1LL << 6)
+#define PTA_CX16		(1LL << 7)
+#define PTA_F16C		(1LL << 8)
+#define PTA_FMA			(1LL << 9)
+#define PTA_FMA4	 	(1LL << 10)
+#define PTA_FSGSBASE		(1LL << 11)
+#define PTA_LWP		 	(1LL << 12)
+#define PTA_LZCNT	 	(1LL << 13)
+#define PTA_MMX			(1LL << 14)
+#define PTA_MOVBE		(1LL << 15)
+#define PTA_NO_SAHF		(1LL << 16)
+#define PTA_PCLMUL		(1LL << 17)
+#define PTA_POPCNT		(1LL << 18)
+#define PTA_PREFETCH_SSE	(1LL << 19)
+#define PTA_RDRND	 	(1LL << 20)
+#define PTA_SSE			(1LL << 21)
+#define PTA_SSE2		(1LL << 22)
+#define PTA_SSE3		(1LL << 23)
+#define PTA_SSE4_1	 	(1LL << 24)
+#define PTA_SSE4_2	 	(1LL << 25)
+#define PTA_SSE4A		(1LL << 26)
+#define PTA_SSSE3		(1LL << 27)
+#define PTA_TBM		 	(1LL << 28)
+#define PTA_XOP		 	(1LL << 29)
+/* if this reaches 64, need to widen struct pta flags below */
 
   static struct pta
     {
       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 flags;
     }
   const processor_alias_table[] =
     {
@@ -24047,7 +24046,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;
 };
@@ -24072,7 +24071,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;
@@ -24110,7 +24110,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);
@@ -24127,7 +24127,7 @@ def_builtin_const (int mask, const char *name,
    declarations to the tree, even if we didn't use them.  */
 
 static void
-ix86_add_new_builtins (int isa)
+ix86_add_new_builtins (HOST_WIDE_INT isa)
 {
   int i;
 
@@ -24161,7 +24161,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 f197dd8..654f4eb 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -24,12 +24,12 @@ config/i386/i386-opts.h
 
 ; 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 +50,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-functions.awk b/gcc/opt-functions.awk
index 945eeb1..cab7817 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -110,6 +110,11 @@ function switch_flags (flags)
 # Return bit-field initializers for option flags FLAGS.
 function switch_bit_fields (flags)
 {
+	vn = var_name(flags);
+	if (max_mask_bits[vn] == 64)
+		host_wide_int = "Host_Wide_Int"
+	else
+		host_wide_int = ""
 	result = ""
 	sep_args = opt_args("Args", flags)
 	if (sep_args == "")
@@ -126,6 +131,7 @@ function switch_bit_fields (flags)
 	  flag_init("RejectNegative", flags) \
 	  flag_init("JoinedOrMissing", flags) \
 	  flag_init("UInteger", flags) \
+	  flag_init("Host_Wide_Int", host_wide_int) \
 	  flag_init("ToLower", flags) \
 	  flag_init("Report", flags)
 
@@ -140,6 +146,17 @@ function var_name(flags)
 	return nth_arg(0, opt_args("Var", flags))
 }
 
+# Return the name of the variable if FLAGS has a HOST_WIDE_INT variable. 
+# Return the empty string otherwise.
+function host_wide_int_var_name(flags)
+{
+	split (flags, array, "[ \t]+")
+	if (array[1] == "HOST_WIDE_INT")
+		return array[2]
+	else
+		return ""
+}
+
 # Return true if the option described by FLAGS has a globally-visible state.
 function global_state_p(flags)
 {
@@ -197,8 +214,12 @@ function var_type_struct(flags)
 		return enum_type[en] " "
 	}
 	else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
-		if (flag_set_p(".*Mask.*", flags))
-			return "int "
+		if (flag_set_p(".*Mask.*", flags)) {
+			if (max_mask_bits[var_name(flags)] == 64)
+				return "HOST_WIDE_INT "
+			else
+				return "int "
+		}
 		else
 			return "signed char "
 	}
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index c488ed5..1f4b741 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -51,6 +51,9 @@ BEGIN {
 		else if ($1 == "Variable") {
 			extra_vars[n_extra_vars] = $2
 			n_extra_vars++
+			name = host_wide_int_var_name($2)
+			if (name != "")
+				max_mask_bits[name] = 64
 		}
 		else if ($1 == "TargetVariable") {
 			# Combination of TargetSave and Variable
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 4efc115..718db96 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -363,10 +363,16 @@ print "{";
 print "  fputs (\"\\n\", file);";
 for (i = 0; i < n_target_other; i++) {
 	print "  if (ptr->x_" var_target_other[i] ")";
-	print "    fprintf (file, \"%*s%s (%#lx)\\n\",";
+	if (max_mask_bits[var_target_other[i]] == 64)
+		print "    fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
+	else
+		print "    fprintf (file, \"%*s%s (%#x)\\n\",";
 	print "             indent, \"\",";
 	print "             \"" var_target_other[i] "\",";
-	print "             (unsigned long)ptr->x_" var_target_other[i] ");";
+	if (max_mask_bits[var_target_other[i]] == 64)
+		print "             ptr->x_" var_target_other[i] ");";
+	else
+		print "             (unsigned long)ptr->x_" var_target_other[i] ");";
 	print "";
 }
 
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 876e0f6..0703678 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -300,18 +300,24 @@ for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
 	vname = var_name(flags[i])
 	mask = "MASK_"
+	mask_1 = "1"
 	if (vname != "") {
 		mask = "OPTION_MASK_"
+		if (max_mask_bits[vname] == 64)
+			mask_1 = "1LL"
 	}
 	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/gcc/opts-common.c b/gcc/opts-common.c
index 973dd7e..1c2138f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1098,11 +1098,26 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
     case CLVC_BIT_CLEAR:
     case CLVC_BIT_SET:
 	if ((value != 0) == (option->var_type == CLVC_BIT_SET))
-	  *(int *) flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var |= option->var_value;
+	    else 
+	      *(int *) flag_var |= option->var_value;
+	  }
 	else
-	  *(int *) flag_var &= ~option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var &= ~option->var_value;
+	    else 
+	      *(int *) flag_var &= ~option->var_value;
+	  }
 	if (set_flag_var)
-	  *(int *) set_flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) set_flag_var |= option->var_value;
+	    else
+	      *(int *) set_flag_var |= option->var_value;
+	  }
 	break;
 
     case CLVC_STRING:
diff --git a/gcc/opts.h b/gcc/opts.h
index b070c8f..3c0fe3f 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -96,6 +96,8 @@ struct cl_option
   BOOL_BITFIELD cl_missing_ok : 1;
   /* Argument is an integer >=0.  */
   BOOL_BITFIELD cl_uinteger : 1;
+  /* Argument is a HOST_WIDE_INT.  */
+  BOOL_BITFIELD cl_host_wide_int : 1;
   /* Argument should be converted to lowercase.  */
   BOOL_BITFIELD cl_tolower : 1;
   /* Report argument with -fverbose-asm  */
@@ -109,7 +111,7 @@ struct cl_option
   /* How this option's value is determined and sets a field.  */
   enum cl_var_type var_type;
   /* Value or bit-mask with which to set a field.  */
-  int var_value;
+  HOST_WIDE_INT var_value;
 };
 
 /* Records that the state of an option consists of SIZE bytes starting

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-08-04 18:08   ` H.J. Lu
@ 2011-08-04 22:09     ` H.J. Lu
  2011-08-04 22:46       ` Joseph S. Myers
  0 siblings, 1 reply; 12+ messages in thread
From: H.J. Lu @ 2011-08-04 22:09 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

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

On Thu, Aug 4, 2011 at 11:08 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jul 27, 2011 at 2:23 PM, Joseph S. Myers
> <joseph@codesourcery.com> wrote:
>> On Wed, 27 Jul 2011, H.J. Lu wrote:
>>
>>> ; Maximum number of mask bits in a variable.
>>> MaxMaskBits
>>> ix86_isa_flags = 64
>>>
>>> It mark ix86_isa_flags as 64bit.  Any comments?
>>
>> The patch won't work as is.  set_option, for example, casts a pointer to
>> (int *), and stores a mask that came from option->var_value, which is an
>> int, so this won't work with option fields not of type int or values that
>> don't fit in int; you'd need to check all uses of CLVC_BIT_CLEAR and
>> CLVC_BIT_SET in the source tree to adapt things for the possibility of
>> wider mask fields, and track the type of each such field.
>>
>
> Here is the updated patch.  Tested on Linux/ia32 and Linux/x86-64. I
> used (1LL < X) for HOST_WIDE_INT instead of ((HOST_WIDE_INT) 1 << x)
> since we have
>
> #define OPTION_MASK_ISA_64BIT (1LL << 2)
> ...
> #define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
> ...
>
> #if TARGET_64BIT_DEFAULT
> #define OPT_ARCH64 "!m32"
> #define OPT_ARCH32 "m32"
> #else
> #define OPT_ARCH64 "m64|mx32"
> #define OPT_ARCH32 "m64|mx32:;"
> #endif
>
> and C preprocessor doesn't support ((HOST_WIDE_INT) 1 << x).
>
> OK for trunk?
>

Here is the updated patch to get proper HOST_WIDE_INT bits and 1
through a new file, opt-gen.c.  OK for trunk?

Thanks.


-- 
H.J.
----
2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* Makefile.in (options.c): Depend on and use opt-gen$(exeext).
	(options-save.c): Likewise.
	(options.h): Likewise.
	(opt-gen$(exeext)): New target.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-gen.c: New.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Check
	max_mask_bits instead of 31 for target masks.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

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

2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* Makefile.in (options.c): Depend on and use opt-gen$(exeext).
	(options-save.c): Likewise.
	(options.h): Likewise.
	(opt-gen$(exeext)): New target.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-gen.c: New.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Check
	max_mask_bits instead of 31 for target masks.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 0204f93..fd14c35 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2245,22 +2245,22 @@ s-options: $(ALL_OPT_FILES) Makefile $(srcdir)/opt-gather.awk
 	$(STAMP) s-options
 
 options.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \
-    $(srcdir)/optc-gen.awk
+    $(srcdir)/optc-gen.awk opt-gen$(exeext)
 	$(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \
-	       -f $(srcdir)/optc-gen.awk \
+	       -f $(srcdir)/optc-gen.awk `./opt-gen$(exeext)` \
 	       -v header_name="config.h system.h coretypes.h tm.h" < $< > $@
 
 options-save.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \
-    $(srcdir)/optc-save-gen.awk
+    $(srcdir)/optc-save-gen.awk opt-gen$(exeext)
 	$(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \
-	       -f $(srcdir)/optc-save-gen.awk \
+	       -f $(srcdir)/optc-save-gen.awk `./opt-gen$(exeext)` \
 	       -v header_name="config.h system.h coretypes.h tm.h" < $< > $@
 
 options.h: s-options-h ; @true
 s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \
-    $(srcdir)/opth-gen.awk
+    $(srcdir)/opth-gen.awk opt-gen$(exeext)
 	$(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \
-	       -f $(srcdir)/opth-gen.awk \
+	       -f $(srcdir)/opth-gen.awk `./opt-gen$(exeext)` \
 	       < $< > tmp-options.h
 	$(SHELL) $(srcdir)/../move-if-change tmp-options.h options.h
 	$(STAMP) $@
@@ -4043,6 +4043,10 @@ gengtype-lex.c : gengtype-lex.l
 	  mv $@.tmp $@; \
 	}
 
+opt-gen$(exeext) : opt-gen.c $(BCONFIG_H) $(SYSTEM_H)
+	$(COMPILER_FOR_BUILD) $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
+		-o $@ $(srcdir)/opt-gen.c
+
 #\f
 # Remake internationalization support.
 intl.o: intl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h Makefile
diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index 1fc333c..c5a770f 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -34,14 +34,14 @@ along with GCC; see the file COPYING3.  If not see
 
 static bool ix86_pragma_target_parse (tree, tree);
 static void ix86_target_macros_internal
-  (int, enum processor_type, enum processor_type, enum fpmath_unit,
+  (HOST_WIDE_INT, enum processor_type, enum processor_type, enum fpmath_unit,
    void (*def_or_undef) (cpp_reader *, const char *));
 
 \f
 /* Internal function to either define or undef the appropriate system
    macros.  */
 static void
-ix86_target_macros_internal (int isa_flag,
+ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
 			     enum processor_type arch,
 			     enum processor_type tune,
 			     enum fpmath_unit fpmath,
@@ -301,9 +301,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
   tree cur_tree;
   struct cl_target_option *prev_opt;
   struct cl_target_option *cur_opt;
-  int prev_isa;
-  int cur_isa;
-  int diff_isa;
+  HOST_WIDE_INT prev_isa;
+  HOST_WIDE_INT cur_isa;
+  HOST_WIDE_INT diff_isa;
   enum processor_type prev_arch;
   enum processor_type prev_tune;
   enum processor_type cur_arch;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a7f8ee5..397a809 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2500,7 +2500,7 @@ static int ix86_function_regparm (const_tree, const_tree);
 static void ix86_compute_frame_layout (struct ix86_frame *);
 static bool ix86_expand_vector_init_one_nonzero (bool, enum machine_mode,
 						 rtx, rtx, int);
-static void ix86_add_new_builtins (int);
+static void ix86_add_new_builtins (HOST_WIDE_INT);
 static rtx ix86_expand_vec_perm_builtin (tree);
 static tree ix86_canonical_va_list_type (tree);
 static void predict_jump (int);
@@ -2514,8 +2514,8 @@ enum ix86_function_specific_strings
   IX86_FUNCTION_SPECIFIC_MAX
 };
 
-static char *ix86_target_string (int, int, const char *, const char *,
-				 enum fpmath_unit, bool);
+static char *ix86_target_string (HOST_WIDE_INT, int, const char *,
+				 const char *, enum fpmath_unit, bool);
 static void ix86_debug_options (void) ATTRIBUTE_UNUSED;
 static void ix86_function_specific_save (struct cl_target_option *);
 static void ix86_function_specific_restore (struct cl_target_option *);
@@ -2633,13 +2633,14 @@ ix86_using_red_zone (void)
    responsible for freeing the string.  */
 
 static char *
-ix86_target_string (int isa, int flags, const char *arch, const char *tune,
-		    enum fpmath_unit fpmath, bool add_nl_p)
+ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
+		    const char *tune, enum fpmath_unit fpmath,
+		    bool add_nl_p)
 {
   struct ix86_target_opts
   {
     const char *option;		/* option string */
-    int mask;			/* isa mask options */
+    HOST_WIDE_INT mask;		/* isa mask options */
   };
 
   /* This table is ordered so that options like -msse4.2 that imply
@@ -2747,7 +2748,8 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
   if (isa && add_nl_p)
     {
       opts[num++][0] = isa_other;
-      sprintf (isa_other, "(other isa: %#x)", isa);
+      sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)",
+	       isa);
     }
 
   /* Add flag options.  */
@@ -2888,47 +2890,44 @@ ix86_option_override_internal (bool main_args_p)
   const char *suffix;
   const char *sw;
 
-  enum pta_flags
-    {
-      PTA_SSE = 1 << 0,
-      PTA_SSE2 = 1 << 1,
-      PTA_SSE3 = 1 << 2,
-      PTA_MMX = 1 << 3,
-      PTA_PREFETCH_SSE = 1 << 4,
-      PTA_3DNOW = 1 << 5,
-      PTA_3DNOW_A = 1 << 6,
-      PTA_64BIT = 1 << 7,
-      PTA_SSSE3 = 1 << 8,
-      PTA_CX16 = 1 << 9,
-      PTA_POPCNT = 1 << 10,
-      PTA_ABM = 1 << 11,
-      PTA_SSE4A = 1 << 12,
-      PTA_NO_SAHF = 1 << 13,
-      PTA_SSE4_1 = 1 << 14,
-      PTA_SSE4_2 = 1 << 15,
-      PTA_AES = 1 << 16,
-      PTA_PCLMUL = 1 << 17,
-      PTA_AVX = 1 << 18,
-      PTA_FMA = 1 << 19,
-      PTA_MOVBE = 1 << 20,
-      PTA_FMA4 = 1 << 21,
-      PTA_XOP = 1 << 22,
-      PTA_LWP = 1 << 23,
-      PTA_FSGSBASE = 1 << 24,
-      PTA_RDRND = 1 << 25,
-      PTA_F16C = 1 << 26,
-      PTA_BMI = 1 << 27,
-      PTA_TBM = 1 << 28,
-      PTA_LZCNT = 1 << 29
-      /* if this reaches 32, need to widen struct pta flags below */
-    };
+#define PTA_3DNOW	 	(1LL << 0)
+#define PTA_3DNOW_A	 	(1LL << 1)
+#define PTA_64BIT		(1LL << 2)
+#define PTA_ABM			(1LL << 3)
+#define PTA_AES		 	(1LL << 4)
+#define PTA_AVX			(1LL << 5)
+#define PTA_BMI		 	(1LL << 6)
+#define PTA_CX16		(1LL << 7)
+#define PTA_F16C		(1LL << 8)
+#define PTA_FMA			(1LL << 9)
+#define PTA_FMA4	 	(1LL << 10)
+#define PTA_FSGSBASE		(1LL << 11)
+#define PTA_LWP		 	(1LL << 12)
+#define PTA_LZCNT	 	(1LL << 13)
+#define PTA_MMX			(1LL << 14)
+#define PTA_MOVBE		(1LL << 15)
+#define PTA_NO_SAHF		(1LL << 16)
+#define PTA_PCLMUL		(1LL << 17)
+#define PTA_POPCNT		(1LL << 18)
+#define PTA_PREFETCH_SSE	(1LL << 19)
+#define PTA_RDRND	 	(1LL << 20)
+#define PTA_SSE			(1LL << 21)
+#define PTA_SSE2		(1LL << 22)
+#define PTA_SSE3		(1LL << 23)
+#define PTA_SSE4_1	 	(1LL << 24)
+#define PTA_SSE4_2	 	(1LL << 25)
+#define PTA_SSE4A		(1LL << 26)
+#define PTA_SSSE3		(1LL << 27)
+#define PTA_TBM		 	(1LL << 28)
+#define PTA_XOP		 	(1LL << 29)
+/* if this reaches 64, need to widen struct pta flags below */
 
   static struct pta
     {
       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 flags;
     }
   const processor_alias_table[] =
     {
@@ -24047,7 +24046,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;
 };
@@ -24072,7 +24071,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;
@@ -24110,7 +24110,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);
@@ -24127,7 +24127,7 @@ def_builtin_const (int mask, const char *name,
    declarations to the tree, even if we didn't use them.  */
 
 static void
-ix86_add_new_builtins (int isa)
+ix86_add_new_builtins (HOST_WIDE_INT isa)
 {
   int i;
 
@@ -24161,7 +24161,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 f197dd8..654f4eb 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -24,12 +24,12 @@ config/i386/i386-opts.h
 
 ; 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 +50,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-functions.awk b/gcc/opt-functions.awk
index 945eeb1..5edfe63 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -110,6 +110,11 @@ function switch_flags (flags)
 # Return bit-field initializers for option flags FLAGS.
 function switch_bit_fields (flags)
 {
+	vn = var_name(flags);
+	if (max_mask_bits[vn] == HOST_BITS_PER_WIDE_INT)
+		host_wide_int = "Host_Wide_Int"
+	else
+		host_wide_int = ""
 	result = ""
 	sep_args = opt_args("Args", flags)
 	if (sep_args == "")
@@ -126,6 +131,7 @@ function switch_bit_fields (flags)
 	  flag_init("RejectNegative", flags) \
 	  flag_init("JoinedOrMissing", flags) \
 	  flag_init("UInteger", flags) \
+	  flag_init("Host_Wide_Int", host_wide_int) \
 	  flag_init("ToLower", flags) \
 	  flag_init("Report", flags)
 
@@ -140,6 +146,17 @@ function var_name(flags)
 	return nth_arg(0, opt_args("Var", flags))
 }
 
+# Return the name of the variable if FLAGS has a HOST_WIDE_INT variable. 
+# Return the empty string otherwise.
+function host_wide_int_var_name(flags)
+{
+	split (flags, array, "[ \t]+")
+	if (array[1] == "HOST_WIDE_INT")
+		return array[2]
+	else
+		return ""
+}
+
 # Return true if the option described by FLAGS has a globally-visible state.
 function global_state_p(flags)
 {
@@ -197,8 +214,12 @@ function var_type_struct(flags)
 		return enum_type[en] " "
 	}
 	else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
-		if (flag_set_p(".*Mask.*", flags))
-			return "int "
+		if (flag_set_p(".*Mask.*", flags)) {
+			if (max_mask_bits[var_name(flags)] == HOST_BITS_PER_WIDE_INT)
+				return "HOST_WIDE_INT "
+			else
+				return "int "
+		}
 		else
 			return "signed char "
 	}
diff --git a/gcc/opt-gen.c b/gcc/opt-gen.c
new file mode 100644
index 0000000..a7770d6
--- /dev/null
+++ b/gcc/opt-gen.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "bconfig.h"
+#include "system.h"
+
+int
+main (void)
+{
+  printf ("-v HOST_BITS_PER_WIDE_INT=%d\n", HOST_BITS_PER_WIDE_INT);
+  printf ("-v HOST_WIDE_INT_1=1%s\n", HOST_WIDE_INT_PRINT_C);
+  return 0;
+}
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index c488ed5..d3e6500 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -51,6 +51,9 @@ BEGIN {
 		else if ($1 == "Variable") {
 			extra_vars[n_extra_vars] = $2
 			n_extra_vars++
+			name = host_wide_int_var_name($2)
+			if (name != "")
+				max_mask_bits[name] = HOST_BITS_PER_WIDE_INT
 		}
 		else if ($1 == "TargetVariable") {
 			# Combination of TargetSave and Variable
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 4efc115..b2e8adb 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -363,10 +363,16 @@ print "{";
 print "  fputs (\"\\n\", file);";
 for (i = 0; i < n_target_other; i++) {
 	print "  if (ptr->x_" var_target_other[i] ")";
-	print "    fprintf (file, \"%*s%s (%#lx)\\n\",";
+	if (max_mask_bits[var_target_other[i]] == HOST_BITS_PER_WIDE_INT)
+		print "    fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
+	else
+		print "    fprintf (file, \"%*s%s (%#x)\\n\",";
 	print "             indent, \"\",";
 	print "             \"" var_target_other[i] "\",";
-	print "             (unsigned long)ptr->x_" var_target_other[i] ");";
+	if (max_mask_bits[var_target_other[i]] == HOST_BITS_PER_WIDE_INT)
+		print "             ptr->x_" var_target_other[i] ");";
+	else
+		print "             (unsigned long)ptr->x_" var_target_other[i] ");";
 	print "";
 }
 
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 876e0f6..f0f7e0e 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -300,18 +300,24 @@ for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
 	vname = var_name(flags[i])
 	mask = "MASK_"
+	mask_1 = "1"
 	if (vname != "") {
 		mask = "OPTION_MASK_"
+		if (max_mask_bits[vname] == HOST_BITS_PER_WIDE_INT)
+			mask_1 = HOST_WIDE_INT_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/gcc/opts-common.c b/gcc/opts-common.c
index 973dd7e..1c2138f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1098,11 +1098,26 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
     case CLVC_BIT_CLEAR:
     case CLVC_BIT_SET:
 	if ((value != 0) == (option->var_type == CLVC_BIT_SET))
-	  *(int *) flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var |= option->var_value;
+	    else 
+	      *(int *) flag_var |= option->var_value;
+	  }
 	else
-	  *(int *) flag_var &= ~option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var &= ~option->var_value;
+	    else 
+	      *(int *) flag_var &= ~option->var_value;
+	  }
 	if (set_flag_var)
-	  *(int *) set_flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) set_flag_var |= option->var_value;
+	    else
+	      *(int *) set_flag_var |= option->var_value;
+	  }
 	break;
 
     case CLVC_STRING:
diff --git a/gcc/opts.h b/gcc/opts.h
index b070c8f..3c0fe3f 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -96,6 +96,8 @@ struct cl_option
   BOOL_BITFIELD cl_missing_ok : 1;
   /* Argument is an integer >=0.  */
   BOOL_BITFIELD cl_uinteger : 1;
+  /* Argument is a HOST_WIDE_INT.  */
+  BOOL_BITFIELD cl_host_wide_int : 1;
   /* Argument should be converted to lowercase.  */
   BOOL_BITFIELD cl_tolower : 1;
   /* Report argument with -fverbose-asm  */
@@ -109,7 +111,7 @@ struct cl_option
   /* How this option's value is determined and sets a field.  */
   enum cl_var_type var_type;
   /* Value or bit-mask with which to set a field.  */
-  int var_value;
+  HOST_WIDE_INT var_value;
 };
 
 /* Records that the state of an option consists of SIZE bytes starting

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-08-04 22:09     ` H.J. Lu
@ 2011-08-04 22:46       ` Joseph S. Myers
  2011-08-04 23:44         ` H.J. Lu
  0 siblings, 1 reply; 12+ messages in thread
From: Joseph S. Myers @ 2011-08-04 22:46 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

On Thu, 4 Aug 2011, H.J. Lu wrote:

> Here is the updated patch to get proper HOST_WIDE_INT bits and 1
> through a new file, opt-gen.c.  OK for trunk?

Using another generator program like this can't be the best approach 
(apart from anything else, when built for the build system hwint.h should 
reflect the build system types not the host system types; cf. 
<http://gcc.gnu.org/ml/gcc/2010-08/msg00111.html> where I suspected that 
sort of host/build confusion of causing a reported build failure).

You want opth-gen.awk to know the number of bits to give errors.  Note 
that the errors are given by generating #error into the output file.  It's 
easy enough to generate #if conditions into the file that compare with 
HOST_BITS_PER_WIDE_INT.

You want opth-gen.awk to know whether to use 1LL as the shifted constant.  
You can easily enough make hwint.h contain a HOST_WIDE_INT_1 macro, 
defined to 1L or 1LL as appropriate.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-08-04 22:46       ` Joseph S. Myers
@ 2011-08-04 23:44         ` H.J. Lu
  2011-08-05  0:50           ` H.J. Lu
  0 siblings, 1 reply; 12+ messages in thread
From: H.J. Lu @ 2011-08-04 23:44 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

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

On Thu, Aug 4, 2011 at 3:46 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Thu, 4 Aug 2011, H.J. Lu wrote:
>
>> Here is the updated patch to get proper HOST_WIDE_INT bits and 1
>> through a new file, opt-gen.c.  OK for trunk?
>
> Using another generator program like this can't be the best approach
> (apart from anything else, when built for the build system hwint.h should
> reflect the build system types not the host system types; cf.
> <http://gcc.gnu.org/ml/gcc/2010-08/msg00111.html> where I suspected that
> sort of host/build confusion of causing a reported build failure).
>
> You want opth-gen.awk to know the number of bits to give errors.  Note
> that the errors are given by generating #error into the output file.  It's
> easy enough to generate #if conditions into the file that compare with
> HOST_BITS_PER_WIDE_INT.
>
> You want opth-gen.awk to know whether to use 1LL as the shifted constant.
> You can easily enough make hwint.h contain a HOST_WIDE_INT_1 macro,
> defined to 1L or 1LL as appropriate.
>


Here is the updated patch.  OK for trunk?

Thanks.


-- 
H.J.
----
2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* hwint.h (HOST_WIDE_INT_1): New.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Properly
	check masks for HOST_WIDE_INT.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

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

2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* hwint.h (HOST_WIDE_INT_1): New.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Properly
	check masks for HOST_WIDE_INT.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (1LL << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index 1fc333c..c5a770f 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -34,14 +34,14 @@ along with GCC; see the file COPYING3.  If not see
 
 static bool ix86_pragma_target_parse (tree, tree);
 static void ix86_target_macros_internal
-  (int, enum processor_type, enum processor_type, enum fpmath_unit,
+  (HOST_WIDE_INT, enum processor_type, enum processor_type, enum fpmath_unit,
    void (*def_or_undef) (cpp_reader *, const char *));
 
 \f
 /* Internal function to either define or undef the appropriate system
    macros.  */
 static void
-ix86_target_macros_internal (int isa_flag,
+ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
 			     enum processor_type arch,
 			     enum processor_type tune,
 			     enum fpmath_unit fpmath,
@@ -301,9 +301,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
   tree cur_tree;
   struct cl_target_option *prev_opt;
   struct cl_target_option *cur_opt;
-  int prev_isa;
-  int cur_isa;
-  int diff_isa;
+  HOST_WIDE_INT prev_isa;
+  HOST_WIDE_INT cur_isa;
+  HOST_WIDE_INT diff_isa;
   enum processor_type prev_arch;
   enum processor_type prev_tune;
   enum processor_type cur_arch;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a7f8ee5..397a809 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2500,7 +2500,7 @@ static int ix86_function_regparm (const_tree, const_tree);
 static void ix86_compute_frame_layout (struct ix86_frame *);
 static bool ix86_expand_vector_init_one_nonzero (bool, enum machine_mode,
 						 rtx, rtx, int);
-static void ix86_add_new_builtins (int);
+static void ix86_add_new_builtins (HOST_WIDE_INT);
 static rtx ix86_expand_vec_perm_builtin (tree);
 static tree ix86_canonical_va_list_type (tree);
 static void predict_jump (int);
@@ -2514,8 +2514,8 @@ enum ix86_function_specific_strings
   IX86_FUNCTION_SPECIFIC_MAX
 };
 
-static char *ix86_target_string (int, int, const char *, const char *,
-				 enum fpmath_unit, bool);
+static char *ix86_target_string (HOST_WIDE_INT, int, const char *,
+				 const char *, enum fpmath_unit, bool);
 static void ix86_debug_options (void) ATTRIBUTE_UNUSED;
 static void ix86_function_specific_save (struct cl_target_option *);
 static void ix86_function_specific_restore (struct cl_target_option *);
@@ -2633,13 +2633,14 @@ ix86_using_red_zone (void)
    responsible for freeing the string.  */
 
 static char *
-ix86_target_string (int isa, int flags, const char *arch, const char *tune,
-		    enum fpmath_unit fpmath, bool add_nl_p)
+ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
+		    const char *tune, enum fpmath_unit fpmath,
+		    bool add_nl_p)
 {
   struct ix86_target_opts
   {
     const char *option;		/* option string */
-    int mask;			/* isa mask options */
+    HOST_WIDE_INT mask;		/* isa mask options */
   };
 
   /* This table is ordered so that options like -msse4.2 that imply
@@ -2747,7 +2748,8 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
   if (isa && add_nl_p)
     {
       opts[num++][0] = isa_other;
-      sprintf (isa_other, "(other isa: %#x)", isa);
+      sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)",
+	       isa);
     }
 
   /* Add flag options.  */
@@ -2888,47 +2890,44 @@ ix86_option_override_internal (bool main_args_p)
   const char *suffix;
   const char *sw;
 
-  enum pta_flags
-    {
-      PTA_SSE = 1 << 0,
-      PTA_SSE2 = 1 << 1,
-      PTA_SSE3 = 1 << 2,
-      PTA_MMX = 1 << 3,
-      PTA_PREFETCH_SSE = 1 << 4,
-      PTA_3DNOW = 1 << 5,
-      PTA_3DNOW_A = 1 << 6,
-      PTA_64BIT = 1 << 7,
-      PTA_SSSE3 = 1 << 8,
-      PTA_CX16 = 1 << 9,
-      PTA_POPCNT = 1 << 10,
-      PTA_ABM = 1 << 11,
-      PTA_SSE4A = 1 << 12,
-      PTA_NO_SAHF = 1 << 13,
-      PTA_SSE4_1 = 1 << 14,
-      PTA_SSE4_2 = 1 << 15,
-      PTA_AES = 1 << 16,
-      PTA_PCLMUL = 1 << 17,
-      PTA_AVX = 1 << 18,
-      PTA_FMA = 1 << 19,
-      PTA_MOVBE = 1 << 20,
-      PTA_FMA4 = 1 << 21,
-      PTA_XOP = 1 << 22,
-      PTA_LWP = 1 << 23,
-      PTA_FSGSBASE = 1 << 24,
-      PTA_RDRND = 1 << 25,
-      PTA_F16C = 1 << 26,
-      PTA_BMI = 1 << 27,
-      PTA_TBM = 1 << 28,
-      PTA_LZCNT = 1 << 29
-      /* if this reaches 32, need to widen struct pta flags below */
-    };
+#define PTA_3DNOW	 	(1LL << 0)
+#define PTA_3DNOW_A	 	(1LL << 1)
+#define PTA_64BIT		(1LL << 2)
+#define PTA_ABM			(1LL << 3)
+#define PTA_AES		 	(1LL << 4)
+#define PTA_AVX			(1LL << 5)
+#define PTA_BMI		 	(1LL << 6)
+#define PTA_CX16		(1LL << 7)
+#define PTA_F16C		(1LL << 8)
+#define PTA_FMA			(1LL << 9)
+#define PTA_FMA4	 	(1LL << 10)
+#define PTA_FSGSBASE		(1LL << 11)
+#define PTA_LWP		 	(1LL << 12)
+#define PTA_LZCNT	 	(1LL << 13)
+#define PTA_MMX			(1LL << 14)
+#define PTA_MOVBE		(1LL << 15)
+#define PTA_NO_SAHF		(1LL << 16)
+#define PTA_PCLMUL		(1LL << 17)
+#define PTA_POPCNT		(1LL << 18)
+#define PTA_PREFETCH_SSE	(1LL << 19)
+#define PTA_RDRND	 	(1LL << 20)
+#define PTA_SSE			(1LL << 21)
+#define PTA_SSE2		(1LL << 22)
+#define PTA_SSE3		(1LL << 23)
+#define PTA_SSE4_1	 	(1LL << 24)
+#define PTA_SSE4_2	 	(1LL << 25)
+#define PTA_SSE4A		(1LL << 26)
+#define PTA_SSSE3		(1LL << 27)
+#define PTA_TBM		 	(1LL << 28)
+#define PTA_XOP		 	(1LL << 29)
+/* if this reaches 64, need to widen struct pta flags below */
 
   static struct pta
     {
       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 flags;
     }
   const processor_alias_table[] =
     {
@@ -24047,7 +24046,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;
 };
@@ -24072,7 +24071,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;
@@ -24110,7 +24110,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);
@@ -24127,7 +24127,7 @@ def_builtin_const (int mask, const char *name,
    declarations to the tree, even if we didn't use them.  */
 
 static void
-ix86_add_new_builtins (int isa)
+ix86_add_new_builtins (HOST_WIDE_INT isa)
 {
   int i;
 
@@ -24161,7 +24161,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 f197dd8..654f4eb 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -24,12 +24,12 @@ config/i386/i386-opts.h
 
 ; 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 +50,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/hwint.h b/gcc/hwint.h
index fa77b11..6135136 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -79,6 +79,7 @@ extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
 # define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
 # define HOST_WIDE_INT_PRINT_C "L"
+# define HOST_WIDE_INT_1 1L
   /* 'long' might be 32 or 64 bits, and the number of leading zeroes
      must be tweaked accordingly.  */
 # if HOST_BITS_PER_WIDE_INT == 64
@@ -91,6 +92,7 @@ extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
 #else
 # define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
 # define HOST_WIDE_INT_PRINT_C "LL"
+# define HOST_WIDE_INT_1 1LL
   /* We can assume that 'long long' is at least 64 bits.  */
 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
     "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 945eeb1..1f582fb 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -110,6 +110,11 @@ function switch_flags (flags)
 # Return bit-field initializers for option flags FLAGS.
 function switch_bit_fields (flags)
 {
+	vn = var_name(flags);
+	if (host_wide_int[vn] == "yes")
+		hwi = "Host_Wide_Int"
+	else
+		hwi = ""
 	result = ""
 	sep_args = opt_args("Args", flags)
 	if (sep_args == "")
@@ -126,6 +131,7 @@ function switch_bit_fields (flags)
 	  flag_init("RejectNegative", flags) \
 	  flag_init("JoinedOrMissing", flags) \
 	  flag_init("UInteger", flags) \
+	  flag_init("Host_Wide_Int", hwi) \
 	  flag_init("ToLower", flags) \
 	  flag_init("Report", flags)
 
@@ -140,6 +146,17 @@ function var_name(flags)
 	return nth_arg(0, opt_args("Var", flags))
 }
 
+# Return the name of the variable if FLAGS has a HOST_WIDE_INT variable. 
+# Return the empty string otherwise.
+function host_wide_int_var_name(flags)
+{
+	split (flags, array, "[ \t]+")
+	if (array[1] == "HOST_WIDE_INT")
+		return array[2]
+	else
+		return ""
+}
+
 # Return true if the option described by FLAGS has a globally-visible state.
 function global_state_p(flags)
 {
@@ -197,8 +214,12 @@ function var_type_struct(flags)
 		return enum_type[en] " "
 	}
 	else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
-		if (flag_set_p(".*Mask.*", flags))
-			return "int "
+		if (flag_set_p(".*Mask.*", flags)) {
+			if (host_wide_int[var_name(flags)] == "yes")
+				return "HOST_WIDE_INT "
+			else
+				return "int "
+		}
 		else
 			return "signed char "
 	}
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index c488ed5..6a4d4de 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -51,6 +51,9 @@ BEGIN {
 		else if ($1 == "Variable") {
 			extra_vars[n_extra_vars] = $2
 			n_extra_vars++
+			name = host_wide_int_var_name($2)
+			if (name != "")
+				host_wide_int[name] = "yes"
 		}
 		else if ($1 == "TargetVariable") {
 			# Combination of TargetSave and Variable
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 4efc115..654d869 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -363,10 +363,16 @@ print "{";
 print "  fputs (\"\\n\", file);";
 for (i = 0; i < n_target_other; i++) {
 	print "  if (ptr->x_" var_target_other[i] ")";
-	print "    fprintf (file, \"%*s%s (%#lx)\\n\",";
+	if (host_wide_int[var_target_other[i]] == "yes")
+		print "    fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
+	else
+		print "    fprintf (file, \"%*s%s (%#x)\\n\",";
 	print "             indent, \"\",";
 	print "             \"" var_target_other[i] "\",";
-	print "             (unsigned long)ptr->x_" var_target_other[i] ");";
+	if (host_wide_int[var_target_other[i]] == "yes")
+		print "             ptr->x_" var_target_other[i] ");";
+	else
+		print "             (unsigned long)ptr->x_" var_target_other[i] ");";
 	print "";
 }
 
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 876e0f6..41e3d84 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -300,18 +300,26 @@ for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
 	vname = var_name(flags[i])
 	mask = "MASK_"
+	mask_1 = "1"
 	if (vname != "") {
 		mask = "OPTION_MASK_"
+		if (host_wide_int[vname] == "yes")
+			mask_1 = "HOST_WIDE_INT_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) {
+	if (var != "" && host_wide_int[var] == "yes") {
+		print "#if " masknum[var] " >= HOST_BITS_PER_WIDE_INT"
+		print "#error too many masks for " var
+		print "#endif"
+	}
+	else if (masknum[var] > 31) {
 		if (var == "")
 			print "#error too many target masks"
 		else
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 973dd7e..1c2138f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1098,11 +1098,26 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
     case CLVC_BIT_CLEAR:
     case CLVC_BIT_SET:
 	if ((value != 0) == (option->var_type == CLVC_BIT_SET))
-	  *(int *) flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var |= option->var_value;
+	    else 
+	      *(int *) flag_var |= option->var_value;
+	  }
 	else
-	  *(int *) flag_var &= ~option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var &= ~option->var_value;
+	    else 
+	      *(int *) flag_var &= ~option->var_value;
+	  }
 	if (set_flag_var)
-	  *(int *) set_flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) set_flag_var |= option->var_value;
+	    else
+	      *(int *) set_flag_var |= option->var_value;
+	  }
 	break;
 
     case CLVC_STRING:
diff --git a/gcc/opts.h b/gcc/opts.h
index b070c8f..3c0fe3f 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -96,6 +96,8 @@ struct cl_option
   BOOL_BITFIELD cl_missing_ok : 1;
   /* Argument is an integer >=0.  */
   BOOL_BITFIELD cl_uinteger : 1;
+  /* Argument is a HOST_WIDE_INT.  */
+  BOOL_BITFIELD cl_host_wide_int : 1;
   /* Argument should be converted to lowercase.  */
   BOOL_BITFIELD cl_tolower : 1;
   /* Report argument with -fverbose-asm  */
@@ -109,7 +111,7 @@ struct cl_option
   /* How this option's value is determined and sets a field.  */
   enum cl_var_type var_type;
   /* Value or bit-mask with which to set a field.  */
-  int var_value;
+  HOST_WIDE_INT var_value;
 };
 
 /* Records that the state of an option consists of SIZE bytes starting

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

* Re: RFC: PATCH: Require and use int64 for x86 options
  2011-08-04 23:44         ` H.J. Lu
@ 2011-08-05  0:50           ` H.J. Lu
  0 siblings, 0 replies; 12+ messages in thread
From: H.J. Lu @ 2011-08-05  0:50 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Ian Lance Taylor, Uros Bizjak, Igor Zamyatin, gcc

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

On Thu, Aug 4, 2011 at 4:44 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Aug 4, 2011 at 3:46 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
>> On Thu, 4 Aug 2011, H.J. Lu wrote:
>>
>>> Here is the updated patch to get proper HOST_WIDE_INT bits and 1
>>> through a new file, opt-gen.c.  OK for trunk?
>>
>> Using another generator program like this can't be the best approach
>> (apart from anything else, when built for the build system hwint.h should
>> reflect the build system types not the host system types; cf.
>> <http://gcc.gnu.org/ml/gcc/2010-08/msg00111.html> where I suspected that
>> sort of host/build confusion of causing a reported build failure).
>>
>> You want opth-gen.awk to know the number of bits to give errors.  Note
>> that the errors are given by generating #error into the output file.  It's
>> easy enough to generate #if conditions into the file that compare with
>> HOST_BITS_PER_WIDE_INT.
>>
>> You want opth-gen.awk to know whether to use 1LL as the shifted constant.
>> You can easily enough make hwint.h contain a HOST_WIDE_INT_1 macro,
>> defined to 1L or 1LL as appropriate.
>>
>
>
> Here is the updated patch.  OK for trunk?
>

Small update.  Replace 1LL with HOST_WIDE_INT_1 in  PTA_XXX.
OK for trunk?

Thanks.

-- 
H.J.
---
2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* hwint.h (HOST_WIDE_INT_1): New.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Properly
	check masks for HOST_WIDE_INT.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (HOST_WIDE_INT_1 << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

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

2011-08-04  H.J. Lu  <hongjiu.lu@intel.com>
	    Igor Zamyatin <igor.zamyatin@intel.com>

	* hwint.h (HOST_WIDE_INT_1): New.

	* opt-functions.awk (switch_bit_fields): Initialize the
	host_wide_int field.
	(host_wide_int_var_name): New.
	(var_type_struct): Check and return HOST_WIDE_INT.

	* opt-read.awk: Handle HOST_WIDE_INT for "Variable".

	* optc-save-gen.awk: Support HOST_WIDE_INT on var_target_other.

	* opth-gen.awk: Use HOST_WIDE_INT_1 on HOST_WIDE_INT.  Properly
	check masks for HOST_WIDE_INT.

	* opts-common.c (set_option): Support HOST_WIDE_INT Flag_var.

	* opts.h (cl_option): Add cl_host_wide_int.  Change var_value
	to HOST_WIDE_INT.

	* config/i386/i386-c.c (ix86_target_macros_internal): Replace int
	with HOST_WIDE_INT for isa_flag.
	(ix86_pragma_target_parse): Replace int with HOST_WIDE_INT for
	isa variables.

	* config/i386/i386.c (ix86_target_string): Replace int with
	HOST_WIDE_INT for isa.  Use HOST_WIDE_INT_PRINT to print isa.
	(ix86_target_opts): Replace int with HOST_WIDE_INT on mask.
	(pta_flags): Removed.
	(PTA_XXX): Redefined as (HOST_WIDE_INT_1 << X).
	(pta): Use HOST_WIDE_INT on flags.
	(builtin_isa): Use HOST_WIDE_INT on isa.
	(ix86_add_new_builtins): Likewise.
	(def_builtin): Use HOST_WIDE_INT on mask.
	(def_builtin_const): Likewise.
	(builtin_description): Likewise.

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

diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index 1fc333c..c5a770f 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -34,14 +34,14 @@ along with GCC; see the file COPYING3.  If not see
 
 static bool ix86_pragma_target_parse (tree, tree);
 static void ix86_target_macros_internal
-  (int, enum processor_type, enum processor_type, enum fpmath_unit,
+  (HOST_WIDE_INT, enum processor_type, enum processor_type, enum fpmath_unit,
    void (*def_or_undef) (cpp_reader *, const char *));
 
 \f
 /* Internal function to either define or undef the appropriate system
    macros.  */
 static void
-ix86_target_macros_internal (int isa_flag,
+ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
 			     enum processor_type arch,
 			     enum processor_type tune,
 			     enum fpmath_unit fpmath,
@@ -301,9 +301,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
   tree cur_tree;
   struct cl_target_option *prev_opt;
   struct cl_target_option *cur_opt;
-  int prev_isa;
-  int cur_isa;
-  int diff_isa;
+  HOST_WIDE_INT prev_isa;
+  HOST_WIDE_INT cur_isa;
+  HOST_WIDE_INT diff_isa;
   enum processor_type prev_arch;
   enum processor_type prev_tune;
   enum processor_type cur_arch;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a7f8ee5..2e5c2fb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2500,7 +2500,7 @@ static int ix86_function_regparm (const_tree, const_tree);
 static void ix86_compute_frame_layout (struct ix86_frame *);
 static bool ix86_expand_vector_init_one_nonzero (bool, enum machine_mode,
 						 rtx, rtx, int);
-static void ix86_add_new_builtins (int);
+static void ix86_add_new_builtins (HOST_WIDE_INT);
 static rtx ix86_expand_vec_perm_builtin (tree);
 static tree ix86_canonical_va_list_type (tree);
 static void predict_jump (int);
@@ -2514,8 +2514,8 @@ enum ix86_function_specific_strings
   IX86_FUNCTION_SPECIFIC_MAX
 };
 
-static char *ix86_target_string (int, int, const char *, const char *,
-				 enum fpmath_unit, bool);
+static char *ix86_target_string (HOST_WIDE_INT, int, const char *,
+				 const char *, enum fpmath_unit, bool);
 static void ix86_debug_options (void) ATTRIBUTE_UNUSED;
 static void ix86_function_specific_save (struct cl_target_option *);
 static void ix86_function_specific_restore (struct cl_target_option *);
@@ -2633,13 +2633,14 @@ ix86_using_red_zone (void)
    responsible for freeing the string.  */
 
 static char *
-ix86_target_string (int isa, int flags, const char *arch, const char *tune,
-		    enum fpmath_unit fpmath, bool add_nl_p)
+ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
+		    const char *tune, enum fpmath_unit fpmath,
+		    bool add_nl_p)
 {
   struct ix86_target_opts
   {
     const char *option;		/* option string */
-    int mask;			/* isa mask options */
+    HOST_WIDE_INT mask;		/* isa mask options */
   };
 
   /* This table is ordered so that options like -msse4.2 that imply
@@ -2747,7 +2748,8 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
   if (isa && add_nl_p)
     {
       opts[num++][0] = isa_other;
-      sprintf (isa_other, "(other isa: %#x)", isa);
+      sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)",
+	       isa);
     }
 
   /* Add flag options.  */
@@ -2888,47 +2890,44 @@ ix86_option_override_internal (bool main_args_p)
   const char *suffix;
   const char *sw;
 
-  enum pta_flags
-    {
-      PTA_SSE = 1 << 0,
-      PTA_SSE2 = 1 << 1,
-      PTA_SSE3 = 1 << 2,
-      PTA_MMX = 1 << 3,
-      PTA_PREFETCH_SSE = 1 << 4,
-      PTA_3DNOW = 1 << 5,
-      PTA_3DNOW_A = 1 << 6,
-      PTA_64BIT = 1 << 7,
-      PTA_SSSE3 = 1 << 8,
-      PTA_CX16 = 1 << 9,
-      PTA_POPCNT = 1 << 10,
-      PTA_ABM = 1 << 11,
-      PTA_SSE4A = 1 << 12,
-      PTA_NO_SAHF = 1 << 13,
-      PTA_SSE4_1 = 1 << 14,
-      PTA_SSE4_2 = 1 << 15,
-      PTA_AES = 1 << 16,
-      PTA_PCLMUL = 1 << 17,
-      PTA_AVX = 1 << 18,
-      PTA_FMA = 1 << 19,
-      PTA_MOVBE = 1 << 20,
-      PTA_FMA4 = 1 << 21,
-      PTA_XOP = 1 << 22,
-      PTA_LWP = 1 << 23,
-      PTA_FSGSBASE = 1 << 24,
-      PTA_RDRND = 1 << 25,
-      PTA_F16C = 1 << 26,
-      PTA_BMI = 1 << 27,
-      PTA_TBM = 1 << 28,
-      PTA_LZCNT = 1 << 29
-      /* if this reaches 32, need to widen struct pta flags below */
-    };
+#define PTA_3DNOW	 	(HOST_WIDE_INT_1 << 0)
+#define PTA_3DNOW_A	 	(HOST_WIDE_INT_1 << 1)
+#define PTA_64BIT		(HOST_WIDE_INT_1 << 2)
+#define PTA_ABM			(HOST_WIDE_INT_1 << 3)
+#define PTA_AES		 	(HOST_WIDE_INT_1 << 4)
+#define PTA_AVX			(HOST_WIDE_INT_1 << 5)
+#define PTA_BMI		 	(HOST_WIDE_INT_1 << 6)
+#define PTA_CX16		(HOST_WIDE_INT_1 << 7)
+#define PTA_F16C		(HOST_WIDE_INT_1 << 8)
+#define PTA_FMA			(HOST_WIDE_INT_1 << 9)
+#define PTA_FMA4	 	(HOST_WIDE_INT_1 << 10)
+#define PTA_FSGSBASE		(HOST_WIDE_INT_1 << 11)
+#define PTA_LWP		 	(HOST_WIDE_INT_1 << 12)
+#define PTA_LZCNT	 	(HOST_WIDE_INT_1 << 13)
+#define PTA_MMX			(HOST_WIDE_INT_1 << 14)
+#define PTA_MOVBE		(HOST_WIDE_INT_1 << 15)
+#define PTA_NO_SAHF		(HOST_WIDE_INT_1 << 16)
+#define PTA_PCLMUL		(HOST_WIDE_INT_1 << 17)
+#define PTA_POPCNT		(HOST_WIDE_INT_1 << 18)
+#define PTA_PREFETCH_SSE	(HOST_WIDE_INT_1 << 19)
+#define PTA_RDRND	 	(HOST_WIDE_INT_1 << 20)
+#define PTA_SSE			(HOST_WIDE_INT_1 << 21)
+#define PTA_SSE2		(HOST_WIDE_INT_1 << 22)
+#define PTA_SSE3		(HOST_WIDE_INT_1 << 23)
+#define PTA_SSE4_1	 	(HOST_WIDE_INT_1 << 24)
+#define PTA_SSE4_2	 	(HOST_WIDE_INT_1 << 25)
+#define PTA_SSE4A		(HOST_WIDE_INT_1 << 26)
+#define PTA_SSSE3		(HOST_WIDE_INT_1 << 27)
+#define PTA_TBM		 	(HOST_WIDE_INT_1 << 28)
+#define PTA_XOP		 	(HOST_WIDE_INT_1 << 29)
+/* if this reaches 64, need to widen struct pta flags below */
 
   static struct pta
     {
       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 flags;
     }
   const processor_alias_table[] =
     {
@@ -24047,7 +24046,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;
 };
@@ -24072,7 +24071,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;
@@ -24110,7 +24110,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);
@@ -24127,7 +24127,7 @@ def_builtin_const (int mask, const char *name,
    declarations to the tree, even if we didn't use them.  */
 
 static void
-ix86_add_new_builtins (int isa)
+ix86_add_new_builtins (HOST_WIDE_INT isa)
 {
   int i;
 
@@ -24161,7 +24161,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 f197dd8..654f4eb 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -24,12 +24,12 @@ config/i386/i386-opts.h
 
 ; 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 +50,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/hwint.h b/gcc/hwint.h
index fa77b11..6135136 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -79,6 +79,7 @@ extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
 # define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
 # define HOST_WIDE_INT_PRINT_C "L"
+# define HOST_WIDE_INT_1 1L
   /* 'long' might be 32 or 64 bits, and the number of leading zeroes
      must be tweaked accordingly.  */
 # if HOST_BITS_PER_WIDE_INT == 64
@@ -91,6 +92,7 @@ extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
 #else
 # define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
 # define HOST_WIDE_INT_PRINT_C "LL"
+# define HOST_WIDE_INT_1 1LL
   /* We can assume that 'long long' is at least 64 bits.  */
 # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \
     "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x"
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 945eeb1..1f582fb 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -110,6 +110,11 @@ function switch_flags (flags)
 # Return bit-field initializers for option flags FLAGS.
 function switch_bit_fields (flags)
 {
+	vn = var_name(flags);
+	if (host_wide_int[vn] == "yes")
+		hwi = "Host_Wide_Int"
+	else
+		hwi = ""
 	result = ""
 	sep_args = opt_args("Args", flags)
 	if (sep_args == "")
@@ -126,6 +131,7 @@ function switch_bit_fields (flags)
 	  flag_init("RejectNegative", flags) \
 	  flag_init("JoinedOrMissing", flags) \
 	  flag_init("UInteger", flags) \
+	  flag_init("Host_Wide_Int", hwi) \
 	  flag_init("ToLower", flags) \
 	  flag_init("Report", flags)
 
@@ -140,6 +146,17 @@ function var_name(flags)
 	return nth_arg(0, opt_args("Var", flags))
 }
 
+# Return the name of the variable if FLAGS has a HOST_WIDE_INT variable. 
+# Return the empty string otherwise.
+function host_wide_int_var_name(flags)
+{
+	split (flags, array, "[ \t]+")
+	if (array[1] == "HOST_WIDE_INT")
+		return array[2]
+	else
+		return ""
+}
+
 # Return true if the option described by FLAGS has a globally-visible state.
 function global_state_p(flags)
 {
@@ -197,8 +214,12 @@ function var_type_struct(flags)
 		return enum_type[en] " "
 	}
 	else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
-		if (flag_set_p(".*Mask.*", flags))
-			return "int "
+		if (flag_set_p(".*Mask.*", flags)) {
+			if (host_wide_int[var_name(flags)] == "yes")
+				return "HOST_WIDE_INT "
+			else
+				return "int "
+		}
 		else
 			return "signed char "
 	}
diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk
index c488ed5..6a4d4de 100644
--- a/gcc/opt-read.awk
+++ b/gcc/opt-read.awk
@@ -51,6 +51,9 @@ BEGIN {
 		else if ($1 == "Variable") {
 			extra_vars[n_extra_vars] = $2
 			n_extra_vars++
+			name = host_wide_int_var_name($2)
+			if (name != "")
+				host_wide_int[name] = "yes"
 		}
 		else if ($1 == "TargetVariable") {
 			# Combination of TargetSave and Variable
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 4efc115..654d869 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -363,10 +363,16 @@ print "{";
 print "  fputs (\"\\n\", file);";
 for (i = 0; i < n_target_other; i++) {
 	print "  if (ptr->x_" var_target_other[i] ")";
-	print "    fprintf (file, \"%*s%s (%#lx)\\n\",";
+	if (host_wide_int[var_target_other[i]] == "yes")
+		print "    fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
+	else
+		print "    fprintf (file, \"%*s%s (%#x)\\n\",";
 	print "             indent, \"\",";
 	print "             \"" var_target_other[i] "\",";
-	print "             (unsigned long)ptr->x_" var_target_other[i] ");";
+	if (host_wide_int[var_target_other[i]] == "yes")
+		print "             ptr->x_" var_target_other[i] ");";
+	else
+		print "             (unsigned long)ptr->x_" var_target_other[i] ");";
 	print "";
 }
 
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 876e0f6..41e3d84 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -300,18 +300,26 @@ for (i = 0; i < n_opts; i++) {
 	name = opt_args("Mask", flags[i])
 	vname = var_name(flags[i])
 	mask = "MASK_"
+	mask_1 = "1"
 	if (vname != "") {
 		mask = "OPTION_MASK_"
+		if (host_wide_int[vname] == "yes")
+			mask_1 = "HOST_WIDE_INT_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) {
+	if (var != "" && host_wide_int[var] == "yes") {
+		print "#if " masknum[var] " >= HOST_BITS_PER_WIDE_INT"
+		print "#error too many masks for " var
+		print "#endif"
+	}
+	else if (masknum[var] > 31) {
 		if (var == "")
 			print "#error too many target masks"
 		else
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 973dd7e..1c2138f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1098,11 +1098,26 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
     case CLVC_BIT_CLEAR:
     case CLVC_BIT_SET:
 	if ((value != 0) == (option->var_type == CLVC_BIT_SET))
-	  *(int *) flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var |= option->var_value;
+	    else 
+	      *(int *) flag_var |= option->var_value;
+	  }
 	else
-	  *(int *) flag_var &= ~option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) flag_var &= ~option->var_value;
+	    else 
+	      *(int *) flag_var &= ~option->var_value;
+	  }
 	if (set_flag_var)
-	  *(int *) set_flag_var |= option->var_value;
+	  {
+	    if (option->cl_host_wide_int) 
+	      *(HOST_WIDE_INT *) set_flag_var |= option->var_value;
+	    else
+	      *(int *) set_flag_var |= option->var_value;
+	  }
 	break;
 
     case CLVC_STRING:
diff --git a/gcc/opts.h b/gcc/opts.h
index b070c8f..3c0fe3f 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -96,6 +96,8 @@ struct cl_option
   BOOL_BITFIELD cl_missing_ok : 1;
   /* Argument is an integer >=0.  */
   BOOL_BITFIELD cl_uinteger : 1;
+  /* Argument is a HOST_WIDE_INT.  */
+  BOOL_BITFIELD cl_host_wide_int : 1;
   /* Argument should be converted to lowercase.  */
   BOOL_BITFIELD cl_tolower : 1;
   /* Report argument with -fverbose-asm  */
@@ -109,7 +111,7 @@ struct cl_option
   /* How this option's value is determined and sets a field.  */
   enum cl_var_type var_type;
   /* Value or bit-mask with which to set a field.  */
-  int var_value;
+  HOST_WIDE_INT var_value;
 };
 
 /* Records that the state of an option consists of SIZE bytes starting

^ 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).