This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: target/6788: multiple inheritance "non-virtual thunk" assemblyincorrect on sparc64-sun-solars2.8


   From: Brad Spencer <spencer@infointeractive.com>
   Date: Fri, 24 May 2002 12:11:14 -0300

   I have been able to work around this bug by patching gas-2.12.1 as
   shown below.  I still suspect that this is a gcc bug, because I can't
   see why the assembler would be wrong about "set" not taking negative
   values.  Isn't that what "setsw" is for?
   
Right.  But there are other bugs in how gas implements
setx and friends, so best not to even attempt to use it.

I attach a fix for your bug below, I'm having other problems
with your test case after my patch but at least the thunks
are output correctly.

Try to use setx with current binutils results in junk like:

? cat x.s
        .globl  foo
foo:    setx    0x81928192, %o0
? as -Av9a -o x.o x.s
x.s: Assembler messages:
x.s:2: Error: Illegal operands
x.s:2: Warning: setx: temporary register same as destination register
? 

You can use just about whatever destination register you like, GAS
still says that the temporary register conflicts :-)

Anywhere, here is my gcc thunk fix for sparc64.  It also fixes
the warning your testcase generates when generating 32-bit sparc
code.

2002-05-23  David S. Miller  <davem@redhat.com>

	* config/sparc/sparc.h (ASM_OUTPUT_MI_THUNK): Handle negative
	DELTA correctly when TARGET_ARCH64.

--- config/sparc/sparc.h.~1~	Thu May 16 03:00:42 2002
+++ config/sparc/sparc.h	Thu May 23 23:55:23 2002
@@ -2916,8 +2916,21 @@ do {									\
       && aggregate_value_p (TREE_TYPE (TREE_TYPE (FUNCTION))))		\
     reg = 1;								\
   if ((DELTA) >= 4096 || (DELTA) < -4096)				\
-    fprintf (FILE, "\tset\t%d, %%g1\n\tadd\t%%o%d, %%g1, %%o%d\n",	\
-	     (int)(DELTA), reg, reg);					\
+    {									\
+      if ((DELTA) < 0 && TARGET_ARCH64)					\
+        fprintf (FILE,							\
+		 "\tsethi\t%%hi(%d), %%g1\n"				\
+                 "\txor\t%%g1, %%lo(%d), %%g1\n",			\
+		 ~((int)(DELTA)),					\
+		 (-0x400 | ((int)(DELTA) & 0x3ff)));			\
+      else								\
+        fprintf (FILE,							\
+		 "\tsethi\t%%hi(%d), %%g1\n"				\
+                 "\tor\t%%g1, %%lo(%d), %%g1\n",			\
+		 (int)(DELTA), (int)(DELTA));				\
+      fprintf (FILE, "\tadd\t%%o%d, %%g1, %%o%d\n",			\
+	       reg, reg);						\
+    }									\
   else									\
     fprintf (FILE, "\tadd\t%%o%d, %d, %%o%d\n", reg, (int)(DELTA), reg);\
   fprintf (FILE, "\tor\t%%o7, %%g0, %%g1\n");				\


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