13cab2bb3Spatrick //===-- parityti2.c - Implement __parityti2 -------------------------------===// 23cab2bb3Spatrick // 33cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information. 53cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63cab2bb3Spatrick // 73cab2bb3Spatrick //===----------------------------------------------------------------------===// 83cab2bb3Spatrick // 93cab2bb3Spatrick // This file implements __parityti2 for the compiler_rt library. 103cab2bb3Spatrick // 113cab2bb3Spatrick //===----------------------------------------------------------------------===// 123cab2bb3Spatrick 133cab2bb3Spatrick #include "int_lib.h" 143cab2bb3Spatrick 153cab2bb3Spatrick #ifdef CRT_HAS_128BIT 163cab2bb3Spatrick 173cab2bb3Spatrick // Returns: 1 if number of bits is odd else returns 0 183cab2bb3Spatrick __parityti2(ti_int a)191f9cb04fSpatrickCOMPILER_RT_ABI int __parityti2(ti_int a) { 203cab2bb3Spatrick twords x; 21*d89ec533Spatrick dwords x2; 223cab2bb3Spatrick x.all = a; 23*d89ec533Spatrick x2.all = x.s.high ^ x.s.low; 24*d89ec533Spatrick su_int x3 = x2.s.high ^ x2.s.low; 25*d89ec533Spatrick x3 ^= x3 >> 16; 26*d89ec533Spatrick x3 ^= x3 >> 8; 27*d89ec533Spatrick x3 ^= x3 >> 4; 28*d89ec533Spatrick return (0x6996 >> (x3 & 0xF)) & 1; 293cab2bb3Spatrick } 303cab2bb3Spatrick 313cab2bb3Spatrick #endif // CRT_HAS_128BIT 32