public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [patch 02/36][alpha] Hookize static chain and trampoline macros
Date: Mon, 21 Sep 2009 22:14:00 -0000	[thread overview]
Message-ID: <4AB7FA2A.2000603@redhat.com> (raw)
In-Reply-To: <4AB7F353.3060707@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

I merged the trampoline template into the trampoline initialization 
here.  The odd VMS parameters are gone, replaced by code directly in the 
VMS code block already in alpha_trampoline_init.


r~

[-- Attachment #2: d-tramp-02-alpha --]
[-- Type: text/plain, Size: 8901 bytes --]

	* config/alpha/alpha.c (alpha_trampoline_init): Rename from
	alpha_initialize_trampoline.  Make static.  Merge VMS parameter
	differences into the TARGET_ABI_OPEN_VMS code block.
	(TARGET_TRAMPOLINE_INIT): New.
	* config/alpha/alpha.h (TRAMPOLINE_TEMPLATE): Remove.
	(TRAMPOLINE_SECTION, INITIALIZE_TRAMPOLINE): Remove.
	* config/alpha/vms.h (TRAMPOLINE_SIZE, TRAMPOLINE_ALIGNMENT): Remove.
	(INITIALIZE_TRAMPOLINE): Remove.


diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 46ad8f4..86fd1ee 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5541,34 +5541,23 @@ print_operand_address (FILE *file, rtx addr)
 }
 \f
 /* Emit RTL insns to initialize the variable parts of a trampoline at
-   TRAMP. FNADDR is an RTX for the address of the function's pure
-   code.  CXT is an RTX for the static chain value for the function.
+   M_TRAMP.  FNDECL is target function's decl.  CHAIN_VALUE is an rtx
+   for the static chain value for the function.  */
 
-   The three offset parameters are for the individual template's
-   layout.  A JMPOFS < 0 indicates that the trampoline does not
-   contain instructions at all.
-
-   We assume here that a function will be called many more times than
-   its address is taken (e.g., it might be passed to qsort), so we
-   take the trouble to initialize the "hint" field in the JMP insn.
-   Note that the hint field is PC (new) + 4 * bits 13:0.  */
-
-void
-alpha_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt,
-			     int fnofs, int cxtofs, int jmpofs)
+static void
+alpha_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
 {
-  rtx addr;
-  /* VMS really uses DImode pointers in memory at this point.  */
-  enum machine_mode mode = TARGET_ABI_OPEN_VMS ? Pmode : ptr_mode;
+  rtx fnaddr, mem, word1, word2;
+
+  fnaddr = XEXP (DECL_RTL (fndecl), 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  fnaddr = convert_memory_address (mode, fnaddr);
-  cxt = convert_memory_address (mode, cxt);
+  fnaddr = convert_memory_address (Pmode, fnaddr);
+  chain_value = convert_memory_address (Pmode, chain_value);
 #endif
 
   if (TARGET_ABI_OPEN_VMS)
     {
-      rtx temp1, traddr;
       const char *fnname;
       char *trname;
 
@@ -5577,37 +5566,48 @@ alpha_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt,
       trname = (char *) alloca (strlen (fnname) + 5);
       strcpy (trname, fnname);
       strcat (trname, "..tr");
-      traddr = gen_rtx_SYMBOL_REF
-	(mode, ggc_alloc_string (trname, strlen (trname) + 1));
+      fnname = ggc_alloc_string (trname, strlen (trname) + 1);
+      word2 = gen_rtx_SYMBOL_REF (Pmode, fnname);
 
       /* Trampoline (or "bounded") procedure descriptor is constructed from
 	 the function's procedure descriptor with certain fields zeroed IAW
 	 the VMS calling standard. This is stored in the first quadword.  */
-      temp1 = force_reg (DImode, gen_rtx_MEM (DImode, fnaddr));
-      temp1 = expand_and (DImode, temp1,
-			  GEN_INT (0xffff0fff0000fff0), NULL_RTX);
-      addr = memory_address (mode, plus_constant (tramp, 0));
-      emit_move_insn (gen_rtx_MEM (DImode, addr), temp1);
-
-      /* Trampoline transfer address is stored in the second quadword
-	 of the trampoline.  */
-      addr = memory_address (mode, plus_constant (tramp, 8));
-      emit_move_insn (gen_rtx_MEM (mode, addr), traddr);
+      word1 = force_reg (DImode, gen_const_mem (DImode, fnaddr));
+      word1 = expand_and (DImode, word1, GEN_INT (0xffff0fff0000fff0), NULL);
     }
+  else
+    {
+      /* These 4 instructions are:
+	    ldq $1,24($27)
+	    ldq $27,16($27)
+	    jmp $31,($27),0
+	    nop
+	 We don't bother setting the HINT field of the jump; the nop
+	 is merely there for padding.  */
+      word1 = GEN_INT (0xa77b0010a43b0018);
+      word2 = GEN_INT (0x47ff041f6bfb0000);
+    }
+
+  /* Store the first two words, as computed above.  */
+  mem = adjust_address (m_tramp, DImode, 0);
+  emit_move_insn (mem, word1);
+  mem = adjust_address (m_tramp, DImode, 8);
+  emit_move_insn (mem, word2);
+
+  /* Store function address and static chain value.  */
+  mem = adjust_address (m_tramp, Pmode, 16);
+  emit_move_insn (mem, fnaddr);
+  mem = adjust_address (m_tramp, Pmode, 24);
+  emit_move_insn (mem, chain_value);
 
-  /* Store function address and CXT.  */
-  addr = memory_address (mode, plus_constant (tramp, fnofs));
-  emit_move_insn (gen_rtx_MEM (mode, addr), fnaddr);
-  addr = memory_address (mode, plus_constant (tramp, cxtofs));
-  emit_move_insn (gen_rtx_MEM (mode, addr), cxt);
-
+  if (!TARGET_ABI_OPEN_VMS)
+    {
+      emit_insn (gen_imb ());
 #ifdef ENABLE_EXECUTE_STACK
-  emit_library_call (init_one_libfunc ("__enable_execute_stack"),
-		     LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
+      emit_library_call (init_one_libfunc ("__enable_execute_stack"),
+			 LCT_NORMAL, VOIDmode, 1, XEXP (m_tramp, 0), Pmode);
 #endif
-
-  if (jmpofs >= 0)
-    emit_insn (gen_imb ());
+    }
 }
 \f
 /* Determine where to put an argument to a function.
@@ -11114,6 +11114,8 @@ alpha_init_libfuncs (void)
 #define TARGET_GIMPLIFY_VA_ARG_EXPR alpha_gimplify_va_arg
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES alpha_arg_partial_bytes
+#undef TARGET_TRAMPOLINE_INIT
+#define TARGET_TRAMPOLINE_INIT alpha_trampoline_init
 
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD alpha_secondary_reload
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index cd8c11e..6235d9f 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -838,28 +838,6 @@ extern int alpha_memory_latency;
 
 #define EPILOGUE_USES(REGNO)	((REGNO) == 26)
 \f
-/* Output assembler code for a block containing the constant parts
-   of a trampoline, leaving space for the variable parts.
-
-   The trampoline should set the static chain pointer to value placed
-   into the trampoline and should branch to the specified routine.
-   Note that $27 has been set to the address of the trampoline, so we can
-   use it for addressability of the two data items.  */
-
-#define TRAMPOLINE_TEMPLATE(FILE)		\
-do {						\
-  fprintf (FILE, "\tldq $1,24($27)\n");		\
-  fprintf (FILE, "\tldq $27,16($27)\n");	\
-  fprintf (FILE, "\tjmp $31,($27),0\n");	\
-  fprintf (FILE, "\tnop\n");			\
-  fprintf (FILE, "\t.quad 0,0\n");		\
-} while (0)
-
-/* Section in which to place the trampoline.  On Alpha, instructions
-   may only be placed in a text segment.  */
-
-#define TRAMPOLINE_SECTION text_section
-
 /* Length in units of the trampoline for entering a nested function.  */
 
 #define TRAMPOLINE_SIZE    32
@@ -868,13 +846,6 @@ do {						\
 
 #define TRAMPOLINE_ALIGNMENT  64
 
-/* Emit RTL insns to initialize the variable parts of a trampoline.
-   FNADDR is an RTX for the address of the function's pure code.
-   CXT is an RTX for the static chain value for the function.  */
-
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
-  alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, 8)
-
 /* A C expression whose value is RTL representing the value of the return
    address for the frame COUNT steps up from the current frame.
    FRAMEADDR is the frame pointer of the COUNT frame, or the frame pointer of
diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index ca90327..2773008 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -4869,7 +4869,7 @@
   "jmp $31,(%0),0"
   [(set_attr "type" "ibr")])
 
-;; Cache flush.  Used by INITIALIZE_TRAMPOLINE.  0x86 is PAL_imb, but we don't
+;; Cache flush.  Used by alpha_trampoline_init.  0x86 is PAL_imb, but we don't
 ;; want to have to include pal.h in our .s file.
 (define_insn "imb"
   [(unspec_volatile [(const_int 0)] UNSPECV_IMB)]
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index cb84a04..c0b20f8 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -225,26 +225,6 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
   vms_output_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN)
 \f
-#undef TRAMPOLINE_TEMPLATE
-
-/* Length in units of the trampoline for entering a nested function.  */
-
-#undef TRAMPOLINE_SIZE
-#define TRAMPOLINE_SIZE    32
-
-/* The alignment of a trampoline, in bits.  */
-
-#undef TRAMPOLINE_ALIGNMENT
-#define TRAMPOLINE_ALIGNMENT  64
-
-/* Emit RTL insns to initialize the variable parts of a trampoline.
-   FNADDR is an RTX for the address of the function's pure code.
-   CXT is an RTX for the static chain value for the function.  */
-
-#undef INITIALIZE_TRAMPOLINE
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
-  alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, -1)
-
 /* Control how constructors and destructors are emitted.  */
 #define TARGET_ASM_CONSTRUCTOR  vms_asm_out_constructor
 #define TARGET_ASM_DESTRUCTOR   vms_asm_out_destructor

  reply	other threads:[~2009-09-21 22:12 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-21 21:57 [patch 01/36] " Richard Henderson
2009-09-21 22:14 ` Richard Henderson [this message]
2009-09-21 22:17 ` [patch 03/36][arc] " Richard Henderson
2009-09-21 22:19 ` [patch 04/36][ARM] " Richard Henderson
2009-09-21 22:26 ` [patch 05/36][AVR] " Richard Henderson
2009-09-21 22:28 ` [patch 06/36][bfin] " Richard Henderson
2009-09-21 22:29 ` [patch 07/36][cris] " Richard Henderson
2009-09-22  2:31   ` Hans-Peter Nilsson
2009-09-21 22:30 ` [patch 08/36][crx] " Richard Henderson
2009-09-21 22:32 ` [patch 09/36][fr30] " Richard Henderson
2009-09-21 22:34 ` [patch 10/36][frv] " Richard Henderson
2009-09-21 22:35 ` [patch 11/36][h8] " Richard Henderson
2009-09-21 22:36 ` [patch 12/36][ia64] " Richard Henderson
2009-09-21 22:40 ` [patch 13/36][iq2000] " Richard Henderson
2009-09-21 22:41 ` [patch 14/36][m32c] " Richard Henderson
2009-09-21 22:49   ` DJ Delorie
2009-09-21 22:57     ` Richard Henderson
2009-09-21 23:00       ` DJ Delorie
2009-09-21 23:13         ` Richard Henderson
2009-09-21 23:18           ` DJ Delorie
2009-09-21 22:42 ` [patch 15/36][m68hc11] " Richard Henderson
2009-09-21 22:47 ` [patch 16/36][m68k] " Richard Henderson
2009-09-22 15:53   ` Richard Henderson
2009-09-21 22:50 ` [patch 17/36][mcore] " Richard Henderson
2009-09-21 22:52 ` [patch 18/36][mep] " Richard Henderson
2009-09-21 22:59 ` [patch 19/36][mips] " Richard Henderson
2009-09-22 18:19   ` Richard Sandiford
2009-09-21 23:01 ` [patch 20/36][mmix] " Richard Henderson
2009-09-22  2:03   ` Hans-Peter Nilsson
2009-09-21 23:04 ` [patch 21/36][mn10300] " Richard Henderson
2009-09-21 23:11   ` Richard Henderson
2009-09-22 20:53     ` Alexandre Oliva
2009-09-21 23:06 ` [patch 22/36][moxie] " Richard Henderson
2009-09-21 23:08 ` [patch 23/36][parisc] " Richard Henderson
2009-09-22  2:03   ` John David Anglin
2009-09-21 23:09 ` [patch 24/36][pdp11] " Richard Henderson
2009-09-22 18:31   ` Paul Koning
2009-09-21 23:10 ` [patch 25/36][picochip] " Richard Henderson
2009-09-21 23:14 ` [patch 26/36][rs6000] " Richard Henderson
2009-09-22  2:16   ` David Edelsohn
2009-09-21 23:16 ` [patch 27/36][s390] " Richard Henderson
2009-09-22 14:55   ` Andreas Krebbel
2009-09-21 23:21 ` [patch 28/36][score] " Richard Henderson
2009-09-22 11:02   ` 答复: " liqin
2009-09-22 13:58     ` Richard Henderson
2009-09-22 11:25   ` Paolo Bonzini
2009-09-21 23:22 ` [patch 29/36][sh] " Richard Henderson
2009-09-22 20:47   ` Alexandre Oliva
2009-09-21 23:22 ` [patch 30/36][sparc] " Richard Henderson
2009-09-22 13:09   ` Eric Botcazou
2009-09-21 23:26 ` [patch 31/36][spu] " Richard Henderson
2009-09-21 23:44   ` Andrew Pinski
2009-09-21 23:27 ` [patch 32/36][stormy16] " Richard Henderson
2009-09-21 23:30 ` [patch 33/36][v850] " Richard Henderson
2009-09-21 23:31 ` [patch 34/36][vax] " Richard Henderson
2009-09-21 23:35 ` [patch 35/36][xtensa] " Richard Henderson
2009-09-21 23:41 ` [patch 36/36][i386] " Richard Henderson
2009-09-23  0:37   ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AB7FA2A.2000603@redhat.com \
    --to=rth@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).