Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-11-05 Thread Bernd Schmidt
On 10/31/2012 01:12 PM, Richard Sandiford wrote:

 OK with those changes for the rtl bits.  Can't approve the generator
 stuff though.

That's also OK.


Bernd


Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-11-04 Thread Joern Rennecke

Quoting Richard Sandiford rdsandif...@googlemail.com:


OK with those changes for the rtl bits.  Can't approve the generator
stuff though.


It appears we are momentarily short of reviewers for the generator files.

Till someone who feels he is competent to review the generator file patches
finds the time to review them, can we just patch the bits in final.c
(plus supporting hooks) that get in the way when revamping branch shortening?

This is a subset of the previous patch, with the requested change to use
gcc_assert in final.c, and a #ifdef / #else / #endif block at the top of
final.c to provide the things that we currently don't get from the generated
files.

Tested with building 'all-gcc' for i686-pc-linux-gnu X mmix-knuth-mmixware and
bootstrap on i686-pc-linux-gnu.  I'm also currently running a config-list.mk
test on gcc20.


2012-10-30  Joern Rennecke  joern.renne...@embecosm.com

* final.c [HAVE_ATTR_length] (HAVE_ATTR_length): Redefine as 1.
[!HAVE_ATTR_length]: Include hooks.h and insn-addr.h.
Define stubs for insn_*length* functions.
[!HAVE_ATTR_length] (length_unit_log): Provide definition.
[!HAVE_ATTR_length] (HAVE_ATTR_length): Define as 0.
(asm_insn_count, align_fuzz): Always define.
(insn_current_reference_address): Likewise.
(init_insn_lengths): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(get_attr_length_1, shorten_branches, final): Likewise.
(final_scan_insn, output_asm_name): Likewise.
* hooks.c (hook_int_rtx_unreachable): New function.
* hooks.h (hook_int_rtx_unreachable): Declare.

Index: final.c
===
--- final.c (revision 193137)
+++ final.c (working copy)
@@ -198,15 +198,28 @@ Software Foundation; either version 3, o
 static int dialect_number;
 #endif
 
+/* Till we can get generator file patches reviewed, do our own stuff here.  */
+#ifdef HAVE_ATTR_length
+#undef HAVE_ATTR_length
+#define HAVE_ATTR_length 1
+#else /* !HAVE_ATTR_length */
+#include hooks.h
+#include insn-addr.h
+#define HAVE_ATTR_length 0
+const int length_unit_log = 0;
+#define insn_default_length hook_int_rtx_unreachable
+#define insn_min_length hook_int_rtx_unreachable
+#define insn_variable_length_p hook_int_rtx_unreachable
+#define insn_current_length hook_int_rtx_unreachable
+#endif /* !HAVE_ATTR_length */
+
 /* Nonnull if the insn currently being emitted was a COND_EXEC pattern.  */
 rtx current_insn_predicate;
 
 /* True if printing into -fdump-final-insns= dump.  */   
 bool final_insns_dump_p;
 
-#ifdef HAVE_ATTR_length
 static int asm_insn_count (rtx);
-#endif
 static void profile_function (FILE *);
 static void profile_after_prologue (FILE *);
 static bool notice_source_line (rtx, bool *);
@@ -224,9 +237,7 @@ static int alter_cond (rtx);
 #ifndef ADDR_VEC_ALIGN
 static int final_addr_vec_align (rtx);
 #endif
-#ifdef HAVE_ATTR_length
 static int align_fuzz (rtx, rtx, int, unsigned);
-#endif
 
 /* Initialize data in final at the beginning of a compilation.  */
 
@@ -362,9 +373,8 @@ init_insn_lengths (void)
   insn_lengths = 0;
   insn_lengths_max_uid = 0;
 }
-#ifdef HAVE_ATTR_length
-  INSN_ADDRESSES_FREE ();
-#endif
+  if (HAVE_ATTR_length)
+INSN_ADDRESSES_FREE ();
   if (uid_align)
 {
   free (uid_align);
@@ -376,14 +386,15 @@ init_insn_lengths (void)
get its actual length.  Otherwise, use FALLBACK_FN to calculate the
length.  */
 static inline int
-get_attr_length_1 (rtx insn ATTRIBUTE_UNUSED,
-  int (*fallback_fn) (rtx) ATTRIBUTE_UNUSED)
+get_attr_length_1 (rtx insn, int (*fallback_fn) (rtx))
 {
-#ifdef HAVE_ATTR_length
   rtx body;
   int i;
   int length = 0;
 
+  if (!HAVE_ATTR_length)
+return 0;
+
   if (insn_lengths_max_uid  INSN_UID (insn))
 return insn_lengths[INSN_UID (insn)];
   else
@@ -432,11 +443,6 @@ get_attr_length_1 (rtx insn ATTRIBUTE_UN
   ADJUST_INSN_LENGTH (insn, length);
 #endif
   return length;
-#else /* not HAVE_ATTR_length */
-  return 0;
-#define insn_default_length 0
-#define insn_min_length 0
-#endif /* not HAVE_ATTR_length */
 }
 
 /* Obtain the current length of an insn.  If branch shortening has been done,
@@ -583,7 +589,6 @@ label_to_max_skip (rtx label)
   return 0;
 }
 
-#ifdef HAVE_ATTR_length
 /* The differences in addresses
between a branch and its target might grow or shrink depending on
the alignment the start insn of the range (the branch for a forward
@@ -686,7 +691,6 @@ insn_current_reference_address (rtx bran
  + align_fuzz (dest, seq, length_unit_log, ~0));
 }
 }
-#endif /* HAVE_ATTR_length */
 
 /* Compute branch alignments based on frequency information in the
CFG.  */
@@ -851,14 +855,13 @@ struct rtl_opt_pass pass_compute_alignme
slots.  */
 
 void
-shorten_branches (rtx first ATTRIBUTE_UNUSED)
+shorten_branches (rtx first)
 {
   rtx insn;
   int max_uid;
   int i;
   int 

Re: Fwd/Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-11-04 Thread Alexandre Oliva
On Nov  1, 2012, Joern Rennecke joern.renne...@embecosm.com wrote:

 Quoting Richard Sandiford rdsandif...@googlemail.com:
 OK with those changes for the rtl bits.  Can't approve the generator
 stuff though.

 Can you build machinery maintainers also review gen* and *.def patches,
 of this patch ( http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02897.html ).
 or are you strictly limited to *.in files as hinted in the MAINTAINERS file?

I don't think gen* and *.def are part of the build machinery, no.

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist  Red Hat Brazil Compiler Engineer


Fwd/Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-11-01 Thread Joern Rennecke

Quoting Richard Sandiford rdsandif...@googlemail.com:


OK with those changes for the rtl bits.  Can't approve the generator
stuff though.


Can you build machinery maintainers also review gen* and *.def patches,
of this patch ( http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02897.html ).
or are you strictly limited to *.in files as hinted in the MAINTAINERS file?



Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-31 Thread Joern Rennecke

Quoting Richard Sandiford rdsandif...@googlemail.com:


I can't approve the whole thing of course, but I like the idea.
However...

Joern Rennecke joern.renne...@embecosm.com writes:

+@deftypevr {Target Hook} bool TARGET_HAVE_CC0
+@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
+@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
+These flags are automatically generated;  you should not override   
them in @file{tm.c}.

+@end deftypevr


Unless this goes against something already discussed, I think it'd be
better to leave these out until there's a concerted attempt to use them
somewhere.  On its own this isn't even a partial transition. :-)


Well, I was tempted to do a full transition, but then realized that that'd
never get reviewed, so I thought a good start to get out of the hole we
got ourselves into is to stop digging.  Well, maybe we can't even do that
before 4.8 ... whatever.  I have removed that bit from the patch.


+  /* We make an exception here to provide stub definitions for
+ insn_*_length* / get_attr_enabled functions.  */
+  puts (#if !HAVE_ATTR_length\n
+   extern int hook_int_rtx_0 (rtx);\n
+   #define insn_default_length hook_int_rtx_0\n
+   #define insn_min_length hook_int_rtx_0\n
+   #define insn_variable_length_p hook_int_rtx_0\n
+   #define insn_current_length hook_int_rtx_0\n
+   #include \insn-addr.h\\n
+   #endif\n


I'd prefer defaults that call gcc_unreachable, rather than silently
return an arbitrary value.


I'm using a new hook hook_int_rtx_unreachable for this purpose.

tested with config-list.mk on x86_64-unknown-linux-gnu.

2012-10-30  Joern Rennecke  joern.renne...@embecosm.com

* doc/md.texi (Defining Attributes): Document that we are defining
HAVE_ATTR_name macors as 1 for defined attributes, and as 0
for undefined special attributes.
* final.c (asm_insn_count, align_fuzz): Always define.
(insn_current_reference_address): Likewise.
(init_insn_lengths): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(get_attr_length_1, shorten_branches, final): Likewise.
(final_scan_insn, output_asm_name): Likewise.
* genattr.c (gen_attr): Define HAVE_ATTR_name macros for
defined attributes as 1.
Remove ancient get_attr_alternative compatibility code.
For special purpose attributes not provided, define HAVE_ATTR_name
as 0.
In case no length attribute is given, provide stub definitions
for insn_*_length* functions, and also include insn-addr.h.
In case no enabled attribute is given, provide stub definition.
* genattrtab.c (write_length_unit_log): Always write a definition.
* hooks.c (hook_int_rtx_1, hook_int_rtx_unreachable): New functions.
* hooks.h (hook_int_rtx_1, hook_int_rtx_unreachable): Declare.
* lra-int.h (struct lra_insn_recog_data): Make member
alternative_enabled_p unconditional.
* lra.c (free_insn_recog_data): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(lra_set_insn_recog_data): Likewise.  Make initialization of
alternative_enabled_p unconditional.
(lra_update_insn_recog_data): Use #if instead of #ifdef for
HAVE_ATTR_enabled.
* recog.c [!HAVE_ATTR_enabled] (get_attr_enabled): Don't define.
(extract_insn): Check HAVE_ATTR_enabled.
(gate_handle_split_before_regstack): Use #if instead of
#if defined for HAVE_ATTR_length.

Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 193015)
+++ gcc/doc/md.texi (working copy)
@@ -7566,7 +7566,7 @@ (define_attr type branch,fp,load,stor
 the following lines will be written to the file @file{insn-attr.h}.
 
 @smallexample
-#define HAVE_ATTR_type
+#define HAVE_ATTR_type 1
 enum attr_type @{TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  TYPE_STORE, TYPE_ARITH@};
 extern enum attr_type get_attr_type ();
@@ -7591,6 +7591,10 @@ extern enum attr_type get_attr_type ();
 generation. @xref{Disable Insn Alternatives}.
 @end table
 
+For each of these special attributes, the corresponding
+@samp{HAVE_ATTR_@var{name}} @samp{#define} is also written when the
+attribute is not defined; in that case, it is defined as @samp{0}.
+
 @findex define_enum_attr
 @anchor{define_enum_attr}
 Another way of defining an attribute is to use:
Index: gcc/hooks.c
===
--- gcc/hooks.c (revision 193015)
+++ gcc/hooks.c (working copy)
@@ -203,6 +203,18 @@ hook_int_rtx_0 (rtx a ATTRIBUTE_UNUSED)
 }
 
 int
+hook_int_rtx_1 (rtx)
+{
+  return 1;
+}
+
+int
+hook_int_rtx_unreachable (rtx)
+{
+  gcc_unreachable ();
+}
+
+int
 hook_int_rtx_bool_0 (rtx a ATTRIBUTE_UNUSED, bool b ATTRIBUTE_UNUSED)
 {
   

Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-31 Thread Richard Sandiford
Joern Rennecke joern.renne...@embecosm.com writes:
 Quoting Richard Sandiford rdsandif...@googlemail.com:

 I can't approve the whole thing of course, but I like the idea.
 However...

 Joern Rennecke joern.renne...@embecosm.com writes:
 +@deftypevr {Target Hook} bool TARGET_HAVE_CC0
 +@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
 +@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
 +These flags are automatically generated;  you should not override   
 them in @file{tm.c}.
 +@end deftypevr

 Unless this goes against something already discussed, I think it'd be
 better to leave these out until there's a concerted attempt to use them
 somewhere.  On its own this isn't even a partial transition. :-)

 Well, I was tempted to do a full transition, but then realized that that'd
 never get reviewed, so I thought a good start to get out of the hole we
 got ourselves into is to stop digging.  Well, maybe we can't even do that
 before 4.8 ... whatever.  I have removed that bit from the patch.

Thanks.

Sorry, a couple of minor nits that I should probably have picked
up on before:

 @@ -2853,12 +2837,13 @@ final_scan_insn (rtx insn, FILE *file, i
   if (new_rtx == insn  PATTERN (new_rtx) == body)
 fatal_insn (could not split insn, insn);
  
 -#ifdef HAVE_ATTR_length
 - /* This instruction should have been split in shorten_branches,
 -to ensure that we would have valid length info for the
 -splitees.  */
 - gcc_unreachable ();
 -#endif
 + if (HAVE_ATTR_length)
 +   {
 + /* This instruction should have been split in shorten_branches,
 +to ensure that we would have valid length info for the
 +splitees.  */
 + gcc_unreachable ();
 +   }

probably gcc_assert (!HAVE_ATTR_length);

 @@ -3816,7 +3809,7 @@ struct rtl_opt_pass pass_split_after_rel
  static bool
  gate_handle_split_before_regstack (void)
  {
 -#if defined (HAVE_ATTR_length)  defined (STACK_REGS)
 +#if (HAVE_ATTR_length)  defined (STACK_REGS)
/* If flow2 creates new instructions which need splitting
   and scheduling after reload is not done, they might not be
   split until final which doesn't allow splitting
 @@ -3900,7 +3893,7 @@ struct rtl_opt_pass pass_split_before_sc
  static bool
  gate_do_final_split (void)
  {
 -#if defined (HAVE_ATTR_length)  !defined (STACK_REGS)
 +#if (HAVE_ATTR_length)  !defined (STACK_REGS)
return 1;
  #else
return 0;

Redundant brackets around HAVE_ATTR_length.

OK with those changes for the rtl bits.  Can't approve the generator
stuff though.

Richard


Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-30 Thread Richard Sandiford
I can't approve the whole thing of course, but I like the idea.
However...

Joern Rennecke joern.renne...@embecosm.com writes:
 +@deftypevr {Target Hook} bool TARGET_HAVE_CC0
 +@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
 +@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
 +These flags are automatically generated;  you should not override them in 
 @file{tm.c}.
 +@end deftypevr

Unless this goes against something already discussed, I think it'd be
better to leave these out until there's a concerted attempt to use them
somewhere.  On its own this isn't even a partial transition. :-)

 +  /* We make an exception here to provide stub definitions for
 + insn_*_length* / get_attr_enabled functions.  */
 +  puts (#if !HAVE_ATTR_length\n
 + extern int hook_int_rtx_0 (rtx);\n
 + #define insn_default_length hook_int_rtx_0\n
 + #define insn_min_length hook_int_rtx_0\n
 + #define insn_variable_length_p hook_int_rtx_0\n
 + #define insn_current_length hook_int_rtx_0\n
 + #include \insn-addr.h\\n
 + #endif\n

I'd prefer defaults that call gcc_unreachable, rather than silently
return an arbitrary value.  That said,

 + #if !HAVE_ATTR_enabled\n
 + extern int hook_int_rtx_1 (rtx);\n
 + #define get_attr_enabled hook_int_rtx_1\n
 + #endif\n);

I agree that 1 is a safe default here.

Richard


Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-28 Thread Andreas Schwab
Joern Rennecke joern.renne...@embecosm.com writes:

 Index: gcc/doc/tm.texi
 ===
 --- gcc/doc/tm.texi   (revision 192840)
 +++ gcc/doc/tm.texi   (working copy)
 @@ -11333,3 +11333,11 @@ @deftypefn {Target Hook} {unsigned HOST_
  @deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
  This value should be set if the result written by @code{atomic_test_and_set} 
 is not exactly 1, i.e. the @code{bool} @code{true}.
  @end deftypevr
 +
 +@deftypevr {Target Hook} bool TARGET_HAVE_CC0
 +@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
 +@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
 +@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
 +These flags are automatically generated;  you should not override them in 
 tm.c:

Typo: s/:$/./, also @file{tm.c}.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


Re: Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-28 Thread Joern Rennecke

Quoting Andreas Schwab sch...@linux-m68k.org:

+These flags are automatically generated;  you should not override   
them in tm.c:


Typo: s/:$/./, also @file{tm.c}.


Thanks.  I have re-bootstrapped the amended patch on i686-pc-linux-gnu.
2012-10-28  Joern Rennecke  joern.renne...@embecosm.com

* doc/md.texi (Defining Attributes): Document that we are defining
HAVE_ATTR_name macors as 1 for defined attributes, and as 0
for undefined special attributes.
* doc/tm.texi.in: Add @hook TARGET_HAVE_CC0.
* doc/tm.texi: Regenerate.
* final.c (asm_insn_count, align_fuzz): Always define.
(insn_current_reference_address): Likewise.
(init_insn_lengths): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(get_attr_length_1, shorten_branches, final): Likewise.
(final_scan_insn, output_asm_name): Likewise.
* genattr.c (gen_attr): Define HAVE_ATTR_name macros for
defined attributes as 1.
Remove ancient get_attr_alternative compatibility code.
For special purpose attributes not provided, define HAVE_ATTR_name
as 0.
In case no length attribute is given, provide stub definitions
for insn_*_length* functions, and also include insn-addr.h.
In case no enabled attribute is given, provide stub definition.
* genattrtab.c (write_length_unit_log): Always write a definition.
* hooks.c (hook_int_rtx_1): New function.
* hooks.h (hook_int_rtx_1): Declare.
* lra-int.h (struct lra_insn_recog_data): Make member
alternative_enabled_p unconditional.
* lra.c (free_insn_recog_data): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(lra_set_insn_recog_data): Likewise.  Make initialization of
alternative_enabled_p unconditional.
(lra_update_insn_recog_data): Use #if instead of #ifdef for
HAVE_ATTR_enabled.
* recog.c [!HAVE_ATTR_enabled] (get_attr_enabled): Don't define.
(extract_insn): Check HAVE_ATTR_enabled.
(gate_handle_split_before_regstack): Use #if instead of
#if defined for HAVE_ATTR_length.
* gcc/target-def.h: Provide definitions for TARGET_HAVE_CC0,
TARGET_AUTO_INC_DEC, TARGET_STACK_REGS, TARGET_HAVE_ATTR_LENGTH
and TARGET_HAVE_ATTR_ENABLED.
* target.def (have_cc0, auto_inc_dec): New flags in target structure.
(stack_regs, have_attr_enabled, have_attr_length): Likewise.

Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 192840)
+++ gcc/doc/md.texi (working copy)
@@ -7558,7 +7558,7 @@ (define_attr type branch,fp,load,stor
 the following lines will be written to the file @file{insn-attr.h}.
 
 @smallexample
-#define HAVE_ATTR_type
+#define HAVE_ATTR_type 1
 enum attr_type @{TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  TYPE_STORE, TYPE_ARITH@};
 extern enum attr_type get_attr_type ();
@@ -7583,6 +7583,10 @@ extern enum attr_type get_attr_type ();
 generation. @xref{Disable Insn Alternatives}.
 @end table
 
+For each of these special attributes, the corresponding
+@samp{HAVE_ATTR_@var{name}} @samp{#define} is also written when the
+attribute is not defined; in that case, it is defined as @samp{0}.
+
 @findex define_enum_attr
 @anchor{define_enum_attr}
 Another way of defining an attribute is to use:
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi (revision 192840)
+++ gcc/doc/tm.texi (working copy)
@@ -11333,3 +11333,11 @@ @deftypefn {Target Hook} {unsigned HOST_
 @deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
 This value should be set if the result written by @code{atomic_test_and_set} 
is not exactly 1, i.e. the @code{bool} @code{true}.
 @end deftypevr
+
+@deftypevr {Target Hook} bool TARGET_HAVE_CC0
+@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
+@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
+These flags are automatically generated;  you should not override them in 
@file{tm.c}.
+@end deftypevr
Index: gcc/doc/tm.texi.in
===
--- gcc/doc/tm.texi.in  (revision 192840)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -11173,3 +11173,5 @@ @hook TARGET_MEMMODEL_CHECK
 @end deftypefn
 
 @hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
+
+@hook TARGET_HAVE_CC0
Index: gcc/final.c
===
--- gcc/final.c (revision 192840)
+++ gcc/final.c (working copy)
@@ -204,9 +204,7 @@ Software Foundation; either version 3, o
 /* True if printing into -fdump-final-insns= dump.  */   
 bool final_insns_dump_p;
 
-#ifdef HAVE_ATTR_length
 static int asm_insn_count (rtx);
-#endif
 static void profile_function (FILE 

Ping / update: RFA: replace #ifdef with if/#if for HAVE_ATTR_*

2012-10-27 Thread Joern Rennecke

With the lra branch merged, I had to update the patch, because of new uses of
HAVE_ATTTR_enabled.  While looking at the conflicts, I also found that it
was often hard to tell if macros were used for performance reasons, or
just because there was no other interface available. lra itself is probably
one of the last files that we want to wean from tm.h, because it's use of
FIRST_PSEUDO_REGISTER, but some of the macros it uses in #ifdefs are used
in other files with much more tenous connections to tm.h.  So, for these to
use, I added a few new piece-of-data members in the target structure.

bootstrapped in revision 192840 on i686-pc-linux-gnu.
tested iin revision 192840 with config.list.mk on i686-pc-linux-gnu.
2012-10-27  Joern Rennecke  joern.renne...@embecosm.com

* doc/md.texi (Defining Attributes): Document that we are defining
HAVE_ATTR_name macors as 1 for defined attributes, and as 0
for undefined special attributes.
* doc/tm.texi.in: Add @hook TARGET_HAVE_CC0.
* doc/tm.texi: Regenerate.
* final.c (asm_insn_count, align_fuzz): Always define.
(insn_current_reference_address): Likewise.
(init_insn_lengths): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(get_attr_length_1, shorten_branches, final): Likewise.
(final_scan_insn, output_asm_name): Likewise.
* genattr.c (gen_attr): Define HAVE_ATTR_name macros for
defined attributes as 1.
Remove ancient get_attr_alternative compatibility code.
For special purpose attributes not provided, define HAVE_ATTR_name
as 0.
In case no length attribute is given, provide stub definitions
for insn_*_length* functions, and also include insn-addr.h.
In case no enabled attribute is given, provide stub definition.
* genattrtab.c (write_length_unit_log): Always write a definition.
* hooks.c (hook_int_rtx_1): New function.
* hooks.h (hook_int_rtx_1): Declare.
* lra-int.h (struct lra_insn_recog_data): Make member
alternative_enabled_p unconditional.
* lra.c (free_insn_recog_data): Use if (HAVE_ATTR_length) instead of
#ifdef HAVE_ATTR_length.
(lra_set_insn_recog_data): Likewise.  Make initialization of
alternative_enabled_p unconditional.
(lra_update_insn_recog_data): Use #if instead of #ifdef for
HAVE_ATTR_enabled.
* recog.c [!HAVE_ATTR_enabled] (get_attr_enabled): Don't define.
(extract_insn): Check HAVE_ATTR_enabled.
(gate_handle_split_before_regstack): Use #if instead of
#if defined for HAVE_ATTR_length.
* gcc/target-def.h: Provide definitions for TARGET_HAVE_CC0,
TARGET_AUTO_INC_DEC, TARGET_STACK_REGS, TARGET_HAVE_ATTR_LENGTH
and TARGET_HAVE_ATTR_ENABLED.
* target.def (have_cc0, auto_inc_dec): New flags in target structure.
(stack_regs, have_attr_enabled, have_attr_length): Likewise.

Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 192840)
+++ gcc/doc/md.texi (working copy)
@@ -7558,7 +7558,7 @@ (define_attr type branch,fp,load,stor
 the following lines will be written to the file @file{insn-attr.h}.
 
 @smallexample
-#define HAVE_ATTR_type
+#define HAVE_ATTR_type 1
 enum attr_type @{TYPE_BRANCH, TYPE_FP, TYPE_LOAD,
  TYPE_STORE, TYPE_ARITH@};
 extern enum attr_type get_attr_type ();
@@ -7583,6 +7583,10 @@ extern enum attr_type get_attr_type ();
 generation. @xref{Disable Insn Alternatives}.
 @end table
 
+For each of these special attributes, the corresponding
+@samp{HAVE_ATTR_@var{name}} @samp{#define} is also written when the
+attribute is not defined; in that case, it is defined as @samp{0}.
+
 @findex define_enum_attr
 @anchor{define_enum_attr}
 Another way of defining an attribute is to use:
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi (revision 192840)
+++ gcc/doc/tm.texi (working copy)
@@ -11333,3 +11333,11 @@ @deftypefn {Target Hook} {unsigned HOST_
 @deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
 This value should be set if the result written by @code{atomic_test_and_set} 
is not exactly 1, i.e. the @code{bool} @code{true}.
 @end deftypevr
+
+@deftypevr {Target Hook} bool TARGET_HAVE_CC0
+@deftypevrx {Target Hook} {bool} TARGET_AUTO_INC_DEC
+@deftypevrx {Target Hook} {bool} TARGET_STACK_REGS
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_ENABLED
+@deftypevrx {Target Hook} {bool} TARGET_HAVE_ATTR_LENGTH
+These flags are automatically generated;  you should not override them in tm.c:
+@end deftypevr
Index: gcc/doc/tm.texi.in
===
--- gcc/doc/tm.texi.in  (revision 192840)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -11173,3 +11173,5 @@ @hook TARGET_MEMMODEL_CHECK
 @end deftypefn