blob: 5466d217428f8fce46ab41917eac682e69799419 [file] [log] [blame]
Edward O'Callaghan1fcb40b2009-08-05 19:06:50 +00001/* ===-- ucmpti2.c - Implement __ucmpti2 -----------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant9ad441f2010-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'Callaghan1fcb40b2009-08-05 19:06:50 +00007 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file implements __ucmpti2 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000014
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015#include "int_lib.h"
16
Chandler Carruth7f2d7c72012-06-22 21:09:22 +000017#if __x86_64
18
Edward O'Callaghan1fcb40b2009-08-05 19:06:50 +000019/* Returns: if (a < b) returns 0
20 * if (a == b) returns 1
21 * if (a > b) returns 2
22 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000023
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'Callaghanaabd9612009-09-03 09:12:20 +000031 if (x.s.high < y.s.high)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000032 return 0;
Edward O'Callaghanaabd9612009-09-03 09:12:20 +000033 if (x.s.high > y.s.high)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000034 return 2;
Edward O'Callaghanaabd9612009-09-03 09:12:20 +000035 if (x.s.low < y.s.low)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000036 return 0;
Edward O'Callaghanaabd9612009-09-03 09:12:20 +000037 if (x.s.low > y.s.low)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000038 return 2;
39 return 1;
40}
41
42#endif