You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.3 KiB

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