umodsi3-float.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Unsigned 32 bit division optimized for Epiphany.
  2. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. Contributed by Embecosm on behalf of Adapteva, Inc.
  4. This file is part of GCC.
  5. This file is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 3, or (at your option) any
  8. later version.
  9. This file is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #include "epiphany-asm.h"
  21. /* Because we handle a divident with bit 31 set with truncating integer
  22. arithmetic, there is no rounding-related overflow. */
  23. FSTAB (__umodsi3,T_UINT)
  24. .global SYM(__umodsi3)
  25. .balign 4
  26. HIDDEN_FUNC(__umodsi3)
  27. SYM(__umodsi3):
  28. float r2,r0
  29. mov TMP1,%low(0xb0800000) ; ??? this would be faster with small data
  30. float TMP2,r1
  31. movt TMP1,%high(0xb0800000)
  32. asr TMP0,r0,8
  33. sub TMP0,TMP0,TMP1
  34. mov TMP1,%low(.L0step)
  35. movgteu r2,TMP0
  36. sub r2,r2,TMP2
  37. blteu .L0step
  38. asr r2,r2,23
  39. movt TMP1,%high(.L0step)
  40. lsl TMP2,r2,3
  41. lsl r2,r1,r2` sub r2,r0,r2` movgteu r0,r2 ; STEP(r2)
  42. sub r2,TMP1,TMP2
  43. jr r2
  44. #define STEP(n) lsl.l r2,r1,n` sub r2,r0,r2` movgteu r0,r2
  45. .balign 8,,2
  46. STEP(31)` STEP(30)` STEP(29)` STEP(28)`
  47. STEP(27)` STEP(26)` STEP(25)` STEP(24)`
  48. STEP(23)` STEP(22)` STEP(21)` STEP(20)`
  49. STEP(19)` STEP(18)` STEP(17)` STEP(16)`
  50. STEP(15)` STEP(14)` STEP(13)` STEP(12)`
  51. STEP(11)` STEP(10)` STEP(9)` STEP(8)`
  52. STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
  53. .L0step:STEP(0)
  54. .Lret_r0:
  55. rts
  56. ENDFUNC(__umodsi3)