ucmpti2.c 978 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements __ucmpti2 for the compiler_rt library.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "int_lib.h"
  13. #ifdef CRT_HAS_128BIT
  14. // Returns: if (a < b) returns 0
  15. // if (a == b) returns 1
  16. // if (a > b) returns 2
  17. COMPILER_RT_ABI si_int __ucmpti2(tu_int a, tu_int b) {
  18. utwords x;
  19. x.all = a;
  20. utwords y;
  21. y.all = b;
  22. if (x.s.high < y.s.high)
  23. return 0;
  24. if (x.s.high > y.s.high)
  25. return 2;
  26. if (x.s.low < y.s.low)
  27. return 0;
  28. if (x.s.low > y.s.low)
  29. return 2;
  30. return 1;
  31. }
  32. #endif // CRT_HAS_128BIT