h8300: library functions
authorYoshinori Sato <ysato@users.sourceforge.jp>
Tue, 27 Jan 2015 17:48:15 +0000 (02:48 +0900)
committerYoshinori Sato <ysato@users.sourceforge.jp>
Tue, 23 Jun 2015 04:35:54 +0000 (13:35 +0900)
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
16 files changed:
arch/h8300/lib/Makefile [new file with mode: 0644]
arch/h8300/lib/abs.S [new file with mode: 0644]
arch/h8300/lib/ashldi3.c [new file with mode: 0644]
arch/h8300/lib/ashrdi3.c [new file with mode: 0644]
arch/h8300/lib/delay.c [new file with mode: 0644]
arch/h8300/lib/libgcc.h [new file with mode: 0644]
arch/h8300/lib/lshrdi3.c [new file with mode: 0644]
arch/h8300/lib/memcpy.S [new file with mode: 0644]
arch/h8300/lib/memset.S [new file with mode: 0644]
arch/h8300/lib/moddivsi3.S [new file with mode: 0644]
arch/h8300/lib/modsi3.S [new file with mode: 0644]
arch/h8300/lib/muldi3.c [new file with mode: 0644]
arch/h8300/lib/mulsi3.S [new file with mode: 0644]
arch/h8300/lib/strncpy.S [new file with mode: 0644]
arch/h8300/lib/ucmpdi2.c [new file with mode: 0644]
arch/h8300/lib/udivsi3.S [new file with mode: 0644]

diff --git a/arch/h8300/lib/Makefile b/arch/h8300/lib/Makefile
new file mode 100644 (file)
index 0000000..28ff560
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# Makefile for H8/300-specific library files..
+#
+
+lib-y  = memcpy.o memset.o abs.o strncpy.o \
+        mulsi3.o udivsi3.o muldi3.o moddivsi3.o \
+        ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o \
+        delay.o
diff --git a/arch/h8300/lib/abs.S b/arch/h8300/lib/abs.S
new file mode 100644 (file)
index 0000000..efda749
--- /dev/null
@@ -0,0 +1,20 @@
+;;; abs.S
+
+#include <asm/linkage.h>
+
+#if defined(CONFIG_CPU_H8300H)
+       .h8300h
+#endif
+#if defined(CONFIG_CPU_H8S)
+       .h8300s
+#endif
+       .text
+.global _abs
+
+;;; int abs(int n)
+_abs:
+       mov.l   er0,er0
+       bpl     1f
+       neg.l   er0
+1:
+       rts
diff --git a/arch/h8300/lib/ashldi3.c b/arch/h8300/lib/ashldi3.c
new file mode 100644 (file)
index 0000000..c6aa8ea
--- /dev/null
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype
+__ashldi3(DWtype u, word_type b)
+{
+       const DWunion uu = {.ll = u};
+       const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+       DWunion w;
+
+       if (b == 0)
+               return u;
+
+       if (bm <= 0) {
+               w.s.low = 0;
+               w.s.high = (UWtype) uu.s.low << -bm;
+       } else {
+               const UWtype carries = (UWtype) uu.s.low >> bm;
+
+               w.s.low = (UWtype) uu.s.low << b;
+               w.s.high = ((UWtype) uu.s.high << b) | carries;
+       }
+
+       return w.ll;
+}
diff --git a/arch/h8300/lib/ashrdi3.c b/arch/h8300/lib/ashrdi3.c
new file mode 100644 (file)
index 0000000..070adf9
--- /dev/null
@@ -0,0 +1,24 @@
+#include "libgcc.h"
+
+DWtype __ashrdi3(DWtype u, word_type b)
+{
+       const DWunion uu = {.ll = u};
+       const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
+       DWunion w;
+
+       if (b == 0)
+               return u;
+
+       if (bm <= 0) {
+               /* w.s.high = 1..1 or 0..0 */
+               w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
+               w.s.low = uu.s.high >> -bm;
+       } else {
+               const UWtype carries = (UWtype) uu.s.high << bm;
+
+               w.s.high = uu.s.high >> b;
+               w.s.low = ((UWtype) uu.s.low >> b) | carries;
+       }
+
+       return w.ll;
+}
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge