From e6e50811a7a8910c43c7f9892759e1edb65cb89f Mon Sep 17 00:00:00 2001
From: Anthony Green <green@moxielogic.com>
Date: Mon, 4 Jan 2010 08:29:53 +0000
Subject: [PATCH] Fix libgcc build for moxie.

From-SVN: r155609
---
 libgcc/ChangeLog                   |  7 ++++
 libgcc/config.host                 |  4 +--
 libgcc/config/moxie/crti.asm       | 40 +++++++++++++++++++++
 libgcc/config/moxie/crtn.asm       | 34 ++++++++++++++++++
 libgcc/config/moxie/sfp-machine.h  | 57 ++++++++++++++++++++++++++++++
 libgcc/config/moxie/t-moxie        |  9 +++++
 libgcc/config/moxie/t-moxie-softfp |  9 +++++
 7 files changed, 158 insertions(+), 2 deletions(-)
 create mode 100644 libgcc/config/moxie/crti.asm
 create mode 100644 libgcc/config/moxie/crtn.asm
 create mode 100644 libgcc/config/moxie/sfp-machine.h
 create mode 100644 libgcc/config/moxie/t-moxie
 create mode 100644 libgcc/config/moxie/t-moxie-softfp

diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 2a1c9ee71aac..d8424c16cace 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-04  Anthony Green  <green@moxielogic.com>
+
+	* config/moxie/crti.asm, config/moxie/crtn.asm,
+	config/moxie/t-moxie-softfp, config/moxie/sfp-machine.h,
+	config/moxie/t-moxie: New files.
+	* config.host: Add t-moxie-softfp reference.
+
 2009-11-18  Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
 
 	PR other/39888
diff --git a/libgcc/config.host b/libgcc/config.host
index 1a66beb47365..5c3bfa699965 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1,6 +1,6 @@
 # libgcc host-specific configuration file.
 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-# 2008, 2009 Free Software Foundation, Inc.
+# 2008, 2009, 2010 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -436,7 +436,7 @@ mmix-knuth-mmixware)
 mn10300-*-*)
 	;;
 moxie-*-*)
-	tmake_file=${cpu_type}/t-moxie
+	tmake_file="moxie/t-moxie moxie/t-moxie-softfp"
 	extra_parts="crtbegin.o crtend.o crti.o crtn.o"
 	;;
 pdp11-*-*)
diff --git a/libgcc/config/moxie/crti.asm b/libgcc/config/moxie/crti.asm
new file mode 100644
index 000000000000..f44582799a34
--- /dev/null
+++ b/libgcc/config/moxie/crti.asm
@@ -0,0 +1,40 @@
+# crti.asm for moxie
+#
+#   Copyright (C) 2009 Free Software Foundation
+# 
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3, or (at your option) any
+# later version.
+# 
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# This file just make a stack frame for the contents of the .fini and
+# .init sections.  Users may put any desired instructions in those
+# sections.
+
+	.file		"crti.asm"
+
+	.section	".init"
+	.global	_init
+	.type	_init, @function	
+	.p2align	1
+_init:
+
+	.section	".fini"
+	.global	_fini
+	.type	_fini,@function
+	.p2align	1
+_fini:
diff --git a/libgcc/config/moxie/crtn.asm b/libgcc/config/moxie/crtn.asm
new file mode 100644
index 000000000000..3ac9d31eed88
--- /dev/null
+++ b/libgcc/config/moxie/crtn.asm
@@ -0,0 +1,34 @@
+# crtn.asm for moxie
+# 
+#   Copyright (C) 2009 Free Software Foundation
+# 
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3, or (at your option) any
+# later version.
+# 
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+# This file just makes sure that the .fini and .init sections do in
+# fact return.  Users may put any desired instructions in those sections.
+# This file is the last thing linked into any executable.
+
+	.file		"crtn.asm"
+
+	.section	".init"
+	ret
+	
+	.section	".fini"
+	ret
diff --git a/libgcc/config/moxie/sfp-machine.h b/libgcc/config/moxie/sfp-machine.h
new file mode 100644
index 000000000000..98f9f1bf491d
--- /dev/null
+++ b/libgcc/config/moxie/sfp-machine.h
@@ -0,0 +1,57 @@
+#define _FP_W_TYPE_SIZE		32
+#define _FP_W_TYPE		unsigned long
+#define _FP_WS_TYPE		signed long
+#define _FP_I_TYPE		long
+
+/* The type of the result of a floating point comparison.  This must
+   match `__libgcc_cmp_return__' in GCC for the target.  */
+typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
+#define CMPtype __gcc_CMPtype
+
+#define _FP_MUL_MEAT_S(R,X,Y)				\
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)				\
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y)				\
+  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S		0
+#define _FP_NANSIGN_D		0
+#define _FP_NANSIGN_Q		0
+
+#define _FP_KEEPNANFRACP 1
+
+/* Someone please check this.  */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
+  do {								\
+    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
+	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
+      {								\
+	R##_s = Y##_s;						\
+	_FP_FRAC_COPY_##wc(R,Y);				\
+      }								\
+    else							\
+      {								\
+	R##_s = X##_s;						\
+	_FP_FRAC_COPY_##wc(R,X);				\
+      }								\
+    R##_c = FP_CLS_NAN;						\
+  } while (0)
+
+#define	__LITTLE_ENDIAN	1234
+#define	__BIG_ENDIAN	4321
+
+# define __BYTE_ORDER __BIG_ENDIAN
+
+/* Define ALIASNAME as a strong alias for NAME.  */
+# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
+# define _strong_alias(name, aliasname) \
+  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+
diff --git a/libgcc/config/moxie/t-moxie b/libgcc/config/moxie/t-moxie
new file mode 100644
index 000000000000..6e62aec22244
--- /dev/null
+++ b/libgcc/config/moxie/t-moxie
@@ -0,0 +1,9 @@
+# Assemble startup files.
+
+$(T)crti.o: $(srcdir)/config/moxie/crti.asm $(GCC_PASSES)
+	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+	-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/moxie/crti.asm
+
+$(T)crtn.o: $(srcdir)/config/moxie/crtn.asm $(GCC_PASSES)
+	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+	-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/moxie/crtn.asm
diff --git a/libgcc/config/moxie/t-moxie-softfp b/libgcc/config/moxie/t-moxie-softfp
new file mode 100644
index 000000000000..61c575132e9a
--- /dev/null
+++ b/libgcc/config/moxie/t-moxie-softfp
@@ -0,0 +1,9 @@
+softfp_float_modes := sf df
+softfp_int_modes := si di
+softfp_extensions := sfdf
+softfp_truncations := dfsf
+softfp_machine_header := moxie/sfp-machine.h
+softfp_exclude_libgcc2 := y
+
+# softfp seems to be missing a whole bunch of prototypes.
+TARGET_LIBGCC2_CFLAGS += -Wno-missing-prototypes
-- 
GitLab