at91: add support for the WB50N module from Laird
[openwrt/staging/wigyori.git] / toolchain / gcc / patches / 5.4.0 / 931-fix-MIPS-softfloat-build-issue.patch
1 From 2b46f9187b6f994fc450628a7cd97fc703dd23e0 Mon Sep 17 00:00:00 2001
2 From: BangLang Huang <banglang.huang@foxmail.com>
3 Date: Wed, 9 Nov 2016 10:36:49 +0800
4 Subject: [PATCH] fix MIPS softfloat build issue
5
6 This patch is backport from github/libffi #272
7
8 Signed-off-by: BangLang Huang <banglang.huang@foxmail.com>
9 ---
10 libffi/src/mips/n32.S | 17 +++++++++++++++++
11 libffi/src/mips/o32.S | 17 +++++++++++++++++
12 2 files changed, 34 insertions(+)
13
14 diff --git a/libffi/src/mips/n32.S b/libffi/src/mips/n32.S
15 index c6985d3..8f25994 100644
16 --- a/libffi/src/mips/n32.S
17 +++ b/libffi/src/mips/n32.S
18 @@ -107,6 +107,16 @@ loadregs:
19
20 REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6.
21
22 +#ifdef __mips_soft_float
23 + REG_L a0, 0*FFI_SIZEOF_ARG(t9)
24 + REG_L a1, 1*FFI_SIZEOF_ARG(t9)
25 + REG_L a2, 2*FFI_SIZEOF_ARG(t9)
26 + REG_L a3, 3*FFI_SIZEOF_ARG(t9)
27 + REG_L a4, 4*FFI_SIZEOF_ARG(t9)
28 + REG_L a5, 5*FFI_SIZEOF_ARG(t9)
29 + REG_L a6, 6*FFI_SIZEOF_ARG(t9)
30 + REG_L a7, 7*FFI_SIZEOF_ARG(t9)
31 +#else
32 and t4, t6, ((1<<FFI_FLAG_BITS)-1)
33 REG_L a0, 0*FFI_SIZEOF_ARG(t9)
34 beqz t4, arg1_next
35 @@ -193,6 +203,7 @@ arg7_next:
36 arg8_doublep:
37 l.d $f19, 7*FFI_SIZEOF_ARG(t9)
38 arg8_next:
39 +#endif
40
41 callit:
42 # Load the function pointer
43 @@ -214,6 +225,7 @@ retint:
44 b epilogue
45
46 retfloat:
47 +#ifndef __mips_soft_float
48 bne t6, FFI_TYPE_FLOAT, retdouble
49 jal t9
50 REG_L t4, 4*FFI_SIZEOF_ARG($fp)
51 @@ -272,6 +284,7 @@ retstruct_f_d:
52 s.s $f0, 0(t4)
53 s.d $f2, 8(t4)
54 b epilogue
55 +#endif
56
57 retstruct_d_soft:
58 bne t6, FFI_TYPE_STRUCT_D_SOFT, retstruct_f_soft
59 @@ -429,6 +442,7 @@ ffi_closure_N32:
60 REG_S a6, A6_OFF2($sp)
61 REG_S a7, A7_OFF2($sp)
62
63 +#ifndef __mips_soft_float
64 # Store all possible float/double registers.
65 s.d $f12, F12_OFF2($sp)
66 s.d $f13, F13_OFF2($sp)
67 @@ -438,6 +452,7 @@ ffi_closure_N32:
68 s.d $f17, F17_OFF2($sp)
69 s.d $f18, F18_OFF2($sp)
70 s.d $f19, F19_OFF2($sp)
71 +#endif
72
73 # Call ffi_closure_mips_inner_N32 to do the real work.
74 LA t9, ffi_closure_mips_inner_N32
75 @@ -458,6 +473,7 @@ cls_retint:
76 b cls_epilogue
77
78 cls_retfloat:
79 +#ifndef __mips_soft_float
80 bne v0, FFI_TYPE_FLOAT, cls_retdouble
81 l.s $f0, V0_OFF2($sp)
82 b cls_epilogue
83 @@ -500,6 +516,7 @@ cls_retstruct_f_d:
84 l.s $f0, V0_OFF2($sp)
85 l.d $f2, V1_OFF2($sp)
86 b cls_epilogue
87 +#endif
88
89 cls_retstruct_small2:
90 REG_L v0, V0_OFF2($sp)
91 diff --git a/libffi/src/mips/o32.S b/libffi/src/mips/o32.S
92 index eb27981..1aff4b1 100644
93 --- a/libffi/src/mips/o32.S
94 +++ b/libffi/src/mips/o32.S
95 @@ -82,13 +82,16 @@ sixteen:
96
97 ADDU $sp, 4 * FFI_SIZEOF_ARG # adjust $sp to new args
98
99 +#ifndef __mips_soft_float
100 bnez t0, pass_d # make it quick for int
101 +#endif
102 REG_L a0, 0*FFI_SIZEOF_ARG($sp) # just go ahead and load the
103 REG_L a1, 1*FFI_SIZEOF_ARG($sp) # four regs.
104 REG_L a2, 2*FFI_SIZEOF_ARG($sp)
105 REG_L a3, 3*FFI_SIZEOF_ARG($sp)
106 b call_it
107
108 +#ifndef __mips_soft_float
109 pass_d:
110 bne t0, FFI_ARGS_D, pass_f
111 l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
112 @@ -130,6 +133,7 @@ pass_f_d:
113 # bne t0, FFI_ARGS_F_D, call_it
114 l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
115 l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float
116 +#endif
117
118 call_it:
119 # Load the function pointer
120 @@ -158,14 +162,23 @@ retfloat:
121 bne t2, FFI_TYPE_FLOAT, retdouble
122 jalr t9
123 REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
124 +#ifndef __mips_soft_float
125 s.s $f0, 0(t0)
126 +#else
127 + REG_S v0, 0(t0)
128 +#endif
129 b epilogue
130
131 retdouble:
132 bne t2, FFI_TYPE_DOUBLE, noretval
133 jalr t9
134 REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
135 +#ifndef __mips_soft_float
136 s.d $f0, 0(t0)
137 +#else
138 + REG_S v1, 4(t0)
139 + REG_S v0, 0(t0)
140 +#endif
141 b epilogue
142
143 noretval:
144 @@ -261,9 +274,11 @@ $LCFI7:
145 li $13, 1 # FFI_O32
146 bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT
147
148 +#ifndef __mips_soft_float
149 # Store all possible float/double registers.
150 s.d $f12, FA_0_0_OFF2($fp)
151 s.d $f14, FA_1_0_OFF2($fp)
152 +#endif
153 1:
154 # Call ffi_closure_mips_inner_O32 to do the work.
155 la t9, ffi_closure_mips_inner_O32
156 @@ -281,6 +296,7 @@ $LCFI7:
157 li $13, 1 # FFI_O32
158 bne $16, $13, 1f # Skip fp restore if FFI_O32_SOFT_FLOAT
159
160 +#ifndef __mips_soft_float
161 li $9, FFI_TYPE_FLOAT
162 l.s $f0, V0_OFF2($fp)
163 beq $8, $9, closure_done
164 @@ -288,6 +304,7 @@ $LCFI7:
165 li $9, FFI_TYPE_DOUBLE
166 l.d $f0, V0_OFF2($fp)
167 beq $8, $9, closure_done
168 +#endif
169 1:
170 REG_L $3, V1_OFF2($fp)
171 REG_L $2, V0_OFF2($fp)
172 --
173 2.7.4
174