replace abs with c macro; replace round with asm extern function (#647)

Co-authored-by: someone2639 <someone2639@gmail.com>
This commit is contained in:
someone2639
2023-06-25 23:57:21 -04:00
committed by GitHub
parent 13b8339560
commit 1eba347c07
3 changed files with 15 additions and 18 deletions

10
asm/round.s Normal file
View File

@@ -0,0 +1,10 @@
.include "macros.inc"
.section .text
.set noreorder
.set abi_arg0, $f12
glabel roundf
round.w.s $f0, abi_arg0
jr $ra
mfc1 $v0, $f0

View File

@@ -160,6 +160,7 @@ SECTIONS
#ifdef EEP
KEEP(BUILD_DIR/asm/vc_bin.o(.text*));
#endif
KEEP(BUILD_DIR/asm/round.o(.text*));
BUILD_DIR/src/boot*.o(.text*);
BUILD_DIR/src/hvqm*.o(.text*);

View File

@@ -451,27 +451,13 @@ extern f32 gSineTable[];
#define ABS(x) (((x) > 0) ? (x) : -(x))
/// From Wiseguy
ALWAYS_INLINE s32 roundf(f32 in) {
f32 tmp;
s32 out;
__asm__("round.w.s %0,%1" : "=f" (tmp) : "f" (in ));
__asm__("mfc1 %0,%1" : "=r" (out) : "f" (tmp));
return out;
}
extern s32 roundf(f32);
// backwards compatibility
#define round_float(in) roundf(in)
/// Absolute value
ALWAYS_INLINE f32 absf(f32 in) {
f32 out;
__asm__("abs.s %0,%1" : "=f" (out) : "f" (in));
return out;
}
ALWAYS_INLINE s32 absi(s32 in) {
return ABS(in);
}
#define abss absi
#define absf ABS
#define absi ABS
#define abss ABS
#define FLT_IS_NONZERO(x) (absf(x) > NEAR_ZERO)