]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.c
89c367f0360fa9b898de19124a916d8423c2c15e
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / Arm / ucmpdi2.c
1 /** @file
2 Compiler intrinsic for 64-bit compare, ported from LLVM code.
3
4 Copyright (c) 2008-2009, Apple Inc. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9 /**
10 University of Illinois/NCSA
11 Open Source License
12
13 Copyright (c) 2003-2008 University of Illinois at Urbana-Champaign.
14 All rights reserved.
15
16 Developed by:
17
18 LLVM Team
19
20 University of Illinois at Urbana-Champaign
21
22 http://llvm.org
23
24 Permission is hereby granted, free of charge, to any person obtaining a copy of
25 this software and associated documentation files (the "Software"), to deal with
26 the Software without restriction, including without limitation the rights to
27 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28 of the Software, and to permit persons to whom the Software is furnished to do
29 so, subject to the following conditions:
30
31 * Redistributions of source code must retain the above copyright notice,
32 this list of conditions and the following disclaimers.
33
34 * Redistributions in binary form must reproduce the above copyright notice,
35 this list of conditions and the following disclaimers in the
36 documentation and/or other materials provided with the distribution.
37
38 * Neither the names of the LLVM Team, University of Illinois at
39 Urbana-Champaign, nor the names of its contributors may be used to
40 endorse or promote products derived from this Software without specific
41 prior written permission.
42
43 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
45 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46 CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
49 SOFTWARE.
50 **/
51
52
53 #include "Llvm_int_lib.h"
54
55
56 // Returns: if (a < b) returns 0
57 // if (a == b) returns 1
58 // if (a > b) returns 2
59
60 UINT32
61 __ucmpdi2(UINT64 a, UINT64 b)
62 {
63 udwords x;
64 x.all = a;
65 udwords y;
66 y.all = b;
67 if (x.high < y.high)
68 return 0;
69 if (x.high > y.high)
70 return 2;
71 if (x.low < y.low)
72 return 0;
73 if (x.low > y.low)
74 return 2;
75 return 1;
76 }