[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] MiNTLib for ColdFire
Here is a patch for adding ColdFire compatibility to all the C and H files
of the MiNTLib. I used "clean" macros and #ifdef's to change the
incompatible instructions inside inline assembly. The produced code will
remain strictly unchanged on 680x0 targets, there will be no regression.
Alan, could you commit, please ?
NB: There are still 10 full assembler files which requires patching.
--
Vincent Rivière
diff -aurN -x CVS mintlib.orig/ChangeLog mintlib/ChangeLog
--- mintlib.orig/ChangeLog 2009-05-17 18:13:05.750000000 +0200
+++ mintlib/ChangeLog 2009-05-17 23:57:14.841824200 +0200
@@ -1,3 +1,11 @@
+2009-05-17 Sunday 23:57 Vincent Riviere <vincent.riviere@freesbee.fr>
+
+ * mintlib/include/compiler.h, mintlib/include/macros.h,
+ mintlib/include/mint/linea.h, mintlib/include/mint/mintbind.h,
+ mintlib/include/mint/osbind.h, mintlib/mintlib/linea.c
+
+ Added ColdFire support for all the C files.
+
2009-05-14 Thursday 23:37 Vincent Riviere <vincent.riviere@freesbee.fr>
* include/macros.h, include/bits/byteswap.h, include/bits/math-68881.h,
diff -aurN -x CVS mintlib.orig/include/compiler.h mintlib/include/compiler.h
--- mintlib.orig/include/compiler.h 2005-12-06 20:27:53.000000000 +0100
+++ mintlib/include/compiler.h 2009-05-17 22:42:51.312500000 +0200
@@ -62,6 +62,32 @@
# define __CLOBBER_RETURN(a) a,
#endif
+#ifdef __mcoldfire__
+
+#define ADDQ_SP(n) \
+ "addql #" #n ",sp\n\t"
+
+#define PUSH_SP(regs,size) \
+ "lea sp@(-" #size "),sp\n\t" \
+ "movml " regs ",sp@\n\t"
+
+#define POP_SP(regs,size) \
+ "movml sp@," regs "\n\t" \
+ "lea sp@(" #size "),sp\n\t"
+
+#else
+
+#define ADDQ_SP(n) \
+ "addqw #" #n ",sp\n\t"
+
+#define PUSH_SP(regs,size) \
+ "movml " regs ",sp@-\n\t"
+
+#define POP_SP(regs,size) \
+ "movml sp@+," regs "\n\t"
+
+#endif
+
#endif /* __GNUC__ */
/* some default declarations */
diff -aurN -x CVS mintlib.orig/include/macros.h mintlib/include/macros.h
--- mintlib.orig/include/macros.h 2009-05-17 18:13:06.156250000 +0200
+++ mintlib/include/macros.h 2009-05-17 18:34:15.781250000 +0200
@@ -64,7 +64,7 @@
The same macros are available with a 1 appended. Semantics are
the same except that offset is always 1. */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__mcoldfire__)
#define ROLL(offset, x) \
({ unsigned long __arg = (x); \
__asm__ ("roll %2,%1": "=r" (__arg) : "0" (__arg), "d" (offset)); \
diff -aurN -x CVS mintlib.orig/include/mint/linea.h mintlib/include/mint/linea.h
--- mintlib.orig/include/mint/linea.h 2009-05-17 18:13:06.250000000 +0200
+++ mintlib/include/mint/linea.h 2009-05-17 22:19:46.765625000 +0200
@@ -849,10 +849,10 @@
({ \
__asm__ volatile \
( \
- "movml d2/a2/a6,sp@-\n\t" \
+ PUSH_SP("d2/a2/a6", 12) \
"movl %0,a6\n\t" \
".word 0xA007\n\t" \
- "movml sp@+,d2/a2/a6" \
+ POP_SP("d2/a2/a6", 12) \
: /* outputs */ \
: "r"(P) /* inputs */ \
: "d0", "d1", "a0", "a1" /* clobbered regs */ \
diff -aurN -x CVS mintlib.orig/include/mint/mintbind.h mintlib/include/mint/mintbind.h
--- mintlib.orig/include/mint/mintbind.h 2009-05-17 18:13:06.265625000 +0200
+++ mintlib/include/mint/mintbind.h 2009-05-17 19:20:17.000000000 +0200
@@ -77,7 +77,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #8,sp" \
+ ADDQ_SP(8) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b), "r"(_c) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -123,7 +123,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #8,sp" \
+ ADDQ_SP(8) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
diff -aurN -x CVS mintlib.orig/include/mint/osbind.h mintlib/include/mint/osbind.h
--- mintlib.orig/include/mint/osbind.h 2009-05-17 18:13:06.265625000 +0200
+++ mintlib/include/mint/osbind.h 2009-05-17 22:59:13.826199200 +0200
@@ -140,7 +140,7 @@
( \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #2,sp\n\t" \
+ ADDQ_SP(2) \
: "=r"(retvalue) /* outputs */ \
: "g"(n) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -160,7 +160,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #4,sp" \
+ ADDQ_SP(4) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -180,7 +180,7 @@
"movl %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -202,7 +202,7 @@
"movl %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #8,sp" \
+ ADDQ_SP(8) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -297,7 +297,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #1\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -389,7 +389,7 @@
"movl %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #13\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -407,7 +407,7 @@
( \
"movw %1,sp@-\n\t" \
"trap #13\n\t" \
- "addqw #2,sp" \
+ ADDQ_SP(2) \
: "=r"(retvalue) /* outputs */ \
: "g"(n) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -427,7 +427,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #13\n\t" \
- "addqw #4,sp" \
+ ADDQ_SP(4) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -449,7 +449,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #13\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -499,7 +499,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #13\n\t" \
- "addqw #8,sp" \
+ ADDQ_SP(8) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -521,7 +521,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #14\n\t" \
- "addqw #8,sp" \
+ ADDQ_SP(8) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -565,7 +565,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #14\n\t" \
- "addqw #4,sp" \
+ ADDQ_SP(4) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -583,7 +583,7 @@
( \
"movw %1,sp@-\n\t" \
"trap #14\n\t" \
- "addqw #2,sp" \
+ ADDQ_SP(2) \
: "=r"(retvalue) /* outputs */ \
: "g"(n) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -627,7 +627,7 @@
"movl %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #14\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
@@ -649,7 +649,7 @@
"movw %2,sp@-\n\t" \
"movw %1,sp@-\n\t" \
"trap #14\n\t" \
- "addqw #6,sp" \
+ ADDQ_SP(6) \
: "=r"(retvalue) /* outputs */ \
: "g"(n), "r"(_a), "r"(_b) /* inputs */ \
: __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \
diff -aurN -x CVS mintlib.orig/mintlib/linea.c mintlib/mintlib/linea.c
--- mintlib.orig/mintlib/linea.c 2009-05-17 18:13:06.562500000 +0200
+++ mintlib/mintlib/linea.c 2009-05-17 22:20:37.203125000 +0200
@@ -99,10 +99,10 @@
{
__asm__ volatile
(
- "movml d2/a2/a6, sp@-\n\t"
+ PUSH_SP("d2/a2/a6", 12)
"movl %0,a6\n\t"
".word 0xA007\n\t"
- "movml sp@+, d2/a2/a6"
+ POP_SP("d2/a2/a6", 12)
: /* outputs */
: "r"(P) /* inputs */
: "d0", "d1", "a0", "a1" /* clobbered regs */