1214152Sed/* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===
2214152Sed *
3214152Sed *                     The LLVM Compiler Infrastructure
4214152Sed *
5222656Sed * This file is dual licensed under the MIT and the University of Illinois Open
6222656Sed * Source Licenses. See LICENSE.TXT for details.
7214152Sed *
8214152Sed * ===----------------------------------------------------------------------===
9222656Sed *
10214152Sed * This file implements __cmpdi2 for the compiler_rt library.
11214152Sed *
12214152Sed * ===----------------------------------------------------------------------===
13214152Sed */
14214152Sed
15214152Sed#include "int_lib.h"
16214152Sed
17222656Sed/* Returns: if (a <  b) returns 0
18214152Sed*           if (a == b) returns 1
19214152Sed*           if (a >  b) returns 2
20214152Sed*/
21214152Sed
22222656SedCOMPILER_RT_ABI si_int
23214152Sed__cmpdi2(di_int a, di_int b)
24214152Sed{
25214152Sed    dwords x;
26214152Sed    x.all = a;
27214152Sed    dwords y;
28214152Sed    y.all = b;
29214152Sed    if (x.s.high < y.s.high)
30214152Sed        return 0;
31214152Sed    if (x.s.high > y.s.high)
32214152Sed        return 2;
33214152Sed    if (x.s.low < y.s.low)
34214152Sed        return 0;
35214152Sed    if (x.s.low > y.s.low)
36214152Sed        return 2;
37214152Sed    return 1;
38214152Sed}
39263560Sdim
40263560Sdim#ifdef __ARM_EABI__
41263560Sdim/* Returns: if (a <  b) returns -1
42263560Sdim*           if (a == b) returns  0
43263560Sdim*           if (a >  b) returns  1
44263560Sdim*/
45263560SdimCOMPILER_RT_ABI si_int
46263560Sdim__aeabi_lcmp(di_int a, di_int b)
47263560Sdim{
48263560Sdim	return __cmpdi2(a, b) - 1;
49263560Sdim}
50263560Sdim#endif
51263560Sdim
52