Skip to content

Commit

Permalink
m68k: use kernel processor defines for conditional optimizations
Browse files Browse the repository at this point in the history
Older m68k-linux compilers will include pre-defined symbols that
confuse what processor it is being targeted for. For example gcc-4.1.2
will pre-define __mc68020__ even if you specify the target processor
as -m68000 on the gcc command line. Newer versions of gcc have this
corrected.

In a few places the m68k code uses defined(__mc68020__) for optimizations
that include instructions that are specific to the CPU 68020 and above.
When compiling with older compilers this will be true even when we have
selected to compile for the older 68000 processors.

Switch to using the kernel processor defines, CONFIG_M68020 and friends.

Signed-off-by: Greg Ungerer <[email protected]>
  • Loading branch information
gregungerer committed Jun 14, 2011
1 parent 6235672 commit 734c3ce
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
3 changes: 1 addition & 2 deletions arch/m68k/kernel/m68k_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ EXPORT_SYMBOL(__ashrdi3);
EXPORT_SYMBOL(__lshrdi3);
EXPORT_SYMBOL(__muldi3);

#if !defined(__mc68020__) && !defined(__mc68030__) && \
!defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcpu32__)
#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
/*
* Simpler 68k and ColdFire parts also need a few other gcc functions.
*/
Expand Down
9 changes: 4 additions & 5 deletions arch/m68k/lib/memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ void *memcpy(void *to, const void *from, size_t n)
if (temp) {
long *lto = to;
const long *lfrom = from;
#if defined(__mc68020__) || defined(__mc68030__) || \
defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)
#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
for (; temp; temp--)
*lto++ = *lfrom++;
#else
asm volatile (
" movel %2,%3\n"
" andw #7,%3\n"
Expand All @@ -56,9 +58,6 @@ void *memcpy(void *to, const void *from, size_t n)
" jpl 4b"
: "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
: "0" (lfrom), "1" (lto), "2" (temp));
#else
for (; temp; temp--)
*lto++ = *lfrom++;
#endif
to = lto;
from = lfrom;
Expand Down
9 changes: 4 additions & 5 deletions arch/m68k/lib/memset.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ void *memset(void *s, int c, size_t count)
temp = count >> 2;
if (temp) {
long *ls = s;
#if defined(__mc68020__) || defined(__mc68030__) || \
defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)
#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
for (; temp; temp--)
*ls++ = c;
#else
size_t temp1;
asm volatile (
" movel %1,%2\n"
Expand All @@ -55,9 +57,6 @@ void *memset(void *s, int c, size_t count)
" jpl 1b"
: "=a" (ls), "=d" (temp), "=&d" (temp1)
: "d" (c), "0" (ls), "1" (temp));
#else
for (; temp; temp--)
*ls++ = c;
#endif
s = ls;
}
Expand Down
21 changes: 10 additions & 11 deletions arch/m68k/lib/muldi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,7 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */

#if defined(__mc68020__) || defined(__mc68030__) || \
defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)

#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulu%.l %3,%1:%0" \
: "=d" ((USItype)(w0)), \
"=d" ((USItype)(w1)) \
: "%0" ((USItype)(u)), \
"dmi" ((USItype)(v)))

#else
#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)

#define SI_TYPE_SIZE 32
#define __BITS4 (SI_TYPE_SIZE / 4)
Expand Down Expand Up @@ -61,6 +51,15 @@ Boston, MA 02111-1307, USA. */
(w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
} while (0)

#else

#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulu%.l %3,%1:%0" \
: "=d" ((USItype)(w0)), \
"=d" ((USItype)(w1)) \
: "%0" ((USItype)(u)), \
"dmi" ((USItype)(v)))

#endif

#define __umulsidi3(u, v) \
Expand Down

0 comments on commit 734c3ce

Please sign in to comment.