[3.1.1] x86-64 fixes

Jan Hubicka jh@suse.cz
Wed May 22 07:12:00 GMT 2002


Hi,
the attached patches as accumulated in our tree. All of them are x86-64
specific and has been extensivly tested in both i386 and x86-64
compilers.  OK for 3.1.1?

Honza
-------------- next part --------------
>From nobody Tue May 14 13:11:40 2002
Date: Tue, 14 May 2002 12:34:13 +0200
From: Jan Hubicka <jh@suse.cz>
To: Jan Hubicka <jh@suse.cz>
Cc: Andreas Jaeger <aj@suse.de>, Marcus Meissner <meissner@suse.de>,
	x86-64-suse@suse.de, Ruediger Oertel <ro@suse.de>,
	Thorsten Kukuk <kukuk@suse.de>, kde-maintainers@suse.de
Subject: Unwinding w/o -g
Message-ID: <20020514103413.GW6514@atrey.karlin.mff.cuni.cz>
References: <hoy9eni1yz.fsf@gee.suse.de> <Pine.LNX.4.33.0205141019200.29862-100000@Appserv.suse.de>
 <20020514103522.A732@suse.de> <hobsbji07q.fsf@gee.suse.de>
 <20020514111725.A29439@suse.de>
 <20020514092659.GQ6514@atrey.karlin.mff.cuni.cz>
 <ho3cwvgj7p.fsf@gee.suse.de>
 <20020514094206.GS6514@atrey.karlin.mff.cuni.cz>
MIME-Version: 1.0

Hi,
this should fix the eh_frame output so it is useable for debuging.

Tue May 14 12:32:10 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* dwarf2out.c (output_call_frame_info): Do not skip unwind info
	when flag_asynchronous_unwind_tables is set.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.356.2.9
diff -c -3 -p -r1.356.2.9 dwarf2out.c
*** dwarf2out.c	7 May 2002 17:27:30 -0000	1.356.2.9
--- dwarf2out.c	14 May 2002 10:32:04 -0000
*************** output_call_frame_info (for_eh)
*** 1943,1949 ****
        fde = &fde_table[i];
  
        /* Don't emit EH unwind info for leaf functions that don't need it.  */
!       if (for_eh && fde->nothrow && ! fde->uses_eh_lsda)
  	continue;
  
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);
--- 1943,1950 ----
        fde = &fde_table[i];
  
        /* Don't emit EH unwind info for leaf functions that don't need it.  */
!       if (!flag_asynchronous_unwind_tables && for_eh && fde->nothrow
! 	  && !  fde->uses_eh_lsda)
  	continue;
  
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);


-------------- next part --------------
Index: i386-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386-protos.h,v
retrieving revision 1.68
diff -c -3 -p -r1.68 i386-protos.h
*** i386-protos.h	7 Feb 2002 11:18:32 -0000	1.68
--- i386-protos.h	14 May 2002 09:25:57 -0000
*************** extern tree ix86_handle_shared_attribute
*** 197,200 ****
--- 197,201 ----
  extern unsigned int i386_pe_section_type_flags PARAMS ((tree, const char *,
  							int));
  extern void i386_pe_asm_named_section PARAMS ((const char *, unsigned int));
+ extern void x86_output_mi_thunk PARAMS ((FILE *, int, tree));
  #endif
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.368.2.9
diff -c -3 -p -r1.368.2.9 i386.c
*** i386.c	23 Apr 2002 08:11:22 -0000	1.368.2.9
--- i386.c	14 May 2002 09:25:58 -0000
*************** x86_order_regs_for_local_alloc ()
*** 12472,12475 ****
--- 12527,12605 ----
        at all.  */
     while (pos < FIRST_PSEUDO_REGISTER)
       reg_alloc_order [pos++] = 0;
+ }
+ 
+ void
+ x86_output_mi_thunk (file, delta, function)
+      FILE *file;
+      int delta;
+      tree function;
+ {
+   tree parm;
+   rtx xops[3];
+ 
+   if (ix86_regparm > 0)
+     parm = TYPE_ARG_TYPES (TREE_TYPE (function));
+   else
+     parm = NULL_TREE;
+   for (; parm; parm = TREE_CHAIN (parm))
+     if (TREE_VALUE (parm) == void_type_node)
+       break;
+ 
+   xops[0] = GEN_INT (delta);
+   if (TARGET_64BIT)
+     {
+       int n = aggregate_value_p (TREE_TYPE (TREE_TYPE (function))) != 0;
+       xops[1] = gen_rtx_REG (DImode, x86_64_int_parameter_registers[n]);
+       output_asm_insn ("add{q} {%0, %1|%1, %0}", xops);
+       if (flag_pic)
+ 	{
+ 	  fprintf (file, "\tjmp *");
+ 	  assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
+ 	  fprintf (file, "@GOTPCREL(%%rip)\n");
+ 	}
+       else
+ 	{
+ 	  fprintf (file, "\tjmp ");
+ 	  assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
+ 	  fprintf (file, "\n");
+ 	}
+     }
+   else
+     {
+       if (parm)
+ 	xops[1] = gen_rtx_REG (SImode, 0);
+       else if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function))))
+ 	xops[1] = gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx, 8));
+       else
+ 	xops[1] = gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx, 4));
+       output_asm_insn ("add{l} {%0, %1|%1, %0}", xops);
+ 
+       if (flag_pic)
+ 	{
+ 	  xops[0] = pic_offset_table_rtx;
+ 	  xops[1] = gen_label_rtx ();
+ 	  xops[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
+ 
+ 	  if (ix86_regparm > 2)
+ 	    abort ();
+ 	  output_asm_insn ("push{l}\t%0", xops);
+ 	  output_asm_insn ("call\t%P1", xops);
+ 	  ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (xops[1]));
+ 	  output_asm_insn ("pop{l}\t%0", xops);
+ 	  output_asm_insn
+ 	    ("add{l}\t{%2+[.-%P1], %0|%0, OFFSET FLAT: %2+[.-%P1]}", xops);
+ 	  xops[0] = gen_rtx_MEM (SImode, XEXP (DECL_RTL (function), 0));
+ 	  output_asm_insn
+ 	    ("mov{l}\t{%0@GOT(%%ebx), %%ecx|%%ecx, %0@GOT[%%ebx]}", xops);
+ 	  asm_fprintf (file, "\tpop{l\t%%ebx|\t%%ebx}\n");
+ 	  asm_fprintf (file, "\tjmp\t{*%%ecx|%%ecx}\n");
+ 	}
+       else
+ 	{
+ 	  fprintf (file, "\tjmp ");
+ 	  assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
+ 	  fprintf (file, "\n");
+ 	}
+     }
  }
Index: unix.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/unix.h,v
retrieving revision 1.19
diff -c -3 -p -r1.19 unix.h
*** unix.h	21 Sep 2001 12:55:18 -0000	1.19
--- unix.h	14 May 2002 09:25:58 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 79,135 ****
  
  /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
     Used for C++ multiple inheritance.  */
! #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION)	    \
! do {									    \
!   tree parm;								    \
!   rtx xops[3];								    \
! 									    \
!   if (ix86_regparm > 0)							    \
!     parm = TYPE_ARG_TYPES (TREE_TYPE (function));			    \
!   else									    \
!     parm = NULL_TREE;							    \
!   for (; parm; parm = TREE_CHAIN (parm))				    \
!     if (TREE_VALUE (parm) == void_type_node)				    \
!       break;								    \
! 									    \
!   xops[0] = GEN_INT (DELTA);						    \
!   if (parm)								    \
!     xops[1] = gen_rtx_REG (SImode, 0);					    \
!   else if (aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION))))	    \
!     xops[1] = gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx, 8));   \
!   else									    \
!     xops[1] = gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx, 4));   \
!   output_asm_insn ("add{l} {%0, %1|%1, %0}", xops);			    \
! 									    \
!   if (flag_pic && !TARGET_64BIT)					    \
!     {									    \
!       xops[0] = pic_offset_table_rtx;					    \
!       xops[1] = gen_label_rtx ();					    \
!       xops[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");        \
! 									    \
!       if (ix86_regparm > 2)						    \
! 	abort ();							    \
!       output_asm_insn ("push{l}\t%0", xops);				    \
!       output_asm_insn ("call\t%P1", xops);				    \
!       ASM_OUTPUT_INTERNAL_LABEL (FILE, "L", CODE_LABEL_NUMBER (xops[1]));   \
!       output_asm_insn ("pop{l}\t%0", xops);				    \
!       output_asm_insn ("add{l}\t{%2+[.-%P1], %0|%0, OFFSET FLAT: %2+[.-%P1]}", xops); \
!       xops[0] = gen_rtx_MEM (SImode, XEXP (DECL_RTL (FUNCTION), 0));	    \
!       output_asm_insn ("mov{l}\t{%0@GOT(%%ebx), %%ecx|%%ecx, %0@GOT[%%ebx]}",\
! 	               xops);						    \
!       asm_fprintf (FILE, "\tpop{l\t%%ebx|\t%%ebx}\n");			    \
!       asm_fprintf (FILE, "\tjmp\t{*%%ecx|%%ecx}\n");			    \
!     }									    \
!   else if (flag_pic && TARGET_64BIT)					    \
!     {									    \
!       fprintf (FILE, "\tjmp *");					    \
!       assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0));	    \
!       fprintf (FILE, "@GOTPCREL(%%rip)\n");				    \
!     }									    \
!   else									    \
!     {									    \
!       fprintf (FILE, "\tjmp ");						    \
!       assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0));	    \
!       fprintf (FILE, "\n");						    \
!     }									    \
! } while (0)
--- 79,83 ----
  
  /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
     Used for C++ multiple inheritance.  */
! #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
!     x86_output_mi_thunk (FILE, DELTA, FUNCTION);
-------------- next part --------------
>From gcc-patches-return-59309-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org Fri May 10 10:10:58 2002
Return-Path: <gcc-patches-return-59309-listarch-gcc-patches=gcc dot gnu dot org at gcc dot gnu dot org>
Delivered-To: listarch-gcc-patches at gcc dot gnu dot org
Received: (qmail 28517 invoked by alias); 10 May 2002 10:10:57 -0000
Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm
Precedence: bulk
List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>
List-Post: <mailto:gcc-patches at gcc dot gnu dot org>
List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org>
Sender: gcc-patches-owner at gcc dot gnu dot org
Delivered-To: mailing list gcc-patches at gcc dot gnu dot org
Received: (qmail 28505 invoked from network); 10 May 2002 10:10:55 -0000
Received: from unknown (HELO pluto.sonofthor.dk) (80.196.18.231)
  by sources dot redhat dot com with SMTP; 10 May 2002 10:10:55 -0000
Received: from pluto (localhost [127.0.0.1])
	by pluto dot sonofthor dot dk (Postfix on SuSE Linux 8 dot 0 (i386)) with ESMTP
	id 7EA9B24E38; Fri, 10 May 2002 12:19:23 +0200 (CEST)
Content-Type: text/plain;
  charset="us-ascii"
From: Bo Thorsen <bo at sonofthor dot dk>
To: Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org,
	patches at x86-64 dot org
Subject: Make x86-64 multilib work again
Date: Fri, 10 May 2002 12:19:23 +0200
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Message-Id: <200205101219.23056.bo@sonofthor.dk>

Currently x86-64 needs a --disable-multilib since the 
MD_FALLBACK_FRAME_STATE_FOR macro is taken as the same for x86 and x86-64. 
This patch just copies the macro from linux.h to linux64.h and does an ifdef 
to choose.

The reason I've done this is to minimize the possible trouble it would be to 
include linux.h in linux64.h which would be a better solution. Moving the 
macro to linux-shared.h might be better though.

Currently there is a bit of a mess in the x86-64 support of x86 multilib. At 
some point it will probably be possible to compile to both architectures from 
both architectures (given the right libs of course) like it is on sparc. But 
to do that in a clean fashion, we need a more strict separation between 32 
and 64 bit files and the stuff that's shared between them.

I have bootstrapped and regtested both x86 and x86-64 with the patch installed 
(linux64.h isn't used at all in x86, so obviously this is affected. But I did 
it just in case). I've also bootstrapped and regtested x86-64 without 
--disable-multilib - this wasn't possible without the patch.

Can I commit the patch to both mainline and branch?

2002-05-10  Bo Thorsen  <bo@suse.co.uk>

	* config/i386/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Copy the
	i386 version of it here, so multilib works again.

Index: config/i386/linux64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/linux64.h,v
retrieving revision 1.3.10.5
diff -u -r1.3.10.5 linux64.h
--- config/i386/linux64.h	26 Apr 2002 07:57:50 -0000	1.3.10.5
+++ config/i386/linux64.h	10 May 2002 08:54:15 -0000
@@ -76,6 +76,7 @@
 #include <sys/ucontext.h>
 #endif
 
+#ifdef __x86_64__
 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
   do {									\
     unsigned char *pc_ = (CONTEXT)->ra;					\
@@ -132,3 +133,58 @@
     (FS)->retaddr_column = 16;						\
     goto SUCCESS;							\
   } while (0)
+#else /* ifdef __x86_64__  */
+#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
+  do {									\
+    unsigned char *pc_ = (CONTEXT)->ra;					\
+    struct sigcontext *sc_;						\
+    long new_cfa_;							\
+									\
+    /* popl %eax ; movl $__NR_sigreturn,%eax ; int $0x80  */		\
+    if (*(unsigned short *)(pc_+0) == 0xb858				\
+	&& *(unsigned int *)(pc_+2) == 119				\
+	&& *(unsigned short *)(pc_+6) == 0x80cd)			\
+      sc_ = (CONTEXT)->cfa + 4;						\
+    /* movl $__NR_rt_sigreturn,%eax ; int $0x80  */			\
+    else if (*(unsigned char *)(pc_+0) == 0xb8				\
+	     && *(unsigned int *)(pc_+1) == 173				\
+	     && *(unsigned short *)(pc_+5) == 0x80cd)			\
+      {									\
+	struct rt_sigframe {						\
+	  int sig;							\
+	  struct siginfo *pinfo;					\
+	  void *puc;							\
+	  struct siginfo info;						\
+	  struct ucontext uc;						\
+	} *rt_ = (CONTEXT)->cfa;					\
+	sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;		\
+      }									\
+    else								\
+      break;								\
+									\
+    new_cfa_ = sc_->esp;						\
+    (FS)->cfa_how = CFA_REG_OFFSET;					\
+    (FS)->cfa_reg = 4;							\
+    (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;		\
+									\
+    /* The SVR4 register numbering macros aren't usable in libgcc.  */	\
+    (FS)->regs.reg[0].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[0].loc.offset = (long)&sc_->eax - new_cfa_;		\
+    (FS)->regs.reg[3].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[3].loc.offset = (long)&sc_->ebx - new_cfa_;		\
+    (FS)->regs.reg[1].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[1].loc.offset = (long)&sc_->ecx - new_cfa_;		\
+    (FS)->regs.reg[2].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[2].loc.offset = (long)&sc_->edx - new_cfa_;		\
+    (FS)->regs.reg[6].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[6].loc.offset = (long)&sc_->esi - new_cfa_;		\
+    (FS)->regs.reg[7].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[7].loc.offset = (long)&sc_->edi - new_cfa_;		\
+    (FS)->regs.reg[5].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[5].loc.offset = (long)&sc_->ebp - new_cfa_;		\
+    (FS)->regs.reg[8].how = REG_SAVED_OFFSET;				\
+    (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_;		\
+    (FS)->retaddr_column = 8;						\
+    goto SUCCESS;							\
+  } while (0)
+#endif /* ifdef __x86_64__  */


-- 

     Bo Thorsen                 |   Praestevejen 4
     Free software developer    |   5290 Marslev
     SuSE Labs                  |   Denmark

-------------- next part --------------
2002-05-02  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386.c (ix86_expand_int_movcc): Truncate to proper
	mode.

--- i386.c.jj	Tue Apr 23 20:33:42 2002
+++ i386.c	Thu May  2 13:41:30 2002
@@ -7966,7 +7966,9 @@ ix86_expand_int_movcc (operands)
 	code = LTU;
       else
 	code = GEU;
-      ix86_compare_op1 = GEN_INT (INTVAL (ix86_compare_op1) + 1);
+      ix86_compare_op1
+	= GEN_INT (trunc_int_for_mode (INTVAL (ix86_compare_op1) + 1,
+				       GET_MODE (ix86_compare_op0)));
     }
 
   start_sequence ();

-------------- next part --------------
Wed May 22 15:54:55 CEST 2002  Michael Matz
	* i386.md (movabsdi): Kill broken alternative.
Index: i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.339.2.6
diff -u -p -r1.339.2.6 i386.md
--- i386.md	20 Apr 2002 00:24:50 -0000	1.339.2.6
+++ i386.md	29 Apr 2002 14:51:12 -0000
@@ -2555,17 +2555,16 @@
 ;; We fake an second form of instruction to force reload to load address
 ;; into register when rax is not available
 (define_insn "*movabsdi_1_rex64"
-  [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
-	(match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
+  [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
+	(match_operand:DI 1 "nonmemory_operand" "a,er"))]
   "TARGET_64BIT"
   "@
    movabs{q}\t{%1, %P0|%P0, %1}
-   mov{q}\t{%1, %a0|%a0, %1}
-   movabs{q}\t{%1, %a0|%a0, %1}"
+   mov{q}\t{%1, %a0|%a0, %1}"
   [(set_attr "type" "imov")
-   (set_attr "modrm" "0,*,*")
-   (set_attr "length_address" "8,0,0")
-   (set_attr "length_immediate" "0,*,*")
+   (set_attr "modrm" "0,*")
+   (set_attr "length_address" "8,0")
+   (set_attr "length_immediate" "0,*")
    (set_attr "memory" "store")
    (set_attr "mode" "DI")])
 
-------------- next part --------------
Wed May 22 15:55:34 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* i386.c (dbx64_register_map): Fix typo
--- i386.c.typo	Mon Apr 29 17:33:32 2002
+++ i386.c	Mon Apr 29 13:04:12 2002
@@ -458,7 +458,7 @@
 int const dbx64_register_map[FIRST_PSEUDO_REGISTER] =
 {
   0, 1, 2, 3, 4, 5, 6, 7,		/* general regs */
-  33, 34, 35, 36, 37, 38, 39, 40	/* fp regs */
+  33, 34, 35, 36, 37, 38, 39, 40,	/* fp regs */
   -1, -1, -1, -1, -1,			/* arg, flags, fpsr, dir, frame */
   17, 18, 19, 20, 21, 22, 23, 24,	/* SSE */
   41, 42, 43, 44, 45, 46, 47, 48,       /* MMX */


More information about the Gcc-patches mailing list