From 775355a88a0927e2e3a855036c26950397a61d7b Mon Sep 17 00:00:00 2001 From: davem69 Date: Tue, 5 Jun 2001 23:54:00 +0000 Subject: Sparc optimized GLAPI dispatch table. --- src/mesa/glapi/glapi.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index b2a10133b25..e9887551f9a 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -1,4 +1,4 @@ -/* $Id: glapi.c,v 1.54 2001/05/29 15:23:49 brianp Exp $ */ +/* $Id: glapi.c,v 1.55 2001/06/05 23:54:00 davem69 Exp $ */ /* * Mesa 3-D graphics library @@ -52,7 +52,9 @@ #include "glapitable.h" #include "glthread.h" - +#ifdef USE_SPARC_ASM +#include "SPARC/sparc.h" +#endif /***** BEGIN NO-OP DISPATCH *****/ @@ -1754,6 +1756,55 @@ generate_entrypoint(GLuint functionOffset) *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4; } return code; +#elif defined(USE_SPARC_ASM) + +#ifdef __sparc_v9__ + static const unsigned int insn_template[] = { + 0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */ + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */ + 0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */ + 0x8528b020, /* sllx %g2, 32, %g2 */ + 0xc2584002, /* ldx [%g1 + %g2], %g1 */ + 0x05000000, /* sethi %hi(8 * glapioffset), %g2 */ + 0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */ + 0xc6584002, /* ldx [%g1 + %g2], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ + }; +#else + static const unsigned int insn_template[] = { + 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */ + 0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */ + 0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */ + 0x81c0c000, /* jmpl %g3, %g0 */ + 0x01000000 /* nop */ + }; +#endif + unsigned int *code = malloc(sizeof(insn_template)); + unsigned long glapi_addr = (unsigned long) &_glapi_Dispatch; + if (code) { + memcpy(code, insn_template, sizeof(insn_template)); + +#ifdef __sparc_v9__ + code[0] |= (glapi_addr >> (32 + 10)); + code[1] |= ((glapi_addr & 0xffffffff) >> 10); + _mesa_sparc_icache_flush(&code[0]); + code[2] |= ((glapi_addr >> 32) & ((1 << 10) - 1)); + code[3] |= (glapi_addr & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[2]); + code[6] |= ((functionOffset * 8) >> 10); + code[7] |= ((functionOffset * 8) & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[6]); +#else + code[0] |= (glapi_addr >> 10); + code[1] |= (glapi_addr & ((1 << 10) - 1)); + _mesa_sparc_icache_flush(&code[0]); + code[2] |= (functionOffset * 4); + _mesa_sparc_icache_flush(&code[2]); +#endif + } + return code; #else return NULL; #endif -- cgit v1.2.3