cmpdi2.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===
  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 __cmpdi2 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. __cmpdi2(di_int a, di_int b)
  21. {
  22. dwords x;
  23. x.all = a;
  24. dwords 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_lcmp(di_int a, di_int b)
  43. {
  44. return __cmpdi2(a, b) - 1;
  45. }
  46. #endif