ucmpdi2.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* ===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------===
  2. *
  3. * The LLVM Compiler Infrastructure
  4. *
  5. * This file is dual licensed under the MIT and the University of Illinois Open
  6. * Source Licenses. See LICENSE.TXT for details.
  7. *
  8. * ===----------------------------------------------------------------------===
  9. *
  10. * This file implements __ucmpdi2 for the compiler_rt library.
  11. *
  12. * ===----------------------------------------------------------------------===
  13. */
  14. #include "int_lib.h"
  15. /* Returns: if (a < b) returns 0
  16. * if (a == b) returns 1
  17. * if (a > b) returns 2
  18. */
  19. COMPILER_RT_ABI si_int
  20. __ucmpdi2(du_int a, du_int b)
  21. {
  22. udwords x;
  23. x.all = a;
  24. udwords y;
  25. y.all = b;
  26. if (x.s.high < y.s.high)
  27. return 0;
  28. if (x.s.high > y.s.high)
  29. return 2;
  30. if (x.s.low < y.s.low)
  31. return 0;
  32. if (x.s.low > y.s.low)
  33. return 2;
  34. return 1;
  35. }
  36. #ifdef __ARM_EABI__
  37. /* Returns: if (a < b) returns -1
  38. * if (a == b) returns 0
  39. * if (a > b) returns 1
  40. */
  41. COMPILER_RT_ABI si_int
  42. __aeabi_ulcmp(di_int a, di_int b)
  43. {
  44. return __ucmpdi2(a, b) - 1;
  45. }
  46. #endif