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}
39245628Sandrew
40245628Sandrew#ifdef __ARM_EABI__
41245628Sandrew/* Returns: if (a <  b) returns -1
42245628Sandrew*           if (a == b) returns  0
43245628Sandrew*           if (a >  b) returns  1
44245628Sandrew*/
45245628SandrewCOMPILER_RT_ABI si_int
46245628Sandrew__aeabi_lcmp(di_int a, di_int b)
47245628Sandrew{
48245628Sandrew	return __cmpdi2(a, b) - 1;
49245628Sandrew}
50245628Sandrew#endif
51245628Sandrew
52