1353358Sdim//===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------===//
2353358Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6353358Sdim//
7353358Sdim//===----------------------------------------------------------------------===//
8353358Sdim//
9353358Sdim// This file implements __ucmpdi2 for the compiler_rt library.
10353358Sdim//
11353358Sdim//===----------------------------------------------------------------------===//
12276789Sdim
13276789Sdim#include "int_lib.h"
14276789Sdim
15353358Sdim// Returns:  if (a <  b) returns 0
16353358Sdim//           if (a == b) returns 1
17353358Sdim//           if (a >  b) returns 2
18276789Sdim
19353358SdimCOMPILER_RT_ABI si_int __ucmpdi2(du_int a, du_int b) {
20353358Sdim  udwords x;
21353358Sdim  x.all = a;
22353358Sdim  udwords y;
23353358Sdim  y.all = b;
24353358Sdim  if (x.s.high < y.s.high)
25353358Sdim    return 0;
26353358Sdim  if (x.s.high > y.s.high)
27353358Sdim    return 2;
28353358Sdim  if (x.s.low < y.s.low)
29353358Sdim    return 0;
30353358Sdim  if (x.s.low > y.s.low)
31353358Sdim    return 2;
32353358Sdim  return 1;
33276789Sdim}
34276789Sdim
35276789Sdim#ifdef __ARM_EABI__
36353358Sdim// Returns: if (a <  b) returns -1
37353358Sdim//           if (a == b) returns  0
38353358Sdim//           if (a >  b) returns  1
39353358SdimCOMPILER_RT_ABI si_int __aeabi_ulcmp(di_int a, di_int b) {
40353358Sdim  return __ucmpdi2(a, b) - 1;
41276789Sdim}
42276789Sdim#endif
43