On 18 Nov 2011, at 22:06, Joseph S. Myers wrote:

TM_CLONE_TABLE_SECTION_NAME would better be a target hook, not a macro.

... done as below ...

It should be possible for Rainer to define TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME to NULL, and have varasm use the normal data section for tm_clone_table sections. One might wish to re-adjust testsuite/gcc.dg/tm/20100615.c if that is done.


OK for trunk?
Iain

gcc:

        * target.def (tm_clone_table_section_name): New hook.
        * doc/tm.texi.in (TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME): Define.
        * doc/tm.texi: Regenerate.
* varasm.c (dump_tm_clone_pairs): Use target tm_clone_table_section_name if
        available, if that is NULL fall back to the data section.
        * config/darwin.h (TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME): New.


gcc/testsuite:

        * gcc.dg/tm/20100615.c: Adjust for Darwin tm_clone_table section name.

Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in  (revision 181497)
+++ gcc/doc/tm.texi.in  (working copy)
@@ -7013,6 +7013,8 @@ otherwise.
 
 @hook TARGET_ASM_MERGEABLE_RODATA_PREFIX
 
+@hook TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME
+
 @hook TARGET_ASM_SELECT_RTX_SECTION
 Return the section into which a constant @var{x}, of mode @var{mode},
 should be placed.  You can assume that @var{x} is some kind of
Index: gcc/target.def
===================================================================
--- gcc/target.def      (revision 181497)
+++ gcc/target.def      (working copy)
@@ -305,6 +305,16 @@ section names for mergeable constant data.  Define
 the string if a different section name should be used.",
  const char *, ".rodata")
 
+/* Set if the target wants to override the default ".tm_clone_table"
+   section name.  */
+DEFHOOKPOD
+(tm_clone_table_section_name,
+ "Define this macro to specify the section name that should be used\
+  for transactional memory clone tables.  If this is defined to NULL\
+  the normal data section will be used for the tables instead.\
+  The default section name is @code{\".tm_clone_table\"}.",
+ const char *, ".tm_clone_table")
+
 /* Output a constructor for a symbol with a given priority.  */
 DEFHOOK
 (constructor,
Index: gcc/testsuite/gcc.dg/tm/20100615.c
===================================================================
--- gcc/testsuite/gcc.dg/tm/20100615.c  (revision 181497)
+++ gcc/testsuite/gcc.dg/tm/20100615.c  (working copy)
@@ -3,7 +3,8 @@
 
 /* Since the non TM version of new_node() gets optimized away, it
    shouldn't appear in the clone table either.  */
-/* { dg-final { scan-assembler-not "tm_clone_table" } } */
+/* { dg-final { scan-assembler-not "tm_clone_table" { target { ! *-*-darwin*  
} } } } */
+/* { dg-final { scan-assembler-not "__DATA,__tm_clone_table" { target 
*-*-darwin*  } } } */
 
 #define NULL 0
 extern void *malloc (__SIZE_TYPE__);
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 181497)
+++ gcc/varasm.c        (working copy)
@@ -5961,7 +5961,13 @@ dump_tm_clone_pairs (VEC(tm_alias_pair,heap) *tm_a
 
       if (!switched)
        {
-         switch_to_section (get_named_section (NULL, ".tm_clone_table", 3));
+         if (targetm.asm_out.tm_clone_table_section_name)
+           switch_to_section (get_named_section 
+                               (NULL, 
+                                targetm.asm_out.tm_clone_table_section_name,
+                                3));
+         else
+           switch_to_section (data_section);
          assemble_align (POINTER_SIZE);
          switched = true;
        }
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h (revision 181497)
+++ gcc/config/darwin.h (working copy)
@@ -692,6 +692,10 @@ extern GTY(()) section * darwin_sections[NUM_DARWI
 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section
 #undef  TARGET_ASM_FUNCTION_RODATA_SECTION
 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
+
+#undef  TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME
+#define TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME "__DATA,__tm_clone_table"
+
 #undef  TARGET_ASM_RELOC_RW_MASK
 #define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask
 



Reply via email to