Skip to contentSkip to conversation

Asm hack for GCC 3.4 changes

PATCH Clark Williams 2 participants 3 messages Oct 6, 2004 MIPS

lore
Share & tools
lore
#0 lore raw

Ralf,

This is a patch I use on MIPS trees to deal with the changes in the way GCC 3.4 handles the 'accum' pseudo register in inline asms. I originally just applied it to time.c, but then I noticed that cpu-bugs64.c had an inline asm that referenced 'accum', so I lifted the conditional macro def to cpu.h, which was the only common header between time.c and cpu-bugs64.c. Not really sure it's appropriate for cpu.h, but I didn't want to create a new header.

Hope it's useful.

Clark

asm-mips/cpu.h renamed from asm-mips/cpu.h.orig +10 -0
@@ -219,4 +219,14 @@
 #define MIPS_CPU_SUBSET_CACHES	0x00020000 /* P-cache subset enforced */
 #define MIPS_CPU_PREFETCH	0x00040000 /* CPU has usable prefetch */
 
+// hack for GCC 3.4 inline asm change
+
+#if __GNUC__ == 3 && __GNUC_MINOR__ < 4
+#define CLOBBER_LO "lo","accum"
+#define CLOBBER_HILO "hi", "lo", "accum"
+#else
+#define CLOBBER_LO "lo"
+#define CLOBBER_HILO "hi", "lo"
+#endif
+
 #endif /* _ASM_CPU_H */
mips/kernel/time.c renamed from mips/kernel/time.c.orig +4 -4
@@ -277,7 +277,7 @@
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (sll32_usecs_per_cycle)
-		: "lo", "accum");
+		: CLOBBER_LO);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -332,7 +332,7 @@
 	__asm__("multu  %1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: CLOBBER_LO);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
@@ -374,7 +374,7 @@
 				: "r" (timerhi), "m" (timerlo),
 				  "r" (tmp), "r" (USECS_PER_JIFFY),
 				  "r" (USECS_PER_JIFFY_FRAC)
-				: "hi", "lo", "accum");
+				: CLOBBER_HILO);
 			cached_quotient = quotient;
 		}
 	}
@@ -388,7 +388,7 @@
 	__asm__("multu	%1,%2"
 		: "=h" (res)
 		: "r" (count), "r" (quotient)
-		: "lo", "accum");
+		: CLOBBER_LO);
 
 	/*
 	 * Due to possible jiffies inconsistencies, we need to check
mips/kernel/cpu-bugs64.c renamed from mips/kernel/cpu-bugs64.c.orig +1 -1
@@ -82,7 +82,7 @@
 		".set	pop"
 		: "=&r" (lv1), "=r" (lw)
 		: "r" (m1), "r" (m2), "r" (s), "I" (0)
-		: "hi", "lo", "accum");
+		: CLOBBER_HILO);
 	/* We have to use single integers for m1 and m2 and a double
 	 * one for p to be sure the mulsidi3 gcc's RTL multiplication
 	 * instruction has the workaround applied.  Older versions of
#1 lore raw
Quoted 9 lines · Clark Williams

This is a patch I use on MIPS trees to deal with the changes in the way GCC 3.4 handles the 'accum' pseudo register in inline asms. I originally just applied it to time.c, but then I noticed that cpu-bugs64.c had an inline asm that referenced 'accum', so I lifted the conditional macro def to cpu.h, which was the only common header between time.c and cpu-bugs64.c. Not really sure it's appropriate for cpu.h, but I didn't want to create a new header.

Hope it's useful.

I was actually waiting for somebody else to commit a similar but more complete patch into CVS. His patch was a little more complete but your's is a bit more stylish ...

Thanks,

Ralf

#2 lore raw
Quoted 5 lines · Ralf Baechle
Quoted 1 line

Hope it's useful.

I was actually waiting for somebody else to commit a similar but more complete patch into CVS. His patch was a little more complete but your's is a bit more stylish ...

So, what you're saying is that the German judge scored me big on artistic merit, but my technical score wasn't high enough for a gold medal?

:)

Clark