dwarf2.h (dwarf_calling_convention): Add enum for renesas sh abi.
authorEric Christopher <echristo@gcc.gnu.org>
Fri, 1 Oct 2004 05:08:59 +0000 (05:08 +0000)
committerEric Christopher <echristo@gcc.gnu.org>
Fri, 1 Oct 2004 05:08:59 +0000 (05:08 +0000)
2004-09-30  Eric Christopher  <echristo@redhat.com>

* dwarf2.h (dwarf_calling_convention): Add enum for renesas
sh abi.
* dwarf2out.c (add_calling_convention_attribute): New function.
(gen_subroutine_type_die): Use.
* target-def.h (TARGET_DWARF_CALLING_CONVENTION): New hook.
* target.h (gcc_target): Add dwarf_calling_convention.
* hooks.c (hook_int_tree_0): New function.
* hooks.h: Prototype.
* config/sh/sh.c: Include dwarf2.h.
(sh_dwarf_calling_convention): New function.
(TARGET_DWARF_CALLING_CONVENTION): Use.
* doc/tm.texi (TARGET_DWARF_CALLING_CONVENTION): Document.

From-SVN: r88382

gcc/ChangeLog
gcc/config/sh/sh.c
gcc/doc/tm.texi
gcc/dwarf2.h
gcc/dwarf2out.c
gcc/hooks.c
gcc/hooks.h
gcc/target-def.h
gcc/target.h
gcc/targhooks.c

index 1cc8a2bd5897e06bbd410b8cde8310d2c4c367eb..5fcdf209fb2ed943da0f44cdcfb1f32dc9afdd13 100644 (file)
@@ -1,3 +1,18 @@
+2004-09-30  Eric Christopher  <echristo@redhat.com>
+
+       * dwarf2.h (dwarf_calling_convention): Add enum for renesas
+       sh abi.
+       * dwarf2out.c (add_calling_convention_attribute): New function.
+       (gen_subroutine_type_die): Use.
+       * target-def.h (TARGET_DWARF_CALLING_CONVENTION): New hook.
+       * target.h (gcc_target): Add dwarf_calling_convention.
+       * hooks.c (hook_int_tree_0): New function.
+       * hooks.h: Prototype.
+       * config/sh/sh.c: Include dwarf2.h.
+       (sh_dwarf_calling_convention): New function.
+       (TARGET_DWARF_CALLING_CONVENTION): Use.
+       * doc/tm.texi (TARGET_DWARF_CALLING_CONVENTION): Document.
+
 2004-09-30  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * builtins.c (expand_builtin_strstr, expand_builtin_strchr,
        s390_update_frame_layout instead of s390_register_info.  Handle
        prologue/epilogue insns that touch only RETURN_REGNUM.
        (s390_reorg): Remove base_used.  Clear split_branches_pending_p.
-       (s390_register_info): Remove base_used and return_addr_used 
+       (s390_register_info): Remove base_used and return_addr_used
        arguments, compute special register usage inline.  Return live
        register data to caller.
        (s390_frame_info): Remove arguments, do not call s390_register_info.
index b23e1eac77cbc9e9ca7a0080a12ef7fcd10b0d39..349d981ccc98a18e46e65ca52678e1cb8c2a393f 100644 (file)
@@ -40,6 +40,7 @@ Boston, MA 02111-1307, USA.  */
 #include "recog.h"
 #include "c-pragma.h"
 #include "integrate.h"
+#include "dwarf2.h"
 #include "tm_p.h"
 #include "target.h"
 #include "target-def.h"
@@ -285,6 +286,7 @@ static bool sh_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
                                  tree, bool);
 static bool sh_callee_copies (CUMULATIVE_ARGS *, enum machine_mode,
                              tree, bool);
+static int sh_dwarf_calling_convention (tree);
 
 \f
 /* Initialize the GCC target structure.  */
@@ -454,6 +456,9 @@ static bool sh_callee_copies (CUMULATIVE_ARGS *, enum machine_mode,
 #undef TARGET_PCH_VALID_P
 #define TARGET_PCH_VALID_P sh_pch_valid_p
 
+#undef TARGET_DWARF_CALLING_CONVENTION
+#define TARGET_DWARF_CALLING_CONVENTION sh_dwarf_calling_convention
+
 /* Return regmode weight for insn.  */
 #define INSN_REGMODE_WEIGHT(INSN, MODE)  regmode_weight[((MODE) == SImode) ? 0 : 1][INSN_UID (INSN)]
 
@@ -9402,6 +9407,17 @@ sh_vector_mode_supported_p (enum machine_mode mode)
   return false;
 }
 
+/* Implements target hook dwarf_calling_convention.  Return an enum
+   of dwarf_calling_convention.  */
+int
+sh_dwarf_calling_convention (tree func)
+{
+  if (sh_attr_renesas_p (func))
+    return DW_CC_renesas_sh;
+
+  return DW_CC_normal;
+}
+
 static void
 sh_init_builtins (void)
 {
index f72713cee67521c3a1d7b59b08761fb34270c3ce..8208a89061a5b921fc67a701dcddec3f6e43996b 100644 (file)
@@ -3747,7 +3747,7 @@ known to be passed by reference.  The hook should return true if the
 function argument should be copied by the callee instead of copied
 by the caller.
 
-For any argument for which the hook returns true, if it can be 
+For any argument for which the hook returns true, if it can be
 determined that the argument is not modified, then a copy need
 not be generated.
 
@@ -8061,6 +8061,12 @@ for SDB in response to the @option{-g} option.
 Define this macro if GCC should produce dwarf version 2 format
 debugging output in response to the @option{-g} option.
 
+@deftypefn {Target Hook} int TARGET_DWARF_CALLING_CONVENTION (tree @var{function})
+Define this to enable the dwarf attribute @code{DW_AT_calling_convention} to
+be emitted for each function.  Instead of an integer return the enum
+value for the @code{DW_CC_} tag.
+@end deftypefn
+
 To support optional call frame debugging information, you must also
 define @code{INCOMING_RETURN_ADDR_RTX} and either set
 @code{RTX_FRAME_RELATED_P} on the prologue insns if you use RTL for the
index 0e98a455fabbab22cc59bc5835977e350ba94a37..111ff522fe3616b1a0fbb62c65e0a1518aee7d09 100644 (file)
@@ -474,7 +474,8 @@ enum dwarf_calling_convention
   {
     DW_CC_normal = 0x1,
     DW_CC_program = 0x2,
-    DW_CC_nocall = 0x3
+    DW_CC_nocall = 0x3,
+    DW_CC_renesas_sh = 0x40
   };
 
 #define DW_CC_lo_user 0x40
index 3992c83189bab0add4004f1ecf1efdd2f4de77d8..aa308489ff655b74f31ed3b9287617703687e409 100644 (file)
@@ -116,7 +116,7 @@ dwarf2out_do_frame (void)
 /* Various versions of targetm.eh_frame_section.  Note these must appear
    outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO macro guards.  */
 
-/* Version of targetm.eh_frame_section for systems with named sections.  */ 
+/* Version of targetm.eh_frame_section for systems with named sections.  */
 void
 named_section_eh_frame_section (void)
 {
@@ -142,7 +142,7 @@ named_section_eh_frame_section (void)
 #endif
 }
 
-/* Version of targetm.eh_frame_section for systems using collect2.  */ 
+/* Version of targetm.eh_frame_section for systems using collect2.  */
 void
 collect2_eh_frame_section (void)
 {
@@ -1150,7 +1150,7 @@ struct reg_saved_in_data GTY(()) {
    more efficient data structure.  */
 static GTY(()) struct reg_saved_in_data regs_saved_in_regs[4];
 static GTY(()) size_t num_regs_saved_in_regs;
-  
+
 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
 static const char *last_reg_save_label;
 
@@ -1253,7 +1253,7 @@ reg_saved_in (rtx reg)
   unsigned int regn = REGNO (reg);
   size_t i;
   struct queued_reg_save *q;
-  
+
   for (q = queued_reg_saves; q; q = q->next)
     if (q->saved_reg && regn == REGNO (q->saved_reg))
       return q->reg;
@@ -1311,7 +1311,7 @@ static dw_cfa_location cfa_temp;
   the intent is to save the value of SP from the previous frame.
 
   In addition, if a register has previously been saved to a different
-  register, 
+  register,
 
   Invariants / Summaries of Rules
 
@@ -1480,7 +1480,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
            {
              /* Rule 1 */
              /* Update the CFA rule wrt SP or FP.  Make sure src is
-                relative to the current CFA register. 
+                relative to the current CFA register.
 
                 We used to require that dest be either SP or FP, but the
                 ARM copies SP to a temporary register, and from there to
@@ -1677,14 +1677,14 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
        case LO_SUM:
          {
            int regno;
-           
+
            gcc_assert (GET_CODE (XEXP (XEXP (dest, 0), 1)) == CONST_INT);
            offset = INTVAL (XEXP (XEXP (dest, 0), 1));
            if (GET_CODE (XEXP (dest, 0)) == MINUS)
              offset = -offset;
 
            regno = REGNO (XEXP (XEXP (dest, 0), 0));
-           
+
            if (cfa_store.reg == (unsigned) regno)
              offset -= cfa_store.offset;
            else
@@ -1700,7 +1700,7 @@ dwarf2out_frame_debug_expr (rtx expr, const char *label)
        case REG:
          {
            int regno = REGNO (XEXP (dest, 0));
-           
+
            if (cfa_store.reg == (unsigned) regno)
              offset = -cfa_store.offset;
            else
@@ -1778,7 +1778,7 @@ dwarf2out_frame_debug (rtx insn)
   if (insn == NULL_RTX)
     {
       size_t i;
-      
+
       /* Flush any queued register saves.  */
       flush_queued_reg_saves ();
 
@@ -1791,7 +1791,7 @@ dwarf2out_frame_debug (rtx insn)
       cfa_store = cfa;
       cfa_temp.reg = -1;
       cfa_temp.offset = 0;
-      
+
       for (i = 0; i < num_regs_saved_in_regs; i++)
        {
          regs_saved_in_regs[i].orig_reg = NULL_RTX;
@@ -3930,6 +3930,7 @@ static dw_die_ref scope_die_for (tree, dw_die_ref);
 static inline int local_scope_p (dw_die_ref);
 static inline int class_or_namespace_scope_p (dw_die_ref);
 static void add_type_attribute (dw_die_ref, tree, int, int, dw_die_ref);
+static void add_calling_convention_attribute (dw_die_ref, tree);
 static const char *type_tag (tree);
 static tree member_declared_type (tree);
 #if 0
@@ -4809,11 +4810,11 @@ AT_string_form (dw_attr_ref a)
   char label[32];
 
   gcc_assert (a && AT_class (a) == dw_val_class_str);
-  
+
   node = a->dw_attr_val.v.val_str;
   if (node->form)
     return node->form;
-  
+
   len = strlen (node->str) + 1;
 
   /* If the string is shorter or equal to the size of the reference, it is
@@ -8637,7 +8638,7 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode, bool can_use_fbreg)
     case ASHIFT:
       op = DW_OP_shl;
       goto do_binop;
-      
+
     case ASHIFTRT:
       op = DW_OP_shra;
       goto do_binop;
@@ -9283,7 +9284,7 @@ field_byte_offset (tree decl)
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return 0;
-  
+
   gcc_assert (TREE_CODE (decl) == FIELD_DECL);
 
   type = field_type (decl);
@@ -9557,7 +9558,7 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
 
        if (val < 0)
          add_AT_int (die, DW_AT_const_value, val);
-       else 
+       else
          add_AT_unsigned (die, DW_AT_const_value, (unsigned HOST_WIDE_INT) val);
       }
       break;
@@ -9605,30 +9606,30 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
              {
                rtx elt = CONST_VECTOR_ELT (rtl, i);
                HOST_WIDE_INT lo, hi;
-               
+
                switch (GET_CODE (elt))
                  {
                  case CONST_INT:
                    lo = INTVAL (elt);
                    hi = -(lo < 0);
                    break;
-                   
+
                  case CONST_DOUBLE:
                    lo = CONST_DOUBLE_LOW (elt);
                    hi = CONST_DOUBLE_HIGH (elt);
                    break;
-                   
+
                  default:
                    gcc_unreachable ();
                  }
-               
+
                if (elt_size <= sizeof (HOST_WIDE_INT))
                  insert_int (lo, elt_size, p);
                else
                  {
                    unsigned char *p0 = p;
                    unsigned char *p1 = p + sizeof (HOST_WIDE_INT);
-                   
+
                    gcc_assert (elt_size == 2 * sizeof (HOST_WIDE_INT));
                    if (WORDS_BIG_ENDIAN)
                      {
@@ -10621,6 +10622,20 @@ add_type_attribute (dw_die_ref object_die, tree type, int decl_const,
     add_AT_die_ref (object_die, DW_AT_type, type_die);
 }
 
+/* Given an object die, add the calling convention attribute for the
+   function call type.  */
+static void
+add_calling_convention_attribute (dw_die_ref subr_die, tree type)
+{
+  enum dwarf_calling_convention value = DW_CC_normal;
+
+  value = targetm.dwarf_calling_convention (type);
+
+  /* Only add the attribute if the backend requests it.  */
+  if (value)
+    add_AT_unsigned (subr_die, DW_AT_calling_convention, value);
+}
+
 /* Given a tree pointer to a struct, class, union, or enum type node, return
    a pointer to the (string) tag name for the given type, or zero if the type
    was declared without a tag.  */
@@ -11165,7 +11180,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
          subr_die = old_die;
 
          /* Clear out the declaration attribute and the formal parameters.
-            Do not remove all children, because it is possible that this 
+            Do not remove all children, because it is possible that this
             declaration die was forced using force_decl_die(). In such
             cases die that forced declaration die (e.g. TAG_imported_module)
             is one of the children that we do not want to remove.  */
@@ -11218,7 +11233,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
          /* The first time we see a member function, it is in the context of
             the class to which it belongs.  We make sure of this by emitting
             the class first.  The next time is the definition, which is
-            handled above.  The two may come from the same source text. 
+            handled above.  The two may come from the same source text.
 
             Note that force_decl_die() forces function declaration die. It is
             later reused to represent definition.  */
@@ -11917,6 +11932,7 @@ gen_subroutine_type_die (tree type, dw_die_ref context_die)
   equate_type_number_to_die (type, subr_die);
   add_prototyped_attribute (subr_die, type);
   add_type_attribute (subr_die, return_type, 0, 0, context_die);
+  add_calling_convention_attribute (subr_die, type);
   gen_formal_types_die (type, subr_die);
 }
 
@@ -12356,7 +12372,7 @@ force_decl_die (tree decl)
          save_fn = current_function_decl;
          current_function_decl = NULL_TREE;
          gen_subprogram_die (decl, context_die);
-         current_function_decl = save_fn; 
+         current_function_decl = save_fn;
          break;
 
        case VAR_DECL:
@@ -12375,14 +12391,14 @@ force_decl_die (tree decl)
        default:
          gcc_unreachable ();
        }
-  
+
       /* See if we can find the die for this deci now.
         If not then abort.  */
       if (!decl_die)
        decl_die = lookup_decl_die (decl);
       gcc_assert (decl_die);
     }
-  
+
   return decl_die;
 }
 
@@ -12696,8 +12712,8 @@ dwarf2out_type_decl (tree decl, int local)
     dwarf2out_decl (decl);
 }
 
-/* Output debug information for imported module or decl.  */ 
+/* Output debug information for imported module or decl.  */
+
 static void
 dwarf2out_imported_module_or_decl (tree decl, tree context)
 {
@@ -12705,14 +12721,14 @@ dwarf2out_imported_module_or_decl (tree decl, tree context)
   dw_die_ref scope_die;
   unsigned file_index;
   expanded_location xloc;
-  
+
   if (debug_info_level <= DINFO_LEVEL_TERSE)
     return;
 
   gcc_assert (decl);
 
   /* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs.
-     We need decl DIE for reference and scope die. First, get DIE for the decl 
+     We need decl DIE for reference and scope die. First, get DIE for the decl
      itself.  */
 
   /* Get the scope die for decl context. Use comp_unit_die for global module
@@ -12729,8 +12745,8 @@ dwarf2out_imported_module_or_decl (tree decl, tree context)
     at_import_die = force_type_die (TREE_TYPE (decl));
   else
     at_import_die = force_decl_die (decl);
-  
-  /* OK, now we have DIEs for decl as well as scope. Emit imported die.  */ 
+
+  /* OK, now we have DIEs for decl as well as scope. Emit imported die.  */
   if (TREE_CODE (decl) == NAMESPACE_DECL)
     imported_die = new_die (DW_TAG_imported_module, scope_die, context);
   else
@@ -13440,7 +13456,7 @@ static void
 prune_unused_types_prune (dw_die_ref die)
 {
   dw_die_ref c, p, n;
-  
+
   gcc_assert (die->die_mark);
 
   p = NULL;
@@ -13568,9 +13584,9 @@ dwarf2out_finish (const char *filename)
                context = DECL_CONTEXT (node->created_for);
              else if (TYPE_P (node->created_for))
                context = TYPE_CONTEXT (node->created_for);
-               
+
              gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
-             
+
              origin = lookup_decl_die (context);
              if (origin)
                add_child_die (origin, die);
index 65224a4042a604eb73a6b7d52ee7f189a2b5d263..9470a4d84c6130953fa5072afb6c607edccfd364 100644 (file)
@@ -117,6 +117,12 @@ default_can_output_mi_thunk_no_vcall (tree a ATTRIBUTE_UNUSED,
   return c == 0;
 }
 
+int
+hook_int_tree_0 (tree a ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 /* ??? Used for comp_type_attributes, which ought to return bool.  */
 int
 hook_int_tree_tree_1 (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
@@ -245,4 +251,3 @@ hook_tree_tree_bool_null (tree t ATTRIBUTE_UNUSED, bool ignore ATTRIBUTE_UNUSED)
 {
   return NULL;
 }
-  
index 4f7f08c0c1c2107c0fa9234048ce7e7f75bdfd32..10966a912a28e7263ef2f45dd700b556d1b29ad5 100644 (file)
@@ -46,6 +46,7 @@ extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
 extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 
+extern int hook_int_tree_0 (tree);
 extern int hook_int_tree_tree_1 (tree, tree);
 extern int hook_int_rtx_0 (rtx);
 extern int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int);
index e8262decb8634670ba081d980c30ccf9a2845add..700d5db51ec0dac73e49495097a467dce7e9aa42 100644 (file)
@@ -379,6 +379,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 #define TARGET_MD_ASM_CLOBBERS hook_tree_tree_identity
 
+#define TARGET_DWARF_CALLING_CONVENTION hook_int_tree_0
+
 #define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_false
 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_false
 #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_false
@@ -523,6 +525,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   TARGET_DEFAULT_SHORT_ENUMS,                  \
   TARGET_BUILTIN_SETJMP_FRAME_VALUE,           \
   TARGET_MD_ASM_CLOBBERS,                      \
+  TARGET_DWARF_CALLING_CONVENTION,              \
   TARGET_CALLS,                                        \
   TARGET_CXX,                                  \
   TARGET_HAVE_NAMED_SECTIONS,                  \
index 9f766ae18dd2ec27753d05136cdca8a34f6d25c0..49a7f9d7f920fd9170b5f0627f632508c90b7c80 100644 (file)
@@ -488,6 +488,13 @@ struct gcc_target
      the port wishes to automatically clobber for all asms.  */
   tree (* md_asm_clobbers) (tree);
 
+  /* This target hook allows the backend to specify a calling convention
+     in the debug information.  This function actually returns an
+     enum dwarf_calling_convention, but because of forward declarations
+     and not wanting to include dwarf2.h everywhere target.h is included
+     the function is being declared as an int.  */
+  int (* dwarf_calling_convention) (tree);
+
   /* Functions relating to calls - argument passing, returns, etc.  */
   struct calls {
     bool (*promote_function_args) (tree fntype);
index 3bf938c1828c95c0a875e6e9e6df8a9e10e07f14..852421cb9e33996ab482731812b8fe448bafa3e8 100644 (file)
@@ -129,7 +129,7 @@ default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
          != default_setup_incoming_varargs);
 }
 
-enum machine_mode 
+enum machine_mode
 default_eh_return_filter_mode (void)
 {
   return word_mode;
@@ -173,7 +173,7 @@ default_cxx_get_cookie_size (tree type)
      (true_type)) bytes.  */
   tree sizetype_size;
   tree type_align;
-  
+
   sizetype_size = size_in_bytes (sizetype);
   type_align = size_int (TYPE_ALIGN_UNIT (type));
   if (INT_CST_LT_UNSIGNED (type_align, sizetype_size))