blob: f2d3f99f880eca7241d260b9a9935942372ea6fd [file] [log] [blame]
Edward O'Callaghan37a6a452009-08-07 20:30:09 +00001/* ===-- ucmpdi2.c - Implement __ucmpdi2 -----------------------------------===
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'Callaghan37a6a452009-08-07 20:30:09 +00007 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file implements __ucmpdi2 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000014#include "abi.h"
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015
16#include "int_lib.h"
17
Edward O'Callaghan37a6a452009-08-07 20:30:09 +000018/* Returns: if (a < b) returns 0
19 * if (a == b) returns 1
20 * if (a > b) returns 2
21 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000022
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000023COMPILER_RT_ABI si_int
Daniel Dunbarb3a69012009-06-26 16:47:03 +000024__ucmpdi2(du_int a, du_int b)
25{
26 udwords x;
27 x.all = a;
28 udwords y;
29 y.all = b;
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000030 if (x.s.high < y.s.high)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000031 return 0;
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000032 if (x.s.high > y.s.high)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000033 return 2;
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000034 if (x.s.low < y.s.low)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000035 return 0;
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000036 if (x.s.low > y.s.low)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000037 return 2;
38 return 1;
39}