Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/cmpdi2.c
35260 views
//===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements __cmpdi2 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314// Returns: if (a < b) returns 015// if (a == b) returns 116// if (a > b) returns 21718COMPILER_RT_ABI si_int __cmpdi2(di_int a, di_int b) {19dwords x;20x.all = a;21dwords y;22y.all = b;23if (x.s.high < y.s.high)24return 0;25if (x.s.high > y.s.high)26return 2;27if (x.s.low < y.s.low)28return 0;29if (x.s.low > y.s.low)30return 2;31return 1;32}3334#ifdef __ARM_EABI__35// Returns: if (a < b) returns -136// if (a == b) returns 037// if (a > b) returns 138COMPILER_RT_ABI si_int __aeabi_lcmp(di_int a, di_int b) {39return __cmpdi2(a, b) - 1;40}41#endif424344