linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: Handle removal of 'h' constraint in GCC 4.4
@ 2008-12-18  2:24 David Daney
  2008-12-19  0:46 ` Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: David Daney @ 2008-12-18  2:24 UTC (permalink / raw)
  To: linux-mips; +Cc: David Daney

This is an incomplete proof of concept that I applied to be able to
build a 64 bit kernel with GCC-4.4.  It doesn't handle the 32 bit case
or the R4000_WAR case.

Comments welcome.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/include/asm/compiler.h |    7 +++++++
 arch/mips/include/asm/delay.h    |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/mips/include/asm/compiler.h b/arch/mips/include/asm/compiler.h
index 71f5c5c..1f0954d 100644
--- a/arch/mips/include/asm/compiler.h
+++ b/arch/mips/include/asm/compiler.h
@@ -16,4 +16,11 @@
 #define GCC_REG_ACCUM "accum"
 #endif
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define GCC_NO_H_CONSTRAINT
+#ifdef CONFIG_64BIT
+typedef unsigned int uint128_t __attribute__((mode(TI)));
+#endif
+#endif
+
 #endif /* _ASM_COMPILER_H */
diff --git a/arch/mips/include/asm/delay.h b/arch/mips/include/asm/delay.h
index b0bccd2..3e467e8 100644
--- a/arch/mips/include/asm/delay.h
+++ b/arch/mips/include/asm/delay.h
@@ -83,10 +83,14 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)
 		: "r" (usecs), "r" (lpj)
 		: GCC_REG_ACCUM);
 	else if (sizeof(long) == 8 && !R4000_WAR)
+#ifdef GCC_NO_H_CONSTRAINT
+		usecs = ((uint128_t)usecs * lpj) >> 64;
+#else
 		__asm__("dmultu\t%2, %3"
 		: "=h" (usecs), "=l" (lo)
 		: "r" (usecs), "r" (lpj)
 		: GCC_REG_ACCUM);
+#endif
 	else if (sizeof(long) == 8 && R4000_WAR)
 		__asm__("dmultu\t%3, %4\n\tmfhi\t%0"
 		: "=r" (usecs), "=h" (hi), "=l" (lo)
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] MIPS: Handle removal of 'h' constraint in GCC 4.4
@ 2009-02-24 23:04 David Daney
  2009-02-25  1:25 ` Maciej W. Rozycki
  2009-02-26 16:58 ` Ralf Baechle
  0 siblings, 2 replies; 10+ messages in thread
From: David Daney @ 2009-02-24 23:04 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: David Daney

Due to the removal of the 'h' asm constraint in GCC-4.4, we need to
adjust the computation in delay.h

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---

Tested on 64-bit kernel (Cavium Octeon).

 arch/mips/include/asm/compiler.h |    7 +++++++
 arch/mips/include/asm/delay.h    |   10 +++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/arch/mips/include/asm/compiler.h b/arch/mips/include/asm/compiler.h
index 71f5c5c..1f0954d 100644
--- a/arch/mips/include/asm/compiler.h
+++ b/arch/mips/include/asm/compiler.h
@@ -16,4 +16,11 @@
 #define GCC_REG_ACCUM "accum"
 #endif
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define GCC_NO_H_CONSTRAINT
+#ifdef CONFIG_64BIT
+typedef unsigned int uint128_t __attribute__((mode(TI)));
+#endif
+#endif
+
 #endif /* _ASM_COMPILER_H */
diff --git a/arch/mips/include/asm/delay.h b/arch/mips/include/asm/delay.h
index b0bccd2..9be0ba7 100644
--- a/arch/mips/include/asm/delay.h
+++ b/arch/mips/include/asm/delay.h
@@ -62,8 +62,9 @@ static inline void __delay(unsigned long loops)
 
 static inline void __udelay(unsigned long usecs, unsigned long lpj)
 {
+#ifndef GCC_NO_H_CONSTRAINT
 	unsigned long hi, lo;
-
+#endif
 	/*
 	 * The rates of 128 is rounded wrongly by the catchall case
 	 * for 64-bit.  Excessive precission?  Probably ...
@@ -77,6 +78,12 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)
 	                           0x80000000ULL) >> 32);
 #endif
 
+#ifdef GCC_NO_H_CONSTRAINT
+	if (sizeof(long) == 4)
+		usecs = ((u64)usecs * lpj) >> 32;
+	else
+		usecs = ((uint128_t)usecs * lpj) >> 64;
+#else
 	if (sizeof(long) == 4)
 		__asm__("multu\t%2, %3"
 		: "=h" (usecs), "=l" (lo)
@@ -92,6 +99,7 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)
 		: "=r" (usecs), "=h" (hi), "=l" (lo)
 		: "r" (usecs), "r" (lpj)
 		: GCC_REG_ACCUM);
+#endif
 
 	__delay(usecs);
 }
-- 
1.5.6.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-05-28 16:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-18  2:24 [PATCH] MIPS: Handle removal of 'h' constraint in GCC 4.4 David Daney
2008-12-19  0:46 ` Maciej W. Rozycki
2008-12-27 15:19   ` Richard Sandiford
2009-05-28 11:31     ` Florian Fainelli
2009-05-28 14:31       ` Wu Zhangjin
2009-05-28 15:43         ` David Daney
2009-05-28 16:00           ` Florian Fainelli
  -- strict thread matches above, loose matches on Subject: below --
2009-02-24 23:04 David Daney
2009-02-25  1:25 ` Maciej W. Rozycki
2009-02-26 16:58 ` Ralf Baechle

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 NNTP newsgroup(s).