OSDN Git Service

2005-12-28 Daniel Berlin <dberlin@dberlin.org>
[pf3gnuchains/gcc-fork.git] / gcc / varasm.c
index 244d6d8..f39b07c 100644 (file)
@@ -152,8 +152,6 @@ section *ctors_section;
 section *dtors_section;
 section *bss_section;
 section *sbss_section;
-section *init_section;
-section *fini_section;
 
 /* The section that holds the main exception table, when known.  The section
    is set either by the target's init_sections hook or by the first call to
@@ -169,8 +167,9 @@ section *eh_frame_section;
    been selected or if we lose track of what the current section is.  */
 section *in_section;
 
-/* The last text section used by asm_out_file.  */
-section *last_text_section;
+/* True if code for the current function is currently being directed
+   at the cold section.  */
+bool in_cold_section_p;
 
 /* A linked list of all the unnamed sections.  */
 static GTY(()) section *unnamed_sections;
@@ -413,6 +412,22 @@ asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
 
 #endif /* BSS_SECTION_ASM_OP */
 
+#ifndef USE_SELECT_SECTION_FOR_FUNCTIONS
+/* Return the hot section for function DECL.  Return text_section for
+   null DECLs.  */
+
+static section *
+hot_function_section (tree decl)
+{
+  if (decl != NULL_TREE
+      && DECL_SECTION_NAME (decl) != NULL_TREE
+      && targetm.have_named_sections)
+    return get_named_section (decl, NULL, 0);
+  else
+    return text_section;
+}
+#endif
+
 /* Return the section for function DECL.
 
    If DECL is NULL_TREE, return the text section.  We can be passed
@@ -429,12 +444,7 @@ function_section (tree decl)
 #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
   return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
 #else
-  if (decl != NULL_TREE
-      && DECL_SECTION_NAME (decl) != NULL_TREE
-      && targetm.have_named_sections)
-    return get_named_section (decl, NULL, 0);
-  else
-    return text_section;
+  return hot_function_section (decl);
 #endif
 }
 
@@ -442,17 +452,13 @@ section *
 current_function_section (void)
 {
 #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
-  int reloc = 0; 
-
-  if (unlikely_text_section_p (last_text_section))
-    reloc = 1;
-  return targetm.asm_out.select_section (current_function_decl, reloc,
+  return targetm.asm_out.select_section (current_function_decl,
+                                        in_cold_section_p,
                                         DECL_ALIGN (current_function_decl));
 #else
-  if (last_text_section)
-    return last_text_section;
-  return function_section (current_function_decl);
+  return (in_cold_section_p
+         ? unlikely_text_section ()
+         : hot_function_section (current_function_decl));
 #endif
 }
 
@@ -1085,7 +1091,7 @@ assemble_start_function (tree decl, const char *fnname)
 
   if (flag_reorder_blocks_and_partition)
     {
-      unlikely_text_section ();
+      switch_to_section (unlikely_text_section ());
       assemble_align (FUNCTION_BOUNDARY);
       ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_label);
 
@@ -1117,7 +1123,7 @@ assemble_start_function (tree decl, const char *fnname)
        first_function_block_is_cold = true;
     }
 
-  last_text_section = NULL;
+  in_cold_section_p = first_function_block_is_cold;
 
   /* Switch to the correct text section for the start of the function.  */
 
@@ -1202,7 +1208,7 @@ assemble_end_function (tree decl, const char *fnname)
       section *save_text_section;
 
       save_text_section = in_section;
-      unlikely_text_section ();
+      switch_to_section (unlikely_text_section ());
       ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_end_label);
       if (first_function_block_is_cold)
        switch_to_section (text_section);
@@ -3071,6 +3077,7 @@ output_constant_pool_2 (enum machine_mode mode, rtx x, unsigned int align)
   switch (GET_MODE_CLASS (mode))
     {
     case MODE_FLOAT:
+    case MODE_DECIMAL_FLOAT:
       {
        REAL_VALUE_TYPE r;
        
@@ -3470,18 +3477,24 @@ initializer_constant_valid_p (tree value, tree endtype)
     case ADDR_EXPR:
     case FDESC_EXPR:
       value = staticp (TREE_OPERAND (value, 0));
-      /* "&(*a).f" is like unto pointer arithmetic.  If "a" turns out to
-        be a constant, this is old-skool offsetof-like nonsense.  */
-      if (value
-         && TREE_CODE (value) == INDIRECT_REF
-         && TREE_CONSTANT (TREE_OPERAND (value, 0)))
-       return null_pointer_node;
-      /* Taking the address of a nested function involves a trampoline.  */
-      if (value
-         && TREE_CODE (value) == FUNCTION_DECL
-         && ((decl_function_context (value) && !DECL_NO_STATIC_CHAIN (value))
-             || DECL_DLLIMPORT_P (value)))
-       return NULL_TREE;
+      if (value)
+       {
+         /* "&(*a).f" is like unto pointer arithmetic.  If "a" turns out to
+            be a constant, this is old-skool offsetof-like nonsense.  */
+         if (TREE_CODE (value) == INDIRECT_REF
+             && TREE_CONSTANT (TREE_OPERAND (value, 0)))
+           return null_pointer_node;
+         /* Taking the address of a nested function involves a trampoline.  */
+         if (TREE_CODE (value) == FUNCTION_DECL
+             && ((decl_function_context (value) 
+                  && !DECL_NO_STATIC_CHAIN (value))
+                 || DECL_DLLIMPORT_P (value)))
+           return NULL_TREE;
+         /* "&{...}" requires a temporary to hold the constructed
+            object.  */
+         if (TREE_CODE (value) == CONSTRUCTOR)
+           return NULL_TREE;
+       }
       return value;
 
     case VIEW_CONVERT_EXPR:
@@ -3876,7 +3889,7 @@ array_size_for_constructor (tree val)
   i = size_binop (MINUS_EXPR, convert (sizetype, max_index),
                  convert (sizetype,
                           TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)))));
-  i = size_binop (PLUS_EXPR, i, convert (sizetype, integer_one_node));
+  i = size_binop (PLUS_EXPR, i, build_int_cst (sizetype, 1));
 
   /* Multiply by the array element unit size to find number of bytes.  */
   i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
@@ -4857,16 +4870,6 @@ init_varasm_once (void)
                                      SBSS_SECTION_ASM_OP);
 #endif
 
-#ifdef INIT_SECTION_ASM_OP
-  init_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
-                                     INIT_SECTION_ASM_OP);
-#endif
-
-#ifdef FINI_SECTION_ASM_OP
-  fini_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
-                                     FINI_SECTION_ASM_OP);
-#endif
-
   targetm.asm_out.init_sections ();
 
   if (readonly_data_section == NULL)
@@ -5324,11 +5327,20 @@ default_unique_section_1 (tree decl, int reloc, int shlib)
       prefix = one_only ? ".gnu.linkonce.s2." : ".sdata2.";
       break;
     case SECCAT_DATA:
+      prefix = one_only ? ".gnu.linkonce.d." : ".data.";
+      break;
     case SECCAT_DATA_REL:
+      prefix = one_only ? ".gnu.linkonce.d.rel." : ".data.rel.";
+      break;
     case SECCAT_DATA_REL_LOCAL:
+      prefix = one_only ? ".gnu.linkonce.d.rel.local." : ".data.rel.local.";
+      break;
     case SECCAT_DATA_REL_RO:
+      prefix = one_only ? ".gnu.linkonce.d.rel.ro." : ".data.rel.ro.";
+      break;
     case SECCAT_DATA_REL_RO_LOCAL:
-      prefix = one_only ? ".gnu.linkonce.d." : ".data.";
+      prefix = one_only ? ".gnu.linkonce.d.rel.ro.local."
+              : ".data.rel.ro.local.";
       break;
     case SECCAT_SDATA:
       prefix = one_only ? ".gnu.linkonce.s." : ".sdata.";
@@ -5598,11 +5610,7 @@ switch_to_section (section *new_section)
   if (new_section->common.flags & SECTION_FORGET)
     in_section = NULL;
   else
-    {
-      in_section = new_section;
-      if (new_section->common.flags & SECTION_CODE)
-       last_text_section = in_section;
-    }
+    in_section = new_section;
 
   if (new_section->common.flags & SECTION_NAMED)
     {