1# Support for adding __float128 to the powerpc.
2
3# The standard 128-bit floating point support functions are TFmode.  Most
4# PowerPC targets use a long double format that has a pair of doubles to give
5# you more precision, but no extra expoenent range.  This long double format is
6# mostly compatible with the format used by the IBM XL compilers.  Some of the
7# names used by the IBM double-double format use TF in them, so we rename
8# all of the functions provided for the new IEEE 128-bit support.
9#
10# We use the TF functions in soft-fp for 128-bit floating point support, using
11# sed to transform the names in the files from TF names to KF names.
12
13# Emulator functions from the soft-fp directory
14fp128_softfp_funcs  = addkf3 subkf3 mulkf3 divkf3 negkf2 \
15                                unordkf2 eqkf2 gekf2 lekf2 \
16                                extendsfkf2 extenddfkf2 trunckfsf2 trunckfdf2 \
17                                fixkfsi fixkfdi fixunskfsi fixunskfdi \
18                                floatsikf floatdikf floatunsikf floatundikf
19
20fp128_softfp_src    = $(addsuffix -sw.c,$(fp128_softfp_funcs))
21fp128_softfp_static_obj       = $(addsuffix -sw$(objext),$(fp128_softfp_funcs))
22fp128_softfp_shared_obj       = $(addsuffix -sw_s$(objext),$(fp128_softfp_funcs))
23fp128_softfp_obj    = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj)
24
25# Decimal <-> _Float128 conversions
26fp128_dec_funcs               = _kf_to_sd _kf_to_dd _kf_to_td \
27                                _sd_to_kf _dd_to_kf _td_to_kf
28
29# Decimal <-> __ibm128 conversions
30ibm128_dec_funcs    = _tf_to_sd _tf_to_dd _tf_to_td \
31                                _sd_to_tf _dd_to_tf _td_to_tf
32
33# New functions for software emulation
34fp128_ppc_funcs               = floattikf-sw floatuntikf-sw \
35                                fixkfti-sw fixunskfti-sw \
36                                extendkftf2-sw trunctfkf2-sw \
37                                sfp-exceptions _mulkc3 _divkc3 _powikf2
38
39ifeq ($(decimal_float),yes)
40fp128_ppc_funcs        += $(fp128_dec_funcs)
41endif
42
43fp128_ppc_src                 = $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \
44                                        .c,$(fp128_ppc_funcs)))
45fp128_ppc_static_obj          = $(addsuffix $(objext),$(fp128_ppc_funcs))
46fp128_ppc_shared_obj          = $(addsuffix _s$(objext),$(fp128_ppc_funcs))
47fp128_ppc_obj                 = $(fp128_ppc_static_obj) $(fp128_ppc_shared_obj)
48
49# All functions
50fp128_funcs                   = $(fp128_softfp_funcs) $(fp128_ppc_funcs) \
51                                $(fp128_hw_funcs) $(fp128_ifunc_funcs) \
52                                $(fp128_3_1_hw_funcs)
53
54fp128_src           = $(fp128_softfp_src) $(fp128_ppc_src) \
55                                $(fp128_hw_src) $(fp128_ifunc_src) \
56                                $(fp128_3_1_hw_src)
57
58fp128_obj           = $(fp128_softfp_obj) $(fp128_ppc_obj) \
59                                $(fp128_hw_obj) $(fp128_ifunc_obj) \
60                                $(fp128_3_1_hw_obj)
61
62fp128_sed           = $(srcdir)/config/rs6000/float128-sed$(fp128_sed_hw)
63fp128_dep           = $(fp128_sed) $(srcdir)/config/rs6000/t-float128
64
65fp128_includes                = $(srcdir)/soft-fp/double.h \
66                                $(srcdir)/soft-fp/op-1.h \
67                                $(srcdir)/soft-fp/op-4.h \
68                                $(srcdir)/soft-fp/op-common.h \
69                                $(srcdir)/soft-fp/single.h \
70                                $(srcdir)/soft-fp/extended.h \
71                                $(srcdir)/soft-fp/op-2.h \
72                                $(srcdir)/soft-fp/op-8.h \
73                                $(srcdir)/soft-fp/quad.h \
74                                $(srcdir)/soft-fp/soft-fp.h
75
76# Build the emulator without ISA 3.0 hardware support.
77FP128_CFLAGS_SW                = -Wno-type-limits -mvsx -mfloat128 \
78                                 -mno-float128-hardware -mno-gnu-attribute \
79                                 -I$(srcdir)/soft-fp \
80                                 -I$(srcdir)/config/rs6000 \
81                                 $(FLOAT128_HW_INSNS)
82
83$(fp128_softfp_obj)  : INTERNAL_CFLAGS += $(FP128_CFLAGS_SW)
84$(fp128_ppc_obj)     : INTERNAL_CFLAGS += $(FP128_CFLAGS_SW)
85$(fp128_obj)                   : $(fp128_includes)
86$(fp128_obj)                   : $(srcdir)/config/rs6000/quad-float128.h
87
88# Force the TF mode to/from decimal functions to be compiled with IBM long
89# double.  Add building the KF mode to/from decimal conversions with explict
90# IEEE long double.
91fp128_dec_objs                = $(addsuffix $(objext),$(fp128_dec_funcs)) \
92                                $(addsuffix _s$(objext),$(fp128_dec_funcs))
93
94ibm128_dec_objs               = $(addsuffix $(objext),$(ibm128_dec_funcs)) \
95                                $(addsuffix _s$(objext),$(ibm128_dec_funcs))
96
97FP128_CFLAGS_DECIMAL          = -mno-gnu-attribute -Wno-psabi -mabi=ieeelongdouble
98IBM128_CFLAGS_DECIMAL         = -mno-gnu-attribute -Wno-psabi -mabi=ibmlongdouble
99
100$(fp128_dec_objs)   : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL)
101$(ibm128_dec_objs)  : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL)
102
103$(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep)
104          @src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \
105          echo "Create $@"; \
106          (echo "/* file created from $$src */"; \
107           echo; \
108           sed -f $(fp128_sed) < $$src) > $@
109
110.PHONY: test clean-float128
111
112test:
113          @echo "fp128_src:"; \
114          for x in $(fp128_src); do echo "    $$x"; done; \
115          echo; \
116          echo "fp128_obj:"; \
117          for x in $(fp128_obj); do echo "    $$x"; done;
118
119clean-float128:
120          -rm -f $(fp128_softfp_src) $(fp128_hardfp_src)
121          @$(MULTICLEAN) multi-clean DO=clean-float128
122
123# For now, only put it in the static library
124# LIB2ADD += $(fp128_src)
125
126LIB2ADD_ST += $(fp128_src)
127