cmpti2.c revision 360660
1101099Srwatson//===-- cmpti2.c - Implement __cmpti2 -------------------------------------===// 2101099Srwatson// 3101099Srwatson// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4101099Srwatson// See https://llvm.org/LICENSE.txt for license information. 5101099Srwatson// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6101099Srwatson// 7101099Srwatson//===----------------------------------------------------------------------===// 8106393Srwatson// 9106393Srwatson// This file implements __cmpti2 for the compiler_rt library. 10106393Srwatson// 11106393Srwatson//===----------------------------------------------------------------------===// 12101099Srwatson 13101099Srwatson#include "int_lib.h" 14101099Srwatson 15101099Srwatson#ifdef CRT_HAS_128BIT 16101099Srwatson 17101099Srwatson// Returns: if (a < b) returns 0 18101099Srwatson// if (a == b) returns 1 19101099Srwatson// if (a > b) returns 2 20101099Srwatson 21101099SrwatsonCOMPILER_RT_ABI si_int __cmpti2(ti_int a, ti_int b) { 22101099Srwatson twords x; 23101099Srwatson x.all = a; 24101099Srwatson twords y; 25101099Srwatson y.all = b; 26101099Srwatson if (x.s.high < y.s.high) 27101099Srwatson return 0; 28101099Srwatson if (x.s.high > y.s.high) 29101099Srwatson return 2; 30101099Srwatson if (x.s.low < y.s.low) 31101099Srwatson return 0; 32101099Srwatson if (x.s.low > y.s.low) 33101099Srwatson return 2; 34101099Srwatson return 1; 35101099Srwatson} 36101099Srwatson 37101099Srwatson#endif // CRT_HAS_128BIT 38101099Srwatson