PSPSDK 2024-12-16
Loading...
Searching...
No Matches
pspfpu.h
Go to the documentation of this file.
1/*
2 * PSP Software Development Kit - https://github.com/pspdev
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 *
6 * pspfpu.h - Prototypes for the FPU library
7 *
8 * Copyright (c) 2009 JetCube
9 * Copyright (c) 2006 TyRaNiD (James F.)
10 *
11 */
12#ifndef __PSPFPU_H__
13#define __PSPFPU_H__
14
15#include <stdint.h>
16
17/* Note the bit settings in here come from an NEC MIPSv4 document,
18 * they seem sensible.
19 */
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
37
39#define PSP_FPU_RM_MASK 0x03
40
59
61#define PSP_FPU_FLAGS_POS 2
63#define PSP_FPU_ENABLE_POS 7
65#define PSP_FPU_CAUSE_POS 12
67#define PSP_FPU_CC0_POS 23
69#define PSP_FPU_FS_POS 24
71#define PSP_FPU_CC17_POS 25
72
73#define PSP_FPU_FLAGS_MASK (0x1F << PSP_FPU_FLAGS_POS)
74#define PSP_FPU_ENABLE_MASK (0x1F << PSP_FPU_ENABLE_POS)
75#define PSP_FPU_CAUSE_MASK (0x3F << PSP_FPU_CAUSE_POS)
76#define PSP_FPU_CC0_MASK (1 << PSP_FPU_CC0_POS)
77#define PSP_FPU_FS_MASK (1 << PSP_FPU_FS_POS)
78#define PSP_FPU_CC17_MASK (0x7F << PSP_FPU_CC17_POS)
79
86
93
100
107
115
122
129
135void pspFpuSetEnable(uint32_t enable);
136
143
151
159
166
173
180
184float pspFpuAbs(float f);
185
189int pspFpuCeil(float f);
190
194int pspFpuFloor(float f);
195
199float pspFpuMax(float f1, float f2);
200
204float pspFpuMin(float f1, float f2);
205
209float pspFpuNeg(float f);
210
214int pspFpuRound(float f);
215
216/*
217 * Reciprocal of square root
218 */
219float pspFpuRsqrt(float f);
220
224float pspFpuSqrt(float f);
225
229int pspFpuTrunc(float f);
230
234float pspFpuFmod(float fs, float fd);
235
239float pspFpuFrac(float f);
240
245
250
254int pspFpuIsEqual(float f1, float f2);
255
259float pspFpuSignFloat(float f);
260
264int pspFpuSignInt(float f);
265
269float pspFpuPositiveZero(void);
270
274float pspFpuNegativeZero(void);
275
279int pspFpuIsZero(float f);
280
284int pspFpuIsPositiveZero(float f);
285
289int pspFpuIsNegativeZero(float f);
290
294int pspFpuIsDenormal(float f);
295
299int pspFpuIsZeroOrDenormal(float f);
300
304float pspFpuPositiveInf(void);
305
309float pspFpuNegativeInf(void);
310
314int pspFpuIsInf(float f);
315
319float pspFpuPositiveNaN(void);
320
324float pspFpuNegativeNaN(void);
325
329float pspFpuPositiveQNaN(void);
330
334float pspFpuNegativeQNaN(void);
335
339float pspFpuPositiveSNaN(unsigned int uiSignal);
340
344float pspFpuNegativeSNaN(unsigned int uiSignal);
345
349int pspFpuIsNaN(float f);
350
354int pspFpuIsInfOrNaN(float f);
355
359float pspFpuNormalizePhase(float f);
360
364float pspFpuSin(float x);
365
369float pspFpuCos(float x);
370
374float pspFpuAtan(float x);
375
379float pspFpuLog(float x);
380
384float pspFpuExp(float x);
385
389float pspFpuAsin(float x);
390
394float pspFpuAcos(float x);
395
399double pspFpuFloatToDouble(float a);
400
404float pspFpuDoubleToFloat(double a);
405
406#ifdef __cplusplus
407}
408#endif
409
410#endif /* __PSPFPU_H__ */
int pspFpuIsInfOrNaN(float f)
Test for infinity or NaN.
Definition pspfpu.c:668
int pspFpuFloor(float f)
Truncate.
Definition pspfpu.c:198
uint32_t pspFpuReinterpretUint(float f)
Definition pspfpu.c:293
int pspFpuIsInf(float f)
Test for infinity.
Definition pspfpu.c:515
float pspFpuNegativeQNaN(void)
Quiet NaN (positive QNaN)
Definition pspfpu.c:588
float pspFpuExp(float x)
Exponential.
Definition pspfpu.c:745
void pspFpuClearCondbits(uint32_t clear)
Clear the condition bits.
Definition pspfpu.c:169
int pspFpuIsZeroOrDenormal(float f)
Test for zero or denormalized number.
Definition pspfpu.c:465
int pspFpuIsDenormal(float f)
Test for denormalized number.
Definition pspfpu.c:443
double pspFpuFloatToDouble(float a)
convert float to double
float pspFpuNormalizePhase(float f)
Definition pspfpu.c:689
float pspFpuAsin(float x)
ArcSin.
Definition pspfpu.c:933
float pspFpuSignFloat(float f)
Definition pspfpu.c:322
float pspFpuNegativeInf(void)
Negative infinity.
Definition pspfpu.c:501
float pspFpuMin(float f1, float f2)
select minimum value
Definition pspfpu.c:210
float pspFpuPositiveZero(void)
Positive zero.
Definition pspfpu.c:365
float pspFpuPositiveSNaN(unsigned int uiSignal)
Signaling NaN (positive SNaN)
Definition pspfpu.c:604
float pspFpuSqrt(float f)
Square root.
Definition pspfpu.c:238
float pspFpuAcos(float x)
ArcCos.
Definition pspfpu.c:939
float pspFpuNegativeZero(void)
Negative zero.
Definition pspfpu.c:375
void pspFpuSetRoundmode(enum PspFpuRoundMode mode)
Set the current round mode.
Definition pspfpu.c:64
float pspFpuReinterpretFloat(uint32_t ui)
Definition pspfpu.c:282
int pspFpuRound(float f)
Round to nearest.
Definition pspfpu.c:228
uint32_t pspFpuGetFCR31(void)
Get the current value of the control/status register.
Definition pspfpu.c:43
float pspFpuPositiveNaN(void)
NaN (positive SNaN)
Definition pspfpu.c:538
float pspFpuNeg(float f)
Sign reversal.
Definition pspfpu.c:217
int pspFpuIsNaN(float f)
Test for NaN.
Definition pspfpu.c:644
uint32_t pspFpuGetFlags(void)
Get the exception flags (set when an exception occurs but the actual exception bit is not enabled)
Definition pspfpu.c:79
float pspFpuFrac(float f)
Definition pspfpu.c:266
uint32_t pspFpuGetEnable(void)
Get the exception enable flags.
Definition pspfpu.c:98
void pspFpuSetFCR31(uint32_t var)
Set the current value of the control/status register.
Definition pspfpu.c:55
enum PspFpuRoundMode pspFpuGetRoundmode(void)
Get the current round mode.
Definition pspfpu.c:74
PspFpuExceptions
Enumeration for FPU exceptions.
Definition pspfpu.h:43
@ PSP_FPU_EXCEPTION_DIVBYZERO
Division by zero exception.
Definition pspfpu.h:51
@ PSP_FPU_EXCEPTION_INEXACT
Inexact operation exception.
Definition pspfpu.h:45
@ PSP_FPU_EXCEPTION_INVALIDOP
Invalid operation exception.
Definition pspfpu.h:53
@ PSP_FPU_EXCEPTION_OVERFLOW
Overflow exception.
Definition pspfpu.h:49
@ PSP_FPU_EXCEPTION_ALL
All exceptions.
Definition pspfpu.h:57
@ PSP_FPU_EXCEPTION_UNDERFLOW
Underflow exception.
Definition pspfpu.h:47
@ PSP_FPU_EXCEPTION_UNIMPOP
Unimplemented operation exception (only supported in the cause bits)
Definition pspfpu.h:55
PspFpuRoundMode
Enumeration for FPU rounding modes.
Definition pspfpu.h:27
@ PSP_FPU_RN
Round to nearest representable value.
Definition pspfpu.h:29
@ PSP_FPU_RP
Round towards plus infinity.
Definition pspfpu.h:33
@ PSP_FPU_RM
Round towards minus infinity.
Definition pspfpu.h:35
@ PSP_FPU_RZ
Round towards zero.
Definition pspfpu.h:31
float pspFpuAtan(float x)
Arc tangent.
Definition pspfpu.c:910
void pspFpuClearFlags(uint32_t clear)
Clear the flags bits.
Definition pspfpu.c:88
uint32_t pspFpuGetCondbits(void)
Get the condition flags (8 bits)
Definition pspfpu.c:157
float pspFpuPositiveQNaN(void)
Quiet NaN (positive QNaN)
Definition pspfpu.c:572
float pspFpuNegativeNaN(void)
NaN (negative SNaN)
Definition pspfpu.c:555
float pspFpuSin(float x)
Sine.
Definition pspfpu.c:822
int pspFpuSignInt(float f)
Definition pspfpu.c:345
float pspFpuMax(float f1, float f2)
select maximum value
Definition pspfpu.c:203
float pspFpuCos(float x)
Cosine.
Definition pspfpu.c:860
float pspFpuDoubleToFloat(double a)
convert double to float
float pspFpuFmod(float fs, float fd)
Definition pspfpu.c:248
void pspFpuSetEnable(uint32_t enable)
Set the enable flags bits.
Definition pspfpu.c:107
float pspFpuPositiveInf(void)
Positive infinity.
Definition pspfpu.c:485
float pspFpuNegativeSNaN(unsigned int uiSignal)
Signaling NaN (negative SNaN)
Definition pspfpu.c:624
int pspFpuTrunc(float f)
Round towards zero.
Definition pspfpu.c:243
int pspFpuCeil(float f)
Round up.
Definition pspfpu.c:193
float pspFpuLog(float x)
Natural Logarithm.
Definition pspfpu.c:711
int pspFpuIsZero(float f)
Test for zero value.
Definition pspfpu.c:391
int pspFpuIsNegativeZero(float f)
Test for negative zero.
Definition pspfpu.c:425
uint32_t pspFpuGetCause(void)
Get the cause bits (only useful if you installed your own exception handler)
Definition pspfpu.c:117
void pspFpuClearCause(uint32_t clear)
Clear the cause bits.
Definition pspfpu.c:126
void pspFpuSetFS(uint32_t fs)
Set the FS bit.
Definition pspfpu.c:145
uint32_t pspFpuGetFS(void)
Get the current value of the FS bit (if FS is 0 then an exception occurs with denormalized values,...
Definition pspfpu.c:136
float pspFpuRsqrt(float f)
Definition pspfpu.c:233
int pspFpuIsPositiveZero(float f)
Test for positive zero.
Definition pspfpu.c:410
int pspFpuIsEqual(float f1, float f2)
Definition pspfpu.c:304
float pspFpuAbs(float f)
returns absolute value
Definition pspfpu.c:182
unsigned int ui[4]
Definition psptypes.h:5
float a
Definition psptypes.h:3
float x
Definition psptypes.h:0
float f[4]
Definition psptypes.h:3