cmpdi2.c 1.1 KB

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