cmpti2.c 1003 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------===
  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 __cmpti2 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. __cmpti2(ti_int a, ti_int b)
  22. {
  23. twords x;
  24. x.all = a;
  25. twords 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 */