blob: b156fce90bfaa48587d767aa210eb2acca1f642c [file] [log] [blame]
Edward O'Callaghan55836322009-08-07 20:30:09 +00001/* ===-- cmpti2.c - Implement __cmpti2 -------------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant5b791f62010-11-16 22:13:33 +00005 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
Edward O'Callaghan55836322009-08-07 20:30:09 +00007 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file implements __cmpti2 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Daniel Dunbarfd089992009-06-26 16:47:03 +000014
15#if __x86_64
16
17#include "int_lib.h"
18
Edward O'Callaghan55836322009-08-07 20:30:09 +000019/* Returns: if (a < b) returns 0
20 * if (a == b) returns 1
21 * if (a > b) returns 2
22 */
Daniel Dunbarfd089992009-06-26 16:47:03 +000023
24si_int
25__cmpti2(ti_int a, ti_int b)
26{
27 twords x;
28 x.all = a;
29 twords y;
30 y.all = b;
Edward O'Callaghan665671e2009-09-03 09:12:20 +000031 if (x.s.high < y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:03 +000032 return 0;
Edward O'Callaghan665671e2009-09-03 09:12:20 +000033 if (x.s.high > y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:03 +000034 return 2;
Edward O'Callaghan665671e2009-09-03 09:12:20 +000035 if (x.s.low < y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:03 +000036 return 0;
Edward O'Callaghan665671e2009-09-03 09:12:20 +000037 if (x.s.low > y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:03 +000038 return 2;
39 return 1;
40}
41
42#endif