mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-11 03:08:41 +00:00
92 lines
1.7 KiB
C
92 lines
1.7 KiB
C
/**
|
|
* Jingga
|
|
*
|
|
* @copyright Jingga
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
#ifndef TOS_STDLIB_INTRINSICS_ARM_H
|
|
#define TOS_STDLIB_INTRINSICS_ARM_H
|
|
|
|
#include <arm_sve.h>
|
|
#include <arm_acle.h>
|
|
|
|
inline float oms_sqrt(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svfloat32_t result = svsqrt_f32(input);
|
|
|
|
return svget1_f32(result);
|
|
}
|
|
|
|
inline double oms_sqrt(double a) {
|
|
svfloat64_t input = svdup_f64(a);
|
|
svfloat64_t result = svsqrt_f64(input);
|
|
|
|
return svget1_f64(result);
|
|
}
|
|
|
|
inline float oms_rsqrt(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svfloat32_t result = svrsqrte_f32(input);
|
|
|
|
return svget1_f32(result);
|
|
}
|
|
|
|
inline double oms_rsqrt(double a) {
|
|
svfloat64_t input = svdup_f64(a);
|
|
svfloat64_t result = svrsqrte_f64(input);
|
|
|
|
return svget1_f64(result);
|
|
}
|
|
|
|
inline float oms_round(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svfloat32_t result = svrndn_f32(input);
|
|
|
|
return svget1_f32(result);
|
|
}
|
|
|
|
inline uint32_t round_to_int(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svint32_t result = svcvtn_f32_s32(input, SVE_32B);
|
|
|
|
return svget1_s32(result);
|
|
}
|
|
|
|
inline float oms_floor(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svfloat32_t result = svfloor_f32(input);
|
|
|
|
return svget1_f32(result);
|
|
}
|
|
|
|
inline float oms_ceil(float a) {
|
|
svfloat32_t input = svdup_f32(a);
|
|
svfloat32_t result = svceil_f32(input);
|
|
|
|
return svget1_f32(result);
|
|
}
|
|
|
|
inline void oms_fence_memory()
|
|
{
|
|
__dmb(0xF);
|
|
}
|
|
|
|
inline void oms_fence_write()
|
|
{
|
|
__dmb(0xB);
|
|
}
|
|
|
|
inline void oms_fence_load()
|
|
{
|
|
__dmb(0x7);
|
|
}
|
|
|
|
inline
|
|
void oms_invalidate_cache(void* address)
|
|
{
|
|
asm volatile("dc ivac, %0" : : "r"(address) : "memory");
|
|
}
|
|
|
|
#endif |