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