1353358Sdim//===-- negvsi2.c - Implement __negvsi2 -----------------------------------===// 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 __negvsi2 for the compiler_rt library. 10353358Sdim// 11353358Sdim//===----------------------------------------------------------------------===// 12276789Sdim 13276789Sdim#include "int_lib.h" 14276789Sdim 15353358Sdim// Returns: -a 16276789Sdim 17353358Sdim// Effects: aborts if -a overflows 18276789Sdim 19353358SdimCOMPILER_RT_ABI si_int __negvsi2(si_int a) { 20353358Sdim const si_int MIN = (si_int)1 << ((int)(sizeof(si_int) * CHAR_BIT) - 1); 21353358Sdim if (a == MIN) 22353358Sdim compilerrt_abort(); 23353358Sdim return -a; 24276789Sdim} 25