This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] RFA add dwarf calling convention support
How about this then?
-eric
--
Eric Christopher <echristo@redhat.com>
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.
Index: dwarf2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2.h,v
retrieving revision 1.26
diff -u -p -w -r1.26 dwarf2.h
--- dwarf2.h 8 Jan 2004 07:50:36 -0000 1.26
+++ dwarf2.h 30 Sep 2004 23:47:17 -0000
@@ -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: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.548
diff -u -p -w -r1.548 dwarf2out.c
--- dwarf2out.c 23 Sep 2004 00:51:36 -0000 1.548
+++ dwarf2out.c 30 Sep 2004 23:47:28 -0000
@@ -3930,6 +3930,7 @@ static dw_die_ref scope_die_for (tree, d
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
@@ -10621,6 +10622,20 @@ add_type_attribute (dw_die_ref object_di
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. */
@@ -11917,6 +11932,7 @@ gen_subroutine_type_die (tree type, dw_d
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);
}
Index: hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.c,v
retrieving revision 1.34
diff -u -p -w -r1.34 hooks.c
--- hooks.c 24 Sep 2004 15:13:53 -0000 1.34
+++ hooks.c 30 Sep 2004 23:47:29 -0000
@@ -117,6 +117,12 @@ default_can_output_mi_thunk_no_vcall (tr
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 ATTRIBU
{
return NULL;
}
-
Index: hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.h,v
retrieving revision 1.34
diff -u -p -w -r1.34 hooks.h
--- hooks.h 24 Sep 2004 15:13:53 -0000 1.34
+++ hooks.h 30 Sep 2004 23:47:29 -0000
@@ -46,6 +46,7 @@ extern void hook_void_FILEptr_constcharp
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: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.105
diff -u -p -w -r1.105 target-def.h
--- target-def.h 24 Sep 2004 15:13:53 -0000 1.105
+++ target-def.h 30 Sep 2004 23:47:29 -0000
@@ -379,6 +379,8 @@ Foundation, 59 Temple Place - Suite 330,
#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,
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: target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.117
diff -u -p -w -r1.117 target.h
--- target.h 23 Sep 2004 14:34:19 -0000 1.117
+++ target.h 30 Sep 2004 23:47:30 -0000
@@ -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: targhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/targhooks.c,v
retrieving revision 2.33
diff -u -p -w -r2.33 targhooks.c
Index: config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.302
diff -u -p -w -r1.302 sh.c
--- config/sh/sh.c 28 Sep 2004 17:37:35 -0000 1.302
+++ config/sh/sh.c 30 Sep 2004 23:47:42 -0000
@@ -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 (CUMULA
tree, bool);
static bool sh_callee_copies (CUMULATIVE_ARGS *, enum machine_mode,
tree, bool);
+static int sh_dwarf_calling_convention (tree);
/* Initialize the GCC target structure. */
@@ -454,6 +456,9 @@ static bool sh_callee_copies (CUMULATIVE
#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
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: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.373
diff -u -p -w -r1.373 tm.texi
--- doc/tm.texi 24 Sep 2004 06:17:04 -0000 1.373
+++ doc/tm.texi 30 Sep 2004 23:47:53 -0000
@@ -8053,6 +8053,12 @@ for SDB in response to the @option{-g} o
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