Mesa (master): mesa: Resurrect SPARC asm code.

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 27 01:31:49 UTC 2009


Module: Mesa
Branch: master
Commit: 857ac1e817808f4b6bf985679162d0e3d709e5b5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=857ac1e817808f4b6bf985679162d0e3d709e5b5

Author: David S. Miller <davem at davemloft.net>
Date:   Thu Feb 26 05:35:15 2009 -0800

mesa: Resurrect SPARC asm code.

This rewrites the sparc GLAPI code so that it's PIC friendly and works
with all of the TLS/PTHREADS/64-bit/32-bit combinations properly.

As a result we can turn SPARC asm back on.  Currently it's only
enabled on Linux, as that's the only place where I can test this
stuff out.

For the moment the cliptest SPARC asm routines are disabled as they
are non-working.  The problem is that they use register %g7 as a
temporary which is where the threading libraries store the thread
pointer on SPARC.  I will fix that code up in a future change as it's
a pretty important routine to optimize.

Like x86 we do the runtime patch as a pthread once-invoked initializer
in init_glapi_relocs().

Unlike x86, however, our GLAPI stubs on SPARC are just two instruction
sequences that branch to a trampoline and put the GLAPI offset into a
register.  The trampoline is what we run-time patch.  The stubs thus
all look like:

glFoo:
	ba		__glapi_sparc_foo_stub
	 sethi		GLAPI_OFFSET(glFOO) * PTR_SIZE, %g3

This actually makes generate_entrypoint() a lot simpler on SPARC.  For
this case in generate_entrypoint() we generate stubs using a 'call'
instead of the 'ba' above to make sure it can reach.

In order to get a proper tail call going here, in the unpatched case,
we do several tricks.  To get the current PC, for example, we save the
return address register into a temporary, do a call, save the return
address register written by the call to another temporary, then
restore the original return address register value.  This is to
avoid having to allocate a stack frame.

This is necessary for PIC address formation.

This new GLAPI scheme lets us get rid of the ugly SPARC GLAPI hacks in
__glXInitialize() and one_time_init().

Signed-off-by: David S. Miller <davem at davemloft.net>

---

 configure.ac                   |   13 +
 src/glx/x11/glxext.c           |   86 ---
 src/mesa/glapi/gl_SPARC_asm.py |  228 +++++--
 src/mesa/glapi/glapi.c         |  131 ++++
 src/mesa/glapi/glapi_getproc.c |   78 +--
 src/mesa/main/context.c        |    3 -
 src/mesa/sparc/glapi_sparc.S   | 1645 +++++++++++++---------------------------
 src/mesa/sparc/sparc.c         |   38 +-
 src/mesa/sparc/sparc.h         |    1 -
 9 files changed, 891 insertions(+), 1332 deletions(-)

Diff:   http://cgit.freedesktop.org/mesa/mesa/diff/?id=857ac1e817808f4b6bf985679162d0e3d709e5b5



More information about the mesa-commit mailing list