summaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@redhat.com>2001-11-04 07:37:48 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2001-11-04 07:37:48 +0000
commit52560c7b98c6fe25b891b558029b456437802125 (patch)
tree9b125e0bc27128b153873d26aa12f7ce2e4367ca /gcc/config
parentcb3f834fb6ad5268fe9640218d7285da0394f857 (diff)
downloadgcc-52560c7b98c6fe25b891b558029b456437802125.tar.gz
stormy16.h (ASM_OUTPUT_MI_THUNK): Call stormy16_asm_output_mi_thunk.
* config/stormy16/stormy16.h (ASM_OUTPUT_MI_THUNK): Call stormy16_asm_output_mi_thunk. * config/stormy16/stormy16.c (stormy16_asm_output_mi_thunk): New function. * config/stormy16/stormy16-protos.h (stormy16_asm_output_mi_thunk): New prototype. From-SVN: r46762
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/stormy16/stormy16-protos.h1
-rw-r--r--gcc/config/stormy16/stormy16.c45
-rw-r--r--gcc/config/stormy16/stormy16.h7
3 files changed, 47 insertions, 6 deletions
diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h
index 39a84537ca6..2e96055fa3c 100644
--- a/gcc/config/stormy16/stormy16-protos.h
+++ b/gcc/config/stormy16/stormy16-protos.h
@@ -46,6 +46,7 @@ extern void stormy16_expand_builtin_va_start PARAMS ((int, tree, rtx));
extern rtx stormy16_expand_builtin_va_arg PARAMS ((tree, tree));
extern void stormy16_initialize_trampoline PARAMS ((rtx, rtx, rtx));
extern rtx stormy16_function_value PARAMS ((tree, tree));
+extern void stormy16_asm_output_mi_thunk PARAMS ((FILE *, tree, int, tree));
#endif
#ifdef RTX_CODE
diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c
index 6b69e5c3341..ef4951d3262 100644
--- a/gcc/config/stormy16/stormy16.c
+++ b/gcc/config/stormy16/stormy16.c
@@ -1335,6 +1335,51 @@ stormy16_function_value (valtype, func)
return gen_rtx_REG (mode, RETURN_VALUE_REGNUM);
}
+/* A C compound statement that outputs the assembler code for a thunk function,
+ used to implement C++ virtual function calls with multiple inheritance. The
+ thunk acts as a wrapper around a virtual function, adjusting the implicit
+ object parameter before handing control off to the real function.
+
+ First, emit code to add the integer DELTA to the location that contains the
+ incoming first argument. Assume that this argument contains a pointer, and
+ is the one used to pass the `this' pointer in C++. This is the incoming
+ argument *before* the function prologue, e.g. `%o0' on a sparc. The
+ addition must preserve the values of all other incoming arguments.
+
+ After the addition, emit code to jump to FUNCTION, which is a
+ `FUNCTION_DECL'. This is a direct pure jump, not a call, and does not touch
+ the return address. Hence returning from FUNCTION will return to whoever
+ called the current `thunk'.
+
+ The effect must be as if @var{function} had been called directly
+ with the adjusted first argument. This macro is responsible for
+ emitting all of the code for a thunk function;
+ TARGET_ASM_FUNCTION_PROLOGUE and TARGET_ASM_FUNCTION_EPILOGUE are
+ not invoked.
+
+ The THUNK_FNDECL is redundant. (DELTA and FUNCTION have already been
+ extracted from it.) It might possibly be useful on some targets, but
+ probably not. */
+
+void
+stormy16_asm_output_mi_thunk (file, thunk_fndecl, delta, function)
+ FILE *file;
+ tree thunk_fndecl ATTRIBUTE_UNUSED;
+ int delta;
+ tree function;
+{
+ int regnum = FIRST_ARGUMENT_REGISTER;
+
+ /* There might be a hidden first argument for a returned structure. */
+ if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function))))
+ regnum += 1;
+
+ fprintf (file, "\tadd %s,#0x%x\n", reg_names[regnum], (delta) & 0xFFFF);
+ fputs ("\tjmpf ", file);
+ assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
+ putc ('\n', file);
+}
+
/* Mark functions with SYMBOL_REF_FLAG. */
void
diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h
index 7ca09e16efd..e3bedf56ba6 100644
--- a/gcc/config/stormy16/stormy16.h
+++ b/gcc/config/stormy16/stormy16.h
@@ -2435,12 +2435,7 @@ typedef int CUMULATIVE_ARGS;
FUNCTION instead of jumping to it. The generic approach does not support
varargs. */
#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
-{ \
- fprintf (FILE, "\tadd r2,#0x%x\n", (DELTA) & 0xFFFF); \
- fputs ("\tjmpf ", FILE); \
- assemble_name (FILE, XSTR (XEXP (DECL_RTL (function), 0), 0)); \
- putc ('\n', FILE); \
-}
+ stormy16_asm_output_mi_thunk (FILE, THUNK_FNDECL, DELTA, FUNCTION)
/* Generating Code for Profiling. */