1214152Sed/* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------===
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 * ===----------------------------------------------------------------------===
9214152Sed *
10214152Sed * This file implements __cmpti2 for the compiler_rt library.
11214152Sed *
12214152Sed * ===----------------------------------------------------------------------===
13214152Sed */
14214152Sed
15263560Sdim#include "int_lib.h"
16263560Sdim
17263764Sdim#ifdef CRT_HAS_128BIT
18214152Sed
19214152Sed/* Returns:  if (a <  b) returns 0
20214152Sed *           if (a == b) returns 1
21214152Sed *           if (a >  b) returns 2
22214152Sed */
23214152Sed
24214152Sedsi_int
25214152Sed__cmpti2(ti_int a, ti_int b)
26214152Sed{
27214152Sed    twords x;
28214152Sed    x.all = a;
29214152Sed    twords y;
30214152Sed    y.all = b;
31214152Sed    if (x.s.high < y.s.high)
32214152Sed        return 0;
33214152Sed    if (x.s.high > y.s.high)
34214152Sed        return 2;
35214152Sed    if (x.s.low < y.s.low)
36214152Sed        return 0;
37214152Sed    if (x.s.low > y.s.low)
38214152Sed        return 2;
39214152Sed    return 1;
40214152Sed}
41214152Sed
42263764Sdim#endif /* CRT_HAS_128BIT */
43