1*156cd587Sjoerg /* ===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------=== 2*156cd587Sjoerg * 3*156cd587Sjoerg * The LLVM Compiler Infrastructure 4*156cd587Sjoerg * 5*156cd587Sjoerg * This file is dual licensed under the MIT and the University of Illinois Open 6*156cd587Sjoerg * Source Licenses. See LICENSE.TXT for details. 7*156cd587Sjoerg * 8*156cd587Sjoerg * ===----------------------------------------------------------------------=== 9*156cd587Sjoerg * 10*156cd587Sjoerg * This file implements __cmpdi2 for the compiler_rt library. 11*156cd587Sjoerg * 12*156cd587Sjoerg * ===----------------------------------------------------------------------=== 13*156cd587Sjoerg */ 14*156cd587Sjoerg 15*156cd587Sjoerg #include "int_lib.h" 16*156cd587Sjoerg 17*156cd587Sjoerg /* Returns: if (a < b) returns 0 18*156cd587Sjoerg * if (a == b) returns 1 19*156cd587Sjoerg * if (a > b) returns 2 20*156cd587Sjoerg */ 21*156cd587Sjoerg 22*156cd587Sjoerg COMPILER_RT_ABI si_int __cmpdi2(di_int a,di_int b)23*156cd587Sjoerg__cmpdi2(di_int a, di_int b) 24*156cd587Sjoerg { 25*156cd587Sjoerg dwords x; 26*156cd587Sjoerg x.all = a; 27*156cd587Sjoerg dwords y; 28*156cd587Sjoerg y.all = b; 29*156cd587Sjoerg if (x.s.high < y.s.high) 30*156cd587Sjoerg return 0; 31*156cd587Sjoerg if (x.s.high > y.s.high) 32*156cd587Sjoerg return 2; 33*156cd587Sjoerg if (x.s.low < y.s.low) 34*156cd587Sjoerg return 0; 35*156cd587Sjoerg if (x.s.low > y.s.low) 36*156cd587Sjoerg return 2; 37*156cd587Sjoerg return 1; 38*156cd587Sjoerg } 39*156cd587Sjoerg 40*156cd587Sjoerg #ifdef __ARM_EABI__ 41*156cd587Sjoerg /* Returns: if (a < b) returns -1 42*156cd587Sjoerg * if (a == b) returns 0 43*156cd587Sjoerg * if (a > b) returns 1 44*156cd587Sjoerg */ 45*156cd587Sjoerg COMPILER_RT_ABI si_int __aeabi_lcmp(di_int a,di_int b)46*156cd587Sjoerg__aeabi_lcmp(di_int a, di_int b) 47*156cd587Sjoerg { 48*156cd587Sjoerg return __cmpdi2(a, b) - 1; 49*156cd587Sjoerg } 50*156cd587Sjoerg #endif 51*156cd587Sjoerg 52