1276789Sdim/* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===
2276789Sdim *
3276789Sdim *                     The LLVM Compiler Infrastructure
4276789Sdim *
5276789Sdim * This file is dual licensed under the MIT and the University of Illinois Open
6276789Sdim * Source Licenses. See LICENSE.TXT for details.
7276789Sdim *
8276789Sdim * ===----------------------------------------------------------------------===
9276789Sdim *
10276789Sdim * This file implements __ucmpti2 for the compiler_rt library.
11276789Sdim *
12276789Sdim * ===----------------------------------------------------------------------===
13276789Sdim */
14276789Sdim
15276789Sdim#include "int_lib.h"
16276789Sdim
17276789Sdim#ifdef CRT_HAS_128BIT
18276789Sdim
19276789Sdim/* Returns:  if (a <  b) returns 0
20276789Sdim *           if (a == b) returns 1
21276789Sdim *           if (a >  b) returns 2
22276789Sdim */
23276789Sdim
24276789SdimCOMPILER_RT_ABI si_int
25276789Sdim__ucmpti2(tu_int a, tu_int b)
26276789Sdim{
27276789Sdim    utwords x;
28276789Sdim    x.all = a;
29276789Sdim    utwords y;
30276789Sdim    y.all = b;
31276789Sdim    if (x.s.high < y.s.high)
32276789Sdim        return 0;
33276789Sdim    if (x.s.high > y.s.high)
34276789Sdim        return 2;
35276789Sdim    if (x.s.low < y.s.low)
36276789Sdim        return 0;
37276789Sdim    if (x.s.low > y.s.low)
38276789Sdim        return 2;
39276789Sdim    return 1;
40276789Sdim}
41276789Sdim
42276789Sdim#endif /* CRT_HAS_128BIT */
43