1353358Sdim//===-- cmpti2.c - Implement __cmpti2 -------------------------------------===// 2353358Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6353358Sdim// 7353358Sdim//===----------------------------------------------------------------------===// 8353358Sdim// 9353358Sdim// This file implements __cmpti2 for the compiler_rt library. 10353358Sdim// 11353358Sdim//===----------------------------------------------------------------------===// 12276789Sdim 13276789Sdim#include "int_lib.h" 14276789Sdim 15276789Sdim#ifdef CRT_HAS_128BIT 16276789Sdim 17353358Sdim// Returns: if (a < b) returns 0 18353358Sdim// if (a == b) returns 1 19353358Sdim// if (a > b) returns 2 20276789Sdim 21353358SdimCOMPILER_RT_ABI si_int __cmpti2(ti_int a, ti_int b) { 22353358Sdim twords x; 23353358Sdim x.all = a; 24353358Sdim twords y; 25353358Sdim y.all = b; 26353358Sdim if (x.s.high < y.s.high) 27353358Sdim return 0; 28353358Sdim if (x.s.high > y.s.high) 29353358Sdim return 2; 30353358Sdim if (x.s.low < y.s.low) 31353358Sdim return 0; 32353358Sdim if (x.s.low > y.s.low) 33353358Sdim return 2; 34353358Sdim return 1; 35276789Sdim} 36276789Sdim 37353358Sdim#endif // CRT_HAS_128BIT 38