libgcc-5.4.0 big decimal and soft float point functions

git-svn-id: svn://kolibrios.org@6518 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-09-09 12:30:24 +00:00
parent b275298c0a
commit 3c24fb5fae
4 changed files with 483 additions and 18 deletions

View File

@ -6,36 +6,46 @@ export STRIP = kos32-strip
export SDK_DIR:= $(abspath ../../../../sdk)
cpu_type = i386
enable_shared = no
double_type_size = 64
long_double_type_size = 96
decimal_float = yes
enable_vtable_verify = no
enable_decimal_float = bid
fixed_point = no
FPBIT = true
DPBIT = true
D32PBIT = 1
D64PBIT = 1
D128PBIT = 1
# List of functions not to build from libgcc2.c.
LIB2FUNCS_EXCLUDE =
#FPBIT = true
#DPBIT = true
CFLAGS_OPT+= -fomit-frame-pointer -fno-ident -mno-ms-bitfields
CFLAGS_OPT+= -fbuilding-libgcc -fno-stack-protector
CFLAGS = -c -O2 -DIN_GCC -DIN_LIBGCC2 -DHAVE_CC_TLS -DUSE_EMUTLS -DENABLE_DECIMAL_BID_FORMAT
CFLAGS = -c -O2 -DIN_GCC -DIN_LIBGCC2 -DHAVE_CC_TLS -DUSE_EMUTLS
CFLAGS+= -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -U_MSC_VER
CFLAGS+= -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes
CFLAGS+= -Wmissing-prototypes -Wold-style-definition $(CFLAGS_OPT)
CFLAGS+= -Wold-style-definition $(CFLAGS_OPT)
INCLUDES = -I. -I../gcc -I../include
DECNUMINC = -Iconfig/libbid -DENABLE_DECIMAL_BID_FORMAT
INCLUDES = -I. -I../gcc -I../include $(DECNUMINC)
gcc_compile = $(CC) $(INCLUDES) $(CFLAGS)
# Defined in libgcc2.c, included only in the static library.
LIB2FUNCS_ST = _eprintf __gcc_bcmp
# List of functions not to build from libgcc2.c.
LIB2FUNCS_EXCLUDE =
# These might cause a divide overflow trap and so are compiled with
# unwinder info.
LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
objext = .o
FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
@ -53,6 +63,127 @@ TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
_lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
_tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf
# Additional sources to handle exceptions; overridden by targets as needed.
LIB2ADDEH = unwind-dw2.c unwind-dw2-fde.c unwind-sjlj.c unwind-c.c
LIB2ADDEHSTATIC = $(LIB2ADDEH)
#LIB2ADD = $(srcdir)/config/i386/gthr-win32.c
EH_MODEL = dw2
CUSTOM_CRTSTUFF = yes
crtbegin.o: $(srcdir)/config/i386/cygming-crtbegin.c
$(crt_compile) -fno-omit-frame-pointer -c $<
crtbeginS.o: $(srcdir)/config/i386/cygming-crtbegin.c
$(crt_compile) -fno-omit-frame-pointer -c $< -DCRTSTUFFS_O
# We intentionally use a implementation-reserved init priority of 0,
# so allow the warning.
crtend.o: $(srcdir)/config/i386/cygming-crtend.c
$(crt_compile) -fno-omit-frame-pointer -Wno-error -c $<
# This is an endfile, Use -minline-all-stringops to ensure
# that __builtin_memset doesn't refer to the lib function memset().
crtfastmath.o: $(srcdir)/config/i386/crtfastmath.c
$(gcc_compile) -mfxsr -msse -c $<
LIB1ASMSRC = i386/cygwin.S
LIB1ASMFUNCS = _chkstk _chkstk_ms
DFP_ENABLE = true
LIB2ADD += config/i386/cpuinfo.c
softfp_float_modes := tf
softfp_int_modes := si di ti
softfp_extensions := sftf dftf xftf
softfp_truncations := tfsf tfdf tfxf
softfp_exclude_libgcc2 := n
# Omit TImode functions
softfp_int_modes := si di
# Provide fallbacks for __builtin_copysignq and __builtin_fabsq.
LIB2ADD += config/i386/32/tf-signs.c
# While emutls.c has nothing to do with EH, it is in LIB2ADDEH*
# instead of LIB2ADD because that's the way to be sure on some targets
# (e.g. *-*-darwin*) only one copy of it is linked.
LIB2ADDEH += emutls.c
LIB2ADDEHSTATIC += emutls.c
softfp_float_funcs = add$(m)3 div$(m)3 eq$(m)2 ge$(m)2 le$(m)2 mul$(m)3 \
neg$(m)2 sub$(m)3 unord$(m)2
softfp_floatint_funcs = fix$(m)$(i) fixuns$(m)$(i) \
float$(i)$(m) floatun$(i)$(m)
softfp_func_list := \
$(foreach m,$(softfp_float_modes), \
$(softfp_float_funcs) \
$(foreach i,$(softfp_int_modes), \
$(softfp_floatint_funcs))) \
$(foreach e,$(softfp_extensions),extend$(e)2) \
$(foreach t,$(softfp_truncations),trunc$(t)2) \
$(softfp_extras)
ifeq ($(softfp_exclude_libgcc2),y)
# This list is taken from mklibgcc.in and doesn't presently allow for
# 64-bit targets where si should become di and di should become ti.
softfp_func_list := $(filter-out floatdidf floatdisf fixunsdfsi fixunssfsi \
fixunsdfdi fixdfdi fixunssfdi fixsfdi fixxfdi fixunsxfdi \
floatdixf fixunsxfsi fixtfdi fixunstfdi floatditf \
floatundidf floatundisf floatundixf floatunditf,$(softfp_func_list))
endif
softfp_file_list := $(addsuffix .c,$(addprefix soft-fp/,$(softfp_func_list)))
# Disable missing prototype and type limit warnings. The prototypes
# for the functions in the soft-fp files have not been brought across
# from glibc.
soft-fp-objects-base = $(basename $(notdir $(softfp_file_list)))
soft-fp-objects = $(addsuffix $(objext), $(soft-fp-objects-base)) \
$(addsuffix _s$(objext), $(soft-fp-objects-base))
$(soft-fp-objects) : INTERNAL_CFLAGS += -Wno-missing-prototypes -Wno-type-limits
LIB2ADD += $(softfp_file_list)
ifneq ($(softfp_exclude_libgcc2),y)
# Functions in libgcc2.c are excluded for each soft-float mode (a
# target may have both soft-float and hard-float modes), for the fixed
# list of integer modes (si and di) for which libgcc2.c defines any
# such functions. Depending on the target, the si and di symbols may
# in fact define di and ti functions.
LIB2FUNCS_EXCLUDE += \
$(addprefix _,$(foreach m,$(softfp_float_modes), \
$(foreach i,si di, \
$(softfp_floatint_funcs))))
endif
iterator = empty.mk $(patsubst %,static-object.mk,$(iter-items))
lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \
_clear_cache _trampoline __main _absvsi2 _absvdi2 _addvsi3 \
@ -70,15 +201,59 @@ dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \
$(patsubst %,_floatXX%,sf df xf tf) \
$(patsubst %,_floatunXX%,sf df xf tf)
lib2funcs += $(subst XX,si,$(swfloatfuncs))
lib2funcs += $(subst XX,di,$(dwfloatfuncs))
ifeq ($(LIB2_SIDITI_CONV_FUNCS),)
lib2funcs += $(subst XX,si,$(swfloatfuncs))
lib2funcs += $(subst XX,di,$(dwfloatfuncs))
endif
# These might cause a divide overflow trap and so are compiled with
# unwinder info.
LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
# Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are
# defined as optimized assembly code in LIB1ASMFUNCS or as C code
# in LIB2FUNCS_EXCLUDE.
lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs))
LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
$(LIB2_DIVMOD_FUNCS))
# Build lib2funcs. For the static library also include LIB2FUNCS_ST.
lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST))
$(lib2funcs-o): %$(objext): libgcc2.c
$(gcc_compile) -DL$* -c $< -o $@
libgcc-objects += $(lib2funcs-o)
libgcc-objects =
ifneq ($(LIB2_SIDITI_CONV_FUNCS),)
# Build libgcc2.c for each conversion function, with a specific
# L<func> definition and LIBGCC2_UNITS_PER_WORD setting. The DImode
# functions are built with a wordsize of 4; the TImode functions are
# built with the same labels, but a wordsize of 8.
sifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,si,$(swfloatfuncs)))
difuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,di,$(dwfloatfuncs)))
tifuncs := $(filter-out $(LIB2FUNCS_EXCLUDE),$(subst XX,ti,$(dwfloatfuncs)))
iter-items := $(sifuncs) $(difuncs) $(tifuncs)
iter-labels := $(sifuncs) $(difuncs) $(difuncs)
iter-sizes := $(patsubst %,4,$(sifuncs) $(difuncs)) $(patsubst %,8,$(tifuncs))
include empty.mk $(patsubst %,siditi-object.mk,$(iter-items))
libgcc-objects += $(patsubst %,%$(objext),$(sifuncs) $(difuncs) $(tifuncs))
endif
ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),)
# Provide default flags for compiling divmod functions, if they haven't been
# set already by a target-specific Makefile fragment.
LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions
endif
# Build LIB2_DIVMOD_FUNCS.
lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
$(lib2-divmod-o): %$(objext): libgcc2.c
$(gcc_compile) -DL$* -c $< $(LIB2_DIVMOD_EXCEPTION_FLAGS) -o $@
libgcc-objects += $(lib2-divmod-o)
ifeq ($(TPBIT),)
# _sf_to_tf and _df_to_tf require tp-bit.c being compiled in.
@ -116,6 +291,71 @@ $(tpbit-o): %$(objext): $(fpbit-src)
libgcc-objects += $(tpbit-o)
endif
# Build decimal floating point support.
ifeq ($(decimal_float),yes)
# If $DFP_ENABLE is set, then we want all data type sizes.
ifneq ($(DFP_ENABLE),)
D32PBIT = 1
D64PBIT = 1
D128PBIT = 1
endif
dfp-filenames =
ifneq ($(D32PBIT)$(D64PBIT)$(D128PBIT),)
ifeq ($(enable_decimal_float),bid)
dfp-filenames += bid_decimal_globals bid_decimal_data \
bid_binarydecimal bid_convert_data \
_isinfd32 _isinfd64 _isinfd128 bid64_noncomp \
bid128_noncomp bid128_fma bid_round bid_from_int \
bid64_add bid128_add bid64_div bid128_div \
bid64_mul bid128_mul bid64_compare bid128_compare \
bid128 bid32_to_bid64 bid32_to_bid128 bid64_to_bid128 \
bid64_to_int32 bid64_to_int64 \
bid64_to_uint32 bid64_to_uint64 \
bid128_to_int32 bid128_to_int64 \
bid128_to_uint32 bid128_to_uint64
else
dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle
endif
endif
dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames))
ifeq ($(enable_decimal_float),bid)
$(dfp-objects): %$(objext): config/libbid/%.c
else
$(dfp-objects): %$(objext): ../libdecnumber/%.c
endif
$(gcc_compile) -c $<
libgcc-objects += $(dfp-objects)
decbits-filenames =
ifneq ($(enable_decimal_float),bid)
ifneq ($(D32PBIT),)
decbits-filenames += decimal32
endif
ifneq ($(D64PBIT),)
decbits-filenames += decimal64
endif
ifneq ($(D128PBIT),)
decbits-filenames += decimal128
endif
endif
decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames))
ifeq ($(enable_decimal_float),bid)
$(decbits-objects): %$(objext): config/libbid/%.c
else
$(decbits-objects): %$(objext): ../libdecnumber/$(enable_decimal_float)/%.c
endif
$(gcc_compile) -c $<
libgcc-objects += $(decbits-objects)
# Next build individual support functions.
D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \
_eq_sd _ne_sd _lt_sd _gt_sd _le_sd _ge_sd \
@ -188,12 +428,34 @@ endif
libgcc-objects += $(d128pbit-o)
endif
endif
# Build LIB2ADD and LIB2ADD_ST.
ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
$(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
endif
libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
#libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
c_flags :=
iter-items := $(LIB2ADD) $(LIB2ADD_ST)
include $(iterator)
c_flags := -fexceptions
#libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADDEH))))
iter-items := $(LIB2ADDEH)
include $(iterator)
# targets
all: libgcc.a
libgcc.a : $(lib2funcs-o) $(libgcc-objects) Makefile
$(AR) crs libgcc.a $(lib2funcs-o) $(libgcc-objects)
libgcc.a : $(libgcc-objects) Makefile
$(AR) crs libgcc.a $(libgcc-objects)
# mv -f libbfd.a $(SDK_DIR)/lib

View File

@ -0,0 +1,80 @@
/* auto-target.h. Generated from config.in by configure. */
/* config.in. Generated from configure.ac by autoheader. */
/* Define to 1 if the target assembler supports thread-local storage. */
/* #undef HAVE_CC_TLS */
/* Define to 1 if you have the <ftw.h> header file. */
/* #undef HAVE_FTW_H */
/* Define if _Unwind_GetIPInfo is available. */
#define HAVE_GETIPINFO 1
/* Define if the compiler supports init priority. */
#define HAVE_INIT_PRIORITY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define if the system-provided CRTs are present on Solaris. */
/* #undef HAVE_SOLARIS_CRTS */
/* Define if the system-provided CRTs are present on Solaris. */
/* #undef HAVE_SOLARIS_CRTS */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if the C compiler is configured for setjmp/longjmp exceptions. */
/* #undef LIBGCC_SJLJ_EXCEPTIONS */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "GNU C Runtime Library"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "GNU C Runtime Library 1.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libgcc"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.0"
/* The size of `double', as computed by sizeof. */
#define SIZEOF_DOUBLE 8
/* The size of `long double', as computed by sizeof. */
#define SIZEOF_LONG_DOUBLE 12
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if the target use emutls for thread-local storage. */
#define USE_EMUTLS 1

View File

@ -0,0 +1,85 @@
#ifdef __MINGW32__
/* Make sure we are using gnu-style bitfield handling. */
#define _FP_STRUCT_LAYOUT __attribute__ ((gcc_struct))
#endif
/* 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
#ifdef __x86_64__
#include "config/i386/64/sfp-machine.h"
#else
#include "config/i386/32/sfp-machine.h"
#endif
#define _FP_KEEPNANFRACP 1
#define _FP_QNANNEGATEDP 0
#define _FP_NANSIGN_S 1
#define _FP_NANSIGN_D 1
#define _FP_NANSIGN_E 1
#define _FP_NANSIGN_Q 1
/* Here is something Intel misdesigned: the specs don't define
the case where we have two NaNs with same mantissas, but
different sign. Different operations pick up different NaNs. */
#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
do { \
if (_FP_FRAC_GT_##wc(X, Y) \
|| (_FP_FRAC_EQ_##wc(X,Y) && (OP == '+' || OP == '*'))) \
{ \
R##_s = X##_s; \
_FP_FRAC_COPY_##wc(R,X); \
} \
else \
{ \
R##_s = Y##_s; \
_FP_FRAC_COPY_##wc(R,Y); \
} \
R##_c = FP_CLS_NAN; \
} while (0)
#ifndef _SOFT_FLOAT
#define FP_EX_INVALID 0x01
#define FP_EX_DENORM 0x02
#define FP_EX_DIVZERO 0x04
#define FP_EX_OVERFLOW 0x08
#define FP_EX_UNDERFLOW 0x10
#define FP_EX_INEXACT 0x20
#define FP_EX_ALL \
(FP_EX_INVALID | FP_EX_DENORM | FP_EX_DIVZERO | FP_EX_OVERFLOW \
| FP_EX_UNDERFLOW | FP_EX_INEXACT)
void __sfp_handle_exceptions (int);
#define FP_HANDLE_EXCEPTIONS \
do { \
if (__builtin_expect (_fex, 0)) \
__sfp_handle_exceptions (_fex); \
} while (0);
#define FP_TRAPPING_EXCEPTIONS ((~_fcw >> FP_EX_SHIFT) & FP_EX_ALL)
#define FP_ROUNDMODE (_fcw & FP_RND_MASK)
#endif
#define _FP_TININESS_AFTER_ROUNDING 1
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __BYTE_ORDER __LITTLE_ENDIAN
/* Define ALIASNAME as a strong alias for NAME. */
#if defined __MACH__
/* Mach-O doesn't support aliasing. If these functions ever return
anything but CMPtype we need to revisit this... */
#define strong_alias(name, aliasname) \
CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); }
#else
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
#endif

View File

@ -0,0 +1,38 @@
# This file is included several times in a row, once for each element of
# $(iter-items). On each inclusion, we advance $o to the next element.
o := $(firstword $(iter-items))
iter-items := $(filter-out $o,$(iter-items))
base := $(basename $(notdir $o))
# Copy c_flags to a rule-specific copy and use the copy, to avoid the
# following rules being affected by later changes to c_flags in the
# including file.
c_flags-$o := $(c_flags)
ifeq ($(suffix $o),.c)
$(base)$(objext): $o
$(gcc_compile) $(c_flags-$<) -c $< $(vis_hide)
else
ifneq ($(suffix $o),.S)
ifneq ($(suffix $o),.asm)
$(error Unsupported file type: $o)
endif
endif
as_flags-$o := -xassembler$(if $(filter .S,$(suffix $o)),-with-cpp)
$(base)$(objext): $o $(base).vis
$(gcc_compile) -c $(as_flags-$<) -include $*.vis $<
$(base).vis: $(base)_s$(objext)
$(gen-hide-list)
$(base)_s$(objext): $o
$(gcc_s_compile) -c $(as_flags-$<) $<
endif