204 lines
3.8 KiB
C
204 lines
3.8 KiB
C
/**
|
|
* Part of the Lccrt Project, under the Apache License v2.0
|
|
* See http://www.apache.org/licenses/LICENSE-2.0.txt for license information.
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "lccrt_s.h"
|
|
|
|
#include <assert.h>
|
|
|
|
uint64_t
|
|
__lccrt_ctlz_8( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_clz( a & 0xff) - 24;
|
|
|
|
return (r);
|
|
} /* __lccrt_ctlz_8 */
|
|
|
|
uint64_t
|
|
__lccrt_ctlz_16( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_clz( a & 0xffff) - 16;
|
|
|
|
return (r);
|
|
} /* __lccrt_ctlz_16 */
|
|
|
|
uint64_t
|
|
__lccrt_ctlz_32( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_clz( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctlz_32 */
|
|
|
|
uint64_t
|
|
__lccrt_ctlz_64( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_clzll( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctlz_64 */
|
|
|
|
uint64_t
|
|
__lccrt_cttz_8( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_ctz( a | (1U << 8U));
|
|
|
|
return (r);
|
|
} /* __lccrt_cttz_8 */
|
|
|
|
uint64_t
|
|
__lccrt_cttz_16( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_ctz( a | (1U << 16U));
|
|
|
|
return (r);
|
|
} /* __lccrt_cttz_16 */
|
|
|
|
uint64_t
|
|
__lccrt_cttz_32( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_ctz( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_cttz_32 */
|
|
|
|
uint64_t
|
|
__lccrt_cttz_64( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_ctzll( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_cttz_64 */
|
|
|
|
uint64_t
|
|
__lccrt_ctpop_i8( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_popcount( a & 0xff);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctpop_i8 */
|
|
|
|
uint64_t
|
|
__lccrt_ctpop_i16( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_popcount( a & 0xffff);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctpop_i16 */
|
|
|
|
uint64_t
|
|
__lccrt_ctpop_i32( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_popcount( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctpop_i32 */
|
|
|
|
uint64_t
|
|
__lccrt_ctpop_i64( uint64_t a)
|
|
{
|
|
uint64_t r = __builtin_popcountll( a);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctpop_i64 */
|
|
|
|
__lccrt_uint128_t
|
|
__lccrt_ctpop_i128( __lccrt_uint128_t a)
|
|
{
|
|
__lccrt_uint128_t r = {0};
|
|
|
|
r.lo = __builtin_popcountll( a.hi) + __builtin_popcountll( a.lo);
|
|
|
|
return (r);
|
|
} /* __lccrt_ctpop_i128 */
|
|
|
|
double __lccrt___lccrt_sqrt_f64( double) asm( "__lccrt_sqrt.f64");
|
|
|
|
double
|
|
__lccrt___lccrt_sqrt_f64( double a)
|
|
{
|
|
assert( 0);
|
|
}
|
|
|
|
void
|
|
__builtin_lccopt_mul_4_x_i8( void)
|
|
{
|
|
assert( 0);
|
|
}
|
|
|
|
void
|
|
__builtin_lccopt_shuffle_4_x_i8( void)
|
|
{
|
|
assert( 0);
|
|
}
|
|
|
|
#if defined( __LCC__) && (__LCC__ <= 123)
|
|
__lccrt_complex_f32
|
|
__mulsc3( float a, float b, float c, float d)
|
|
{
|
|
__lccrt_complex_f32 r = {a*c - b*d, a*d + b*c};
|
|
|
|
return (r);
|
|
} /* __mulsc3 */
|
|
#endif /* __LCC__ <= 123 */
|
|
|
|
#if defined( __LCC__) && (__LCC__ <= 123)
|
|
__lccrt_complex_f64
|
|
__muldc3( __lccrt_f64_t a, __lccrt_f64_t b, __lccrt_f64_t c, __lccrt_f64_t d)
|
|
{
|
|
__lccrt_complex_f64 r = {a*c - b*d, a*d + b*c};
|
|
|
|
return (r);
|
|
} /* __muldc3 */
|
|
#endif /* __LCC__ <= 123 */
|
|
|
|
#if defined( __LCC__) && (__LCC__ <= 123)
|
|
__lccrt_complex_f32
|
|
__divsc3( float a, float b, float c, float d)
|
|
{
|
|
float v2 = c*c + d*d;
|
|
__lccrt_complex_f32 r = {(a*c - b*d)/v2, (a*d + b*c)/v2};
|
|
|
|
return (r);
|
|
} /* __divsc3 */
|
|
#endif /* __LCC__ <= 123 */
|
|
|
|
#if defined( __LCC__) && (__LCC__ <= 123)
|
|
__lccrt_complex_f64
|
|
__divdc3( __lccrt_f64_t a, __lccrt_f64_t b, __lccrt_f64_t c, __lccrt_f64_t d)
|
|
{
|
|
__lccrt_f64_t v2 = c*c + d*d;
|
|
__lccrt_complex_f64 r = {(a*c - b*d)/v2, (a*d + b*c)/v2};
|
|
|
|
return (r);
|
|
} /* __divdc3 */
|
|
#endif /* __LCC__ <= 123 */
|
|
|
|
extern void __lccrt_lifetime_start( void) asm( "llvm.lifetime.start.p0i8");
|
|
extern void __lccrt_lifetime_end( void) asm( "llvm.lifetime.end.p0i8");
|
|
extern void *__lccrt_frameaddress( void) asm( "llvm.frameaddress.p0i8");
|
|
|
|
void __lccrt_lifetime_start( void) {}
|
|
void __lccrt_lifetime_end( void) {}
|
|
void *__lccrt_frameaddress() { return (0); }
|
|
|
|
void __lccrt_stacksave( void) { assert( 0); }
|
|
void __lccrt_stackrestore( void) { assert( 0); }
|
|
|
|
int8_t
|
|
__atomic_fetch_max_1( int8_t *a, int8_t b)
|
|
{
|
|
assert( 0);
|
|
return (0);
|
|
} /* __atomic_fetch_max_1 */
|
|
|
|
uint8_t
|
|
__lccrt_typetest_unsupported_yet( void)
|
|
{
|
|
assert( 0);
|
|
|
|
return (0);
|
|
} /* __lccrt_typetest_unsupported_yet */
|