blob: 6931a6f8842769b8100bbbb4fb6cb57300c960f0 [file] [log] [blame]
Edward O'Callaghan2bf62722009-08-05 04:02:56 +00001/* ===-- negvsi2.c - Implement __negvsi2 -----------------------------------===
2 *
Chandler Carruth7a739a02019-01-19 10:56:40 +00003 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Edward O'Callaghan2bf62722009-08-05 04:02:56 +00006 *
7 * ===----------------------------------------------------------------------===
8 *
9 * This file implements __negvsi2 for the compiler_rt library.
10 *
11 * ===----------------------------------------------------------------------===
12 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000013
14#include "int_lib.h"
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015
Edward O'Callaghan2bf62722009-08-05 04:02:56 +000016/* Returns: -a */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000017
Edward O'Callaghan2bf62722009-08-05 04:02:56 +000018/* Effects: aborts if -a overflows */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000019
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000020COMPILER_RT_ABI si_int
Daniel Dunbarb3a69012009-06-26 16:47:03 +000021__negvsi2(si_int a)
22{
23 const si_int MIN = (si_int)1 << ((int)(sizeof(si_int) * CHAR_BIT)-1);
24 if (a == MIN)
Daniel Dunbar48f46ac2010-03-31 17:00:45 +000025 compilerrt_abort();
Daniel Dunbarb3a69012009-06-26 16:47:03 +000026 return -a;
27}