Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 1 | /* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------=== |
| 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
Howard Hinnant | 5b791f6 | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | * This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | * Source Licenses. See LICENSE.TXT for details. |
Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 7 | * |
| 8 | * ===----------------------------------------------------------------------=== |
Anton Korobeynikov | e63da93 | 2011-04-19 17:52:09 +0000 | [diff] [blame^] | 9 | * |
Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 10 | * This file implements __cmpdi2 for the compiler_rt library. |
| 11 | * |
| 12 | * ===----------------------------------------------------------------------=== |
| 13 | */ |
Anton Korobeynikov | e63da93 | 2011-04-19 17:52:09 +0000 | [diff] [blame^] | 14 | #include "abi.h" |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 15 | |
| 16 | #include "int_lib.h" |
| 17 | |
Anton Korobeynikov | e63da93 | 2011-04-19 17:52:09 +0000 | [diff] [blame^] | 18 | /* Returns: if (a < b) returns 0 |
Edward O'Callaghan | 5583632 | 2009-08-07 20:30:09 +0000 | [diff] [blame] | 19 | * if (a == b) returns 1 |
| 20 | * if (a > b) returns 2 |
| 21 | */ |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 22 | |
Anton Korobeynikov | e63da93 | 2011-04-19 17:52:09 +0000 | [diff] [blame^] | 23 | COMPILER_RT_ABI si_int |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 24 | __cmpdi2(di_int a, di_int b) |
| 25 | { |
| 26 | dwords x; |
| 27 | x.all = a; |
| 28 | dwords y; |
| 29 | y.all = b; |
Edward O'Callaghan | ccf4813 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 30 | if (x.s.high < y.s.high) |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 31 | return 0; |
Edward O'Callaghan | ccf4813 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 32 | if (x.s.high > y.s.high) |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 33 | return 2; |
Edward O'Callaghan | ccf4813 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 34 | if (x.s.low < y.s.low) |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 35 | return 0; |
Edward O'Callaghan | ccf4813 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 36 | if (x.s.low > y.s.low) |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 37 | return 2; |
| 38 | return 1; |
| 39 | } |