blob: c2b1f69f4fc261376f10e75147ba00a074cd8f7f [file] [log] [blame]
Edward O'Callaghan55836322009-08-07 20:30:091/* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===
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'Callaghan55836322009-08-07 20:30:097 *
8 * ===----------------------------------------------------------------------===
Anton Korobeynikove63da932011-04-19 17:52:099 *
Edward O'Callaghan55836322009-08-07 20:30:0910 * This file implements __cmpdi2 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Daniel Dunbarfd089992009-06-26 16:47:0314
15#include "int_lib.h"
16
Anton Korobeynikove63da932011-04-19 17:52:0917/* Returns: if (a < b) returns 0
Edward O'Callaghan55836322009-08-07 20:30:0918* if (a == b) returns 1
19* if (a > b) returns 2
20*/
Daniel Dunbarfd089992009-06-26 16:47:0321
Anton Korobeynikove63da932011-04-19 17:52:0922COMPILER_RT_ABI si_int
Daniel Dunbarfd089992009-06-26 16:47:0323__cmpdi2(di_int a, di_int b)
24{
25 dwords x;
26 x.all = a;
27 dwords y;
28 y.all = b;
Edward O'Callaghanccf48132009-08-09 18:41:0229 if (x.s.high < y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:0330 return 0;
Edward O'Callaghanccf48132009-08-09 18:41:0231 if (x.s.high > y.s.high)
Daniel Dunbarfd089992009-06-26 16:47:0332 return 2;
Edward O'Callaghanccf48132009-08-09 18:41:0233 if (x.s.low < y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:0334 return 0;
Edward O'Callaghanccf48132009-08-09 18:41:0235 if (x.s.low > y.s.low)
Daniel Dunbarfd089992009-06-26 16:47:0336 return 2;
37 return 1;
38}