blob: 2c8b56e29a067f82775ee32de6848cb1e93fc37b [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
Daniel Dunbarfd089992009-06-26 16:47:03 +000015#include "int_lib.h"
16
Joerg Sonnenberger938b0df2014-02-21 23:53:03 +000017#ifdef CRT_HAS_128BIT
Chandler Carruth6e2bf8f2012-06-22 21:09:22 +000018
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
Joerg Sonnenberger6e99daa2014-03-01 15:30:50 +000024COMPILER_RT_ABI si_int
Daniel Dunbarfd089992009-06-26 16:47:03 +000025__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
Joerg Sonnenberger938b0df2014-02-21 23:53:03 +000042#endif /* CRT_HAS_128BIT */