Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/ashlti3.c
35260 views
//===-- ashlti3.c - Implement __ashlti3 -----------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements __ashlti3 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314#ifdef CRT_HAS_128BIT1516// Returns: a << b1718// Precondition: 0 <= b < bits_in_tword1920COMPILER_RT_ABI ti_int __ashlti3(ti_int a, int b) {21const int bits_in_dword = (int)(sizeof(di_int) * CHAR_BIT);22twords input;23twords result;24input.all = a;25if (b & bits_in_dword) /* bits_in_dword <= b < bits_in_tword */ {26result.s.low = 0;27result.s.high = input.s.low << (b - bits_in_dword);28} else /* 0 <= b < bits_in_dword */ {29if (b == 0)30return a;31result.s.low = input.s.low << b;32result.s.high =33((du_int)input.s.high << b) | (input.s.low >> (bits_in_dword - b));34}35return result.all;36}3738#endif // CRT_HAS_128BIT394041