931-fix-MIPS-softfloat-build-issue.patch 4.3 KB

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