brintos

brintos / llvm-project-archived public Read only

0
0
Text · 974 B · 7f0ee1b Raw
38 lines · c
1//===-- cmpti2.c - Implement __cmpti2 -------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements __cmpti2 for the compiler_rt library.10//11//===----------------------------------------------------------------------===//12 13#include "int_lib.h"14 15#ifdef CRT_HAS_128BIT16 17// Returns:  if (a <  b) returns 018//           if (a == b) returns 119//           if (a >  b) returns 220 21COMPILER_RT_ABI si_int __cmpti2(ti_int a, ti_int b) {22  twords x;23  x.all = a;24  twords y;25  y.all = b;26  if (x.s.high < y.s.high)27    return 0;28  if (x.s.high > y.s.high)29    return 2;30  if (x.s.low < y.s.low)31    return 0;32  if (x.s.low > y.s.low)33    return 2;34  return 1;35}36 37#endif // CRT_HAS_128BIT38