blob: 11137c5a5ee0cd401d427baad0e2124c75571f1f [file] [log] [blame]
Edward O'Callaghandabf71f2009-08-05 19:06:501/* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant5b791f62010-11-16 22:13:335 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
Edward O'Callaghandabf71f2009-08-05 19:06:507 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file implements __ucmpti2 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Daniel Dunbarfd089992009-06-26 16:47:0314
15#if __x86_64
16
17#include "int_lib.h"
18
Edward O'Callaghandabf71f2009-08-05 19:06:5019/* 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:0323
24si_int
25__ucmpti2(tu_int a, tu_int b)
26{
27 utwords x;
28 x.all = a;
29 utwords y;
30 y.all = b;
Edward O'Callaghan665671e2009-09-03 09:12:2031 if (x.s.high < y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:0332 return 0;
Edward O'Callaghan665671e2009-09-03 09:12:2033 if (x.s.high > y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:0334 return 2;
Edward O'Callaghan665671e2009-09-03 09:12:2035 if (x.s.low < y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:0336 return 0;
Edward O'Callaghan665671e2009-09-03 09:12:2037 if (x.s.low > y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:0338 return 2;
39 return 1;
40}
41
42#endif