Update of /cvsroot/gc-linux/libgx/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20533/src
Modified Files:
Makefile.am
Added Files:
ps_cast.S ps_cast_init.c
Log Message:
Added PS Fast Casting
--- NEW FILE: ps_cast.S ---
#include "asm.h"
#define DECLARES(prefix,float,int,gqr_arg,gqr) \
_GLOBAL(PSCast##prefix##float##to##int) \
psql f0,0(r3),gqr_arg,gqr0; \
psqst f0,0(r4),gqr_arg,gqr; \
blr; \
_GLOBAL(PSCast##prefix##int##to##float) \
psql f0,0(r3),gqr_arg,gqr; \
psqst f0,0(r4),gqr_arg,gqr0; \
blr;
#define DECLARE(a,b,c) DECLARES(Single,a,b,1,c) DECLARES(Double,a,b,0,c)
DECLARE(F32,U8,gqr2)
DECLARE(F32,U16,gqr3)
DECLARE(F32,S8,gqr4)
DECLARE(F32,S16,gqr5)
_GLOBAL(PSCopy2Floats)
psql f0,0(r4),0,gqr0
psqst f0,0(r3),0,gqr0
blr
--- NEW FILE: ps_cast_init.c ---
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "ps_cast.h"
/* GQR is 2-7 LD_SCALE
13-15 LD_TYPE
18-23 ST_SCALE
29-31 ST_TYPE
ST_TYPE is
0 - single-precision floating-point (no conversion)
1-3 reserved
4 u8
5 u16
6 s8
7 s16
*/
#define TYPE_U8 4
#define TYPE_U16 5
#define TYPE_S8 6
#define TYPE_S16 7
#define SCALE_NONE 0
#define MAKE_GQR(ls,lt,ss,st) (((ls) << 24)|((lt) << 16)|((ss) << 8)|(st))
static int Load(unsigned int gqr,unsigned int value)
{
char fname[64];
int fd;
int len;
int ret;
/* open the device */
sprintf(fname,"/proc/sys/gqr/gqr%i",gqr);
fd = open(fname,O_RDWR);
if (fd < 0)
return errno;
len = sprintf(fname,"%u",value);
ret = (write(fd,fname,len) != len);
close(fd);
return ret;
}
int PSInitFastCast()
{
return (Load(0,0) ||
/* GQR 2 - u8 */
Load(2,MAKE_GQR(SCALE_NONE,TYPE_U8,SCALE_NONE,TYPE_U8)) ||
/* GQR 3 - u16 */
Load(3,MAKE_GQR(SCALE_NONE,TYPE_U16,SCALE_NONE,TYPE_U16)) ||
/* GQR 4 - s8 */
Load(4,MAKE_GQR(SCALE_NONE,TYPE_S8,SCALE_NONE,TYPE_S8)) ||
/* GQR 5 - s16 */
Load(5,MAKE_GQR(SCALE_NONE,TYPE_S16,SCALE_NONE,TYPE_S16)));
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/gc-linux/libgx/src/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 31 Oct 2004 22:34:59 -0000 1.2
+++ Makefile.am 6 Dec 2004 18:35:15 -0000 1.3
@@ -2,5 +2,5 @@
AM_CFLAGS=-Wa,-mgekko -Wa,-mregnames -Wa,-gstabs+
lib_LTLIBRARIES = libgx.la
-libgx_la_SOURCES=gx.c gu.c gx_asm.S gu_asm.S
+libgx_la_SOURCES=gx.c gu.c gx_asm.S gu_asm.S ps_cast_init.c ps_cast.S
|