ucmpti2.c 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===
  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 __ucmpti2 for the compiler_rt library.
  11. *
  12. * ===----------------------------------------------------------------------===
  13. */
  14. #include "int_lib.h"
  15. #ifdef CRT_HAS_128BIT
  16. /* Returns: if (a < b) returns 0
  17. * if (a == b) returns 1
  18. * if (a > b) returns 2
  19. */
  20. COMPILER_RT_ABI si_int
  21. __ucmpti2(tu_int a, tu_int b)
  22. {
  23. utwords x;
  24. x.all = a;
  25. utwords y;
  26. y.all = b;
  27. if (x.s.high < y.s.high)
  28. return 0;
  29. if (x.s.high > y.s.high)
  30. return 2;
  31. if (x.s.low < y.s.low)
  32. return 0;
  33. if (x.s.low > y.s.low)
  34. return 2;
  35. return 1;
  36. }
  37. #endif /* CRT_HAS_128BIT */