This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH]: Trampoline for 68HC11/68HC12


Hi!

The following patch adds the support for trampoline code generation
for 68HC11 and 68HC12.

I've committed this patch on mainline and 3_0-branch.

	Stephane

2001-05-03  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* config/m68hc11/m68hc11.h (STATIC_CHAIN_REGNUM): Use soft z register
	instead of _.d1.
	(INITIALIZE_TRAMPOLINE): Call it.
	(TRAMPOLINE_SIZE): Define according to 68HC11/68HC12.
	(TRAMPOLINE_TEMPLATE): Remove.
	* config/m68hc11/m68hc11.c (m68hc11_initialize_trampoline): New.
	* config/m68hc11/m68hc11-protos.h (m68hc11_initialize_trampoline):
	Declare.
Index: config/m68hc11/m68hc11-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11-protos.h,v
retrieving revision 1.3
diff -u -p -r1.3 m68hc11-protos.h
--- m68hc11-protos.h	2001/05/03 19:56:46	1.3
+++ m68hc11-protos.h	2001/05/03 20:37:30
@@ -39,6 +39,8 @@ extern int m68hc11_block_profiler PARAMS
 extern void m68hc11_asm_file_start PARAMS((FILE*, char*));
 
 #ifdef TREE_CODE
+extern void m68hc11_initialize_trampoline PARAMS((rtx, rtx, rtx));
+
 extern void m68hc11_function_arg_advance PARAMS((CUMULATIVE_ARGS*,
                                                  enum machine_mode,
                                                  tree,
Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.6
diff -u -p -r1.6 m68hc11.c
--- m68hc11.c	2001/05/03 19:56:46	1.6
+++ m68hc11.c	2001/05/03 20:37:43
@@ -1056,6 +1056,54 @@ m68hc11_function_block_profiler (out, bl
 {
   return 0;
 }
+
+/* Emit the code to build the trampoline used to call a nested function.
+   
+   68HC11               68HC12
+
+   ldy #&CXT            movw #&CXT,*_.d1
+   sty *_.d1            jmp FNADDR
+   jmp FNADDR
+
+*/
+void
+m68hc11_initialize_trampoline (tramp, fnaddr, cxt)
+     rtx tramp;
+     rtx fnaddr;
+     rtx cxt;
+{
+  char *static_chain_reg = reg_names[STATIC_CHAIN_REGNUM];
+
+  /* Skip the '*'.  */
+  if (*static_chain_reg == '*')
+    static_chain_reg++;
+  if (TARGET_M6811)
+    {
+      emit_move_insn (gen_rtx_MEM (HImode, tramp), GEN_INT (0x18ce));
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 2)), cxt);
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 4)),
+                      GEN_INT (0x18df));
+      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 6)),
+                      gen_rtx_CONST (QImode,
+                                     gen_rtx_SYMBOL_REF (Pmode,
+                                                         static_chain_reg)));
+      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 7)),
+                      GEN_INT (0x7e));
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 8)), fnaddr);
+    }
+  else
+    {
+      emit_move_insn (gen_rtx_MEM (HImode, tramp), GEN_INT (0x1803));
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 2)), cxt);
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 4)),
+                      gen_rtx_CONST (HImode,
+                                     gen_rtx_SYMBOL_REF (Pmode,
+                                                         static_chain_reg)));
+      emit_move_insn (gen_rtx_MEM (QImode, plus_constant (tramp, 6)),
+                      GEN_INT (0x06));
+      emit_move_insn (gen_rtx_MEM (HImode, plus_constant (tramp, 7)), fnaddr);
+    }
+}
 
 /* Declaration of types.  */
 
Index: config/m68hc11/m68hc11.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11.h,v
retrieving revision 1.6
diff -u -p -r1.6 m68hc11.h
--- m68hc11.h	2001/05/03 19:56:46	1.6
+++ m68hc11.h	2001/05/03 20:37:52
@@ -714,6 +714,9 @@ enum reg_class
 #define Y_REGNO_P(REGNO)        ((REGNO) == HARD_Y_REGNUM)
 #define Y_REG_P(X)              (REG_P (X) && Y_REGNO_P (REGNO (X)))
 
+#define Z_REGNO_P(REGNO)        ((REGNO) == HARD_Z_REGNUM)
+#define Z_REG_P(X)              (REG_P (X) && Z_REGNO_P (REGNO (X)))
+
 #define SP_REGNO_P(REGNO)       ((REGNO) == HARD_SP_REGNUM)
 #define SP_REG_P(X)             (REG_P (X) && SP_REGNO_P (REGNO (X)))
 
@@ -932,7 +935,7 @@ extern int m68hc11_sp_correction;
 #define ARG_POINTER_REGNUM		SOFT_AP_REGNUM
 
 /* Register in which static-chain is passed to a function.  */
-#define STATIC_CHAIN_REGNUM	        SOFT_REG_FIRST
+#define STATIC_CHAIN_REGNUM	        SOFT_Z_REGNUM
 
 
 /* Definitions for register eliminations.
@@ -975,8 +978,6 @@ extern int m68hc11_sp_correction;
 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)			\
     { OFFSET = m68hc11_initial_elimination_offset (FROM, TO); }
 
-/* LONGJMP_RESTORE_FROM_STACK */
-
 
 /* Passing Function Arguments on the Stack.  */
 
@@ -1183,21 +1184,17 @@ typedef struct m68hc11_args
     asm ("puly");	       \
   }
 
-/* Output assembler code for a block containing the constant parts
-   of a trampoline, leaving space for the variable parts.  */
-#define TRAMPOLINE_TEMPLATE(FILE) { \
-  fprintf (FILE, "\t.bogus\t\t; TRAMPOLINE_TEMPLATE unimplemented\n"); }
-
 /* Length in units of the trampoline for entering a nested function.  */
-#define TRAMPOLINE_SIZE		0
+#define TRAMPOLINE_SIZE		(TARGET_M6811 ? 11 : 9)
 
 /* A C statement to initialize the variable parts of a trampoline.
    ADDR is an RTX for the address of the trampoline; FNADDR is an
    RTX for the address of the nested function; STATIC_CHAIN is an
    RTX for the static chain value that should be passed to the
    function when it is called.  */
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) { \
-	}
+#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
+  m68hc11_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
+
 
 
 /* If defined, a C expression whose value is nonzero if IDENTIFIER

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]