[clang] Handle __declspec() attributes in using
[llvm-project.git] / compiler-rt / lib / builtins / cmpdi2.c
blob951db85b5062e8f6a18dd5ab79d69f5b90379f5c
1 //===-- cmpdi2.c - Implement __cmpdi2 -------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements __cmpdi2 for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
13 #include "int_lib.h"
15 // Returns: if (a < b) returns 0
16 // if (a == b) returns 1
17 // if (a > b) returns 2
19 COMPILER_RT_ABI si_int __cmpdi2(di_int a, di_int b) {
20 dwords x;
21 x.all = a;
22 dwords y;
23 y.all = b;
24 if (x.s.high < y.s.high)
25 return 0;
26 if (x.s.high > y.s.high)
27 return 2;
28 if (x.s.low < y.s.low)
29 return 0;
30 if (x.s.low > y.s.low)
31 return 2;
32 return 1;
35 #ifdef __ARM_EABI__
36 // Returns: if (a < b) returns -1
37 // if (a == b) returns 0
38 // if (a > b) returns 1
39 COMPILER_RT_ABI si_int __aeabi_lcmp(di_int a, di_int b) {
40 return __cmpdi2(a, b) - 1;
42 #endif