]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ia64.c (ia64_attribute_table): Add "common_object" entry.
authorTristan Gingold <gingold@adacore.com>
Thu, 27 Aug 2009 20:08:49 +0000 (20:08 +0000)
committerDouglas Rupp <rupp@gcc.gnu.org>
Thu, 27 Aug 2009 20:08:49 +0000 (20:08 +0000)
* config/ia64/ia64.c (ia64_attribute_table): Add "common_object"
entry.
(SECTION_VMS_OVERLAY): Define.
(ia64_vms_common_object_attribute): Added.  Handle the "common_object"
attribute.
(ia64_vms_elf_asm_named_section): Added.  Generate .section pseudo-op
for common_object.
(ia64_vms_output_aligned_decl_common): Added.  Generate pseudo-op for
common_object declarations.
(ia64_section_type_flags): Set section flag for common_object.
* config/ia64/ia64-protos.h
(ia64_vms_output_aligned_decl_common): Declare.
(ia64_vms_elf_asm_named_section): Declare.

Co-Authored-By: Douglas B Rupp <rupp@gnat.com>
From-SVN: r151148

gcc/ChangeLog
gcc/config/ia64/ia64-protos.h
gcc/config/ia64/ia64.c

index c70a94aece886f5755e46382527e7561227525b9..df916f54dec1e2c5b06352d260c9c4cbcbe1f3ca 100644 (file)
@@ -1,3 +1,20 @@
+2009-08-27  Tristan Gingold  <gingold@adacore.com>
+           Douglas B Rupp  <rupp@gnat.com>
+
+       * config/ia64/ia64.c (ia64_attribute_table): Add "common_object"
+       entry.
+       (SECTION_VMS_OVERLAY): Define.
+       (ia64_vms_common_object_attribute): Added.  Handle the "common_object"
+       attribute.
+       (ia64_vms_elf_asm_named_section): Added.  Generate .section pseudo-op
+       for common_object.
+       (ia64_vms_output_aligned_decl_common): Added.  Generate pseudo-op for
+       common_object declarations.
+       (ia64_section_type_flags): Set section flag for common_object.
+       * config/ia64/ia64-protos.h
+       (ia64_vms_output_aligned_decl_common): Declare.
+       (ia64_vms_elf_asm_named_section): Declare.
+
 2009-08-27  Michael Matz  <matz@suse.de>
 
        * expr.c (expand_expr_real_2): New function taking exploded
index 5a68854296f0b645fe930e303601bcd3ec8e384c..6d9440ef0d4f18c56cfabc6e4f855cd5e619a13d 100644 (file)
@@ -77,6 +77,10 @@ extern void ia64_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
                                       tree, int);
 extern int ia64_function_arg_boundary (enum machine_mode, tree);
 extern void ia64_asm_output_external (FILE *, tree, const char *);
+extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
+                                                unsigned HOST_WIDE_INT,
+                                                unsigned int);
+extern void ia64_vms_elf_asm_named_section (const char *, unsigned int, tree);
 #endif /* TREE_CODE */
 
 extern int ia64_register_move_cost (enum machine_mode, enum reg_class,
index 85bca08d3859ae9d6865e63d3dfc7e4232fde93e..dbc33cbc892f044126419f6f1a66605603be202a 100644 (file)
@@ -281,6 +281,8 @@ static void ia64_soft_fp_init_libfuncs (void)
      ATTRIBUTE_UNUSED;
 static bool ia64_vms_valid_pointer_mode (enum machine_mode mode)
      ATTRIBUTE_UNUSED;
+static tree ia64_vms_common_object_attribute (tree *, tree, tree, int, bool *)
+     ATTRIBUTE_UNUSED;
 
 static tree ia64_handle_model_attribute (tree *, tree, tree, int, bool *);
 static tree ia64_handle_version_id_attribute (tree *, tree, tree, int, bool *);
@@ -307,6 +309,9 @@ static const struct attribute_spec ia64_attribute_table[] =
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
   { "syscall_linkage", 0, 0, false, true,  true,  NULL },
   { "model",          1, 1, true, false, false, ia64_handle_model_attribute },
+#if TARGET_ABI_OPEN_VMS
+  { "common_object",   1, 1, true, false, false, ia64_vms_common_object_attribute},
+#endif
   { "version_id",      1, 1, true, false, false,
     ia64_handle_version_id_attribute },
   { NULL,             0, 0, false, false, false, NULL }
@@ -628,6 +633,95 @@ ia64_handle_model_attribute (tree *node, tree name, tree args,
   return NULL_TREE;
 }
 
+/* The section must have global and overlaid attributes.  */
+#define SECTION_VMS_OVERLAY SECTION_MACH_DEP
+
+/* Part of the low level implementation of DEC Ada pragma Common_Object which
+   enables the shared use of variables stored in overlaid linker areas
+   corresponding to the use of Fortran COMMON.  */
+
+static tree
+ia64_vms_common_object_attribute (tree *node, tree name, tree args,
+                                 int flags ATTRIBUTE_UNUSED,
+                                 bool *no_add_attrs)
+{
+    tree decl = *node;
+    tree id, val;
+    if (! DECL_P (decl))
+      abort ();
+  
+    DECL_COMMON (decl) = 1;
+    id = TREE_VALUE (args);
+    if (TREE_CODE (id) == IDENTIFIER_NODE)
+      val = build_string (IDENTIFIER_LENGTH (id), IDENTIFIER_POINTER (id));
+    else if (TREE_CODE (id) == STRING_CST)
+      val = id;
+    else
+      {
+       warning (OPT_Wattributes,
+                "%qE attribute requires a string constant argument", name);
+       *no_add_attrs = true;
+       return NULL_TREE;
+      }
+    DECL_SECTION_NAME (decl) = val;
+    return NULL_TREE;
+}
+
+/* Part of the low level implementation of DEC Ada pragma Common_Object.  */
+
+void
+ia64_vms_output_aligned_decl_common (FILE *file, tree decl, const char *name,
+                                    unsigned HOST_WIDE_INT size,
+                                    unsigned int align)
+{
+  tree attr = DECL_ATTRIBUTES (decl);
+
+  /* As common_object attribute set DECL_SECTION_NAME check it before
+     looking up the attribute.  */
+  if (DECL_SECTION_NAME (decl) && attr)
+    attr = lookup_attribute ("common_object", attr);
+  else
+    attr = NULL_TREE;
+
+  if (!attr)
+    {
+      /*  Code from elfos.h.  */
+      fprintf (file, "%s", COMMON_ASM_OP);
+      assemble_name (file, name);
+      fprintf (file, ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",
+              size, align / BITS_PER_UNIT);
+    }
+  else
+    {
+      ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
+      ASM_OUTPUT_LABEL (file, name);
+      ASM_OUTPUT_SKIP (file, size ? size : 1);
+    }
+}
+
+/* Definition of TARGET_ASM_NAMED_SECTION for VMS.  */
+
+void
+ia64_vms_elf_asm_named_section (const char *name, unsigned int flags,
+                               tree decl)
+{
+  if (!(flags & SECTION_VMS_OVERLAY))
+    {
+      default_elf_asm_named_section (name, flags, decl);
+      return;
+    }
+  if (flags != (SECTION_VMS_OVERLAY | SECTION_WRITE))
+    abort ();
+
+  if (flags & SECTION_DECLARED)
+    {
+      fprintf (asm_out_file, "\t.section\t%s\n", name);
+      return;
+    }
+
+  fprintf (asm_out_file, "\t.section\t%s,\"awgO\"\n", name);
+}
+
 static void
 ia64_encode_addr_area (tree decl, rtx symbol)
 {
@@ -10243,6 +10337,12 @@ ia64_section_type_flags (tree decl, const char *name, int reloc)
       || strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
     flags = SECTION_SMALL;
 
+#if TARGET_ABI_OPEN_VMS
+  if (decl && DECL_ATTRIBUTES (decl)
+      && lookup_attribute ("common_object", DECL_ATTRIBUTES (decl)))
+    flags |= SECTION_VMS_OVERLAY;
+#endif
+
   flags |= default_section_type_flags (decl, name, reloc);
   return flags;
 }