lib2divSI.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SI mode divide routines for libgcc for MSP430
  2. Copyright (C) 2012-2022 Free Software Foundation, Inc.
  3. Contributed by Red Hat.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published
  7. by the Free Software Foundation; either version 3, or (at your
  8. option) any later version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  12. 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. typedef int sint32_type __attribute__ ((mode (SI)));
  21. typedef unsigned int uint32_type __attribute__ ((mode (SI)));
  22. typedef int sint16_type __attribute__ ((mode (HI)));
  23. typedef unsigned int uint16_type __attribute__ ((mode (HI)));
  24. typedef int sint08_type __attribute__ ((mode (QI)));
  25. typedef unsigned int uint08_type __attribute__ ((mode (QI)));
  26. typedef int word_type __attribute__ ((mode (__word__)));
  27. #define C3B(a,b,c) a##b##c
  28. #define C3(a,b,c) C3B(a,b,c)
  29. #define UINT_TYPE uint32_type
  30. #define SINT_TYPE sint32_type
  31. #define BITS_MINUS_1 31
  32. #define NAME_MODE si
  33. #include "msp430-divmod.h"
  34. /* ---------------------------------------------------------------------*/
  35. /* There is a typo in the MSP430 ABI document. It calls the unsigned
  36. long integer division function __mspabi_divlu when it should be
  37. __mspabi_divul. Likewise the unsigned long long integer division
  38. function is called __mspabi_divllu when it should be __mspabi_divull.
  39. Earlier versions of this toolchain used generate the ABI compliant
  40. names, so in order to support object files built with those tools
  41. we provide stub functions that call the correct routines. */
  42. asm (".global __mspabi_divlu\n\
  43. .set __mspabi_divlu, __mspabi_divul");
  44. /* We cannot use the same trick for __mspabi_divllu as that is defined
  45. in a different file. Instead we create a stub here. The cost of
  46. executing the branch instruction will be trivial compared to the
  47. cost of executing a long long division. */
  48. #ifdef __MSP430X_LARGE__
  49. asm (".global __mspabi_divllu\n\
  50. __mspabi_divllu:\n\
  51. BRA #__mspabi_divull");
  52. #else
  53. asm (".global __mspabi_divllu\n\
  54. __mspabi_divllu:\n\
  55. BR #__mspabi_divull");
  56. #endif