PATCH for rs6000.c (was: Re: Results for egcs-2.92.18 19981103 (gcc2 ss-980609 experimental) testsuite on powerpc-redhat-linux-gnu

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Thu Nov 19 14:46:00 GMT 1998


Am Tue, 17 Nov 1998 schrieb David Edelsohn:
>I applied this patch and also fixed another part of that
>implementation that has been bothering me.
>
>David
>
>	P.S. Mike, you seem to have the test for local branch #if'ed out.
>I changed TREE_ASM_WRITTEN to current_file_function_operand() which is
>more accurate (used for the same purpose in Alpha implementation).  You
>might see if this addresses your problem.

Ok, I enabled Michaels code and came up with a patch. It's probably not
acceptable, but it shows what goes wrong. rs6000_output_load_toc_table() won't
output a label LCLx unless rs6000_pic_func_labelno != rs6000_pic_labelno. I
added a flag to the call to be able to force the generation of LCLx labels.
This produces a seemingly working output_mi_thunk() and the g++ testsuite passed
with 0 (zero!) failures.

Franz.


Index: rs6000.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.48
diff -u -p -r1.48 rs6000.c
--- rs6000.c	1998/11/16 15:00:08	1.48
+++ rs6000.c	1998/11/19 22:16:13
@@ -3733,9 +3733,10 @@ debug_stack_info (info)
    a constant pool.  */
 
 void
-rs6000_output_load_toc_table (file, reg)
+rs6000_output_load_toc_table (file, reg, force)
      FILE *file;
      int reg;
+     int force;
 {
   char buf[256];
 
@@ -3759,7 +3760,7 @@ rs6000_output_load_toc_table (file, reg)
 	 after the bl.  It will mess up disassembling the instructions
 	 but that can't be helped.  We will later need to bias the
 	 address before loading.  */
-      if (rs6000_pic_func_labelno != rs6000_pic_labelno)
+      if (rs6000_pic_func_labelno != rs6000_pic_labelno || force)
 	{
 	  char *init_ptr = TARGET_32BIT ? ".long" : ".quad";
 	  char *buf_ptr;
@@ -3777,7 +3778,7 @@ rs6000_output_load_toc_table (file, reg)
       ASM_OUTPUT_INTERNAL_LABEL (file, "LCF", rs6000_pic_labelno);
       fprintf (file, "\tmflr %s\n", reg_names[reg]);
 
-      if (rs6000_pic_func_labelno != rs6000_pic_labelno)
+      if (rs6000_pic_func_labelno != rs6000_pic_labelno || force)
 	  asm_fprintf(file, "\t{cal|la} %s,%d(%s)\n", reg_names[reg],
 		      (TARGET_32BIT ? 4 : 8), reg_names[reg]);
 
@@ -4112,7 +4113,7 @@ output_prolog (file, size)
       if (!profile_flag)
 	rs6000_pic_func_labelno = rs6000_pic_labelno;
 #endif
-      rs6000_output_load_toc_table (file, 30);
+      rs6000_output_load_toc_table (file, 30, 0);
     }
 
   if (DEFAULT_ABI == ABI_NT)
@@ -4550,7 +4551,7 @@ output_mi_thunk (file, thunk_fndecl, del
      Otherwise, load up its address and jump to it.  */
 
   fname = XSTR (XEXP (DECL_RTL (function), 0), 0);
-#if 1
+#if 0
   /* For now, just emit a branch always, until we can figure out better when we
      need to load the address into the count register and emit the slower bctr
      instruction.  */
@@ -4559,8 +4560,7 @@ output_mi_thunk (file, thunk_fndecl, del
   fprintf (file, "\n");
 
 #else
-  if (current_file_function_operand (XEXP (DECL_RTL (function), 0))
-      && !lookup_attribute ("longcall", TYPE_ATTRIBUTES (TREE_TYPE (function))))
+  if (current_file_function_operand (XEXP (DECL_RTL (function), 0)))
     {
       fprintf (file, "\tb %s", prefix);
       assemble_name (file, fname);
@@ -4633,7 +4633,7 @@ output_mi_thunk (file, thunk_fndecl, del
 	      fprintf (file, "\tmflr %s\n", r0);
 	      asm_fprintf (file, "\t{st|stw} %s,4(%s)\n", r0, sp);
 	      rs6000_pic_func_labelno = rs6000_pic_labelno;
-	      rs6000_output_load_toc_table (file, 12);
+	      rs6000_output_load_toc_table (file, 12, 1);
 	      asm_fprintf (file, "\t{l|lwz} %s,", r0);
 	      assemble_name (file, buf);
 	      asm_fprintf (file, "(%s)\n", r12);
@@ -5010,7 +5010,7 @@ output_function_profiler (file, labelno)
 	  asm_fprintf (file, "\t{st|stw} %s,4(%s)\n",
 		       reg_names[0], reg_names[1]);
 	  rs6000_pic_func_labelno = rs6000_pic_labelno;
-	  rs6000_output_load_toc_table (file, 12);
+	  rs6000_output_load_toc_table (file, 12, 0);
 	  asm_fprintf (file, "\t{l|lwz} %s,", reg_names[12]);
 	  assemble_name (file, buf);
 	  asm_fprintf (file, "X(%s)\n", reg_names[12]);
Index: rs6000.md
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.31
diff -u -p -r1.31 rs6000.md
--- rs6000.md	1998/11/13 19:57:13	1.31
+++ rs6000.md	1998/11/19 22:16:15
@@ -7288,7 +7288,7 @@
   "TARGET_TOC && TARGET_MINIMAL_TOC"
   "*
 {
-  rs6000_output_load_toc_table (asm_out_file, 30);
+  rs6000_output_load_toc_table (asm_out_file, 30, 0);
   return \"\";
 }"
   [(set_attr "type" "load")])


More information about the Gcc-patches mailing list