mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-05 00:48:08 +00:00

This patch changes types of some integer function arguments or return values from `si_int` to the default `int` type to make it more compatible with `libgcc`. The compiler-rt/lib/builtins/README.txt has a link to the [libgcc specification](http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc). This specification has an explicit note on `int`, `float` and other such types being just illustrations in some cases while the actual types are expressed with machine modes. Such usage of always-32-bit-wide integer type may lead to issues on 16-bit platforms such as MSP430. Provided [libgcc2.h](https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=libgcc/libgcc2.h;hb=HEAD) can be used as a reference for all targets supported by the libgcc, this patch fixes some existing differences in helper declarations. This patch is expected to not change behavior at all for targets with 32-bit `int` type. Differential Revision: https://reviews.llvm.org/D81285
30 lines
786 B
C
30 lines
786 B
C
//===-- powidf2.cpp - Implement __powidf2 ---------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements __powidf2 for the compiler_rt library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "int_lib.h"
|
|
|
|
// Returns: a ^ b
|
|
|
|
COMPILER_RT_ABI double __powidf2(double a, int b) {
|
|
const int recip = b < 0;
|
|
double r = 1;
|
|
while (1) {
|
|
if (b & 1)
|
|
r *= a;
|
|
b /= 2;
|
|
if (b == 0)
|
|
break;
|
|
a *= a;
|
|
}
|
|
return recip ? 1 / r : r;
|
|
}
|