Fix SPARC assembly for 64-bit

- The test for whether or not we're building for 64-bit is '#ifdef __arch64__'.
 This appears to be correct on both Linux and Solaris.

- The test for Solaris is now '#if defined(SVR4) || defined(__SVR4) ||
defined(__svr4__)'.  GCC 3.4.0 has all three defined on Solaris 9.

- Enables assembly language clip routines.

- Fixes to make GLSL code build on Solaris.

- Update gl_SPARC_asm.py.
This commit is contained in:
Ian Romanick 2005-07-28 00:11:10 +00:00
parent 3e36986e5a
commit 9f23a3a1bf
12 changed files with 1962 additions and 19329 deletions

View File

@ -7,10 +7,24 @@ CONFIG_NAME = linux-sparc
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM
CXXFLAGS = -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE
WARN_FLAGS = -Wall
OPT_FLAGS = -O2
PIC_FLAGS = -fPIC
DEFINES = -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM
X11_INCLUDES = -I/usr/X11R6/include
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(ASM_FLAGS) -std=c99 -ffast-math
CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
GLUT_CFLAGS = -fexceptions
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
EXTRA_LIB_PATH=-L/usr/X11R6/lib
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11

View File

@ -4,18 +4,32 @@ include $(TOP)/configs/default
CONFIG_NAME = sunos5-gcc
ASM_SOURCES = $(SPARC_SOURCES) $(SPARC_API)
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -O3 -I/usr/openwin/include -fPIC -fomit-frame-pointer -D_REENTRANT -DUSE_XSHM -DUSE_SPARC_ASM
CXXFLAGS = -O3 -I/usr/openwin/include -fPIC -fomit-frame-pointer -D_REENTRANT -DUSE_SPARC_ASM
WARN_FLAGS = -Wall
OPT_FLAGS = -O3 -g -fomit-frame-pointer -pipe
PIC_FLAGS = -fPIC
ARCH_FLAGS ?=
DEFINES = -D_REENTRANT -DUSE_XSHM
ASM_SOURCES = $(SPARC_SOURCES) $(SPARC_API)
ASM_FLAGS = -DUSE_SPARC_ASM
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(ASM_FLAGS) -std=c99 -ffast-math -I/usr/openwin/include
CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
-I/usr/openwin/include
GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm
GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
APP_LIB_DEPS = -L$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
# Library/program dependencies
EXTRA_LIB_PATH=-L/usr/openwin/lib
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXmu -lXi -lm
GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
APP_LIB_DEPS = -L$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm

View File

@ -331,7 +331,16 @@ typedef struct {
} GLXBufferClobberEventSGIX;
#endif
#if defined(__UNIXOS2__) || defined(__SOL64__)
#if defined(__sun__)
#include <inttypes.h>
#if defined(__STDC__)
#if defined(__arch64__)
typedef long int int64_t;
#else
typedef long long int int64_t;
#endif /* __arch64__ */
#endif /* __STDC__ */
#elif defined(__UNIXOS2__) || defined(__SOL64__)
typedef long int int32_t;
typedef long long int int64_t;
#elif defined( __VMS )

View File

@ -40,15 +40,13 @@ class PrintGenericStubs(gl_XML.gl_print_base):
def printRealHeader(self):
print '#include "glapioffsets.h"'
print ''
print '#define GLOBL_FN(x) .globl x ; .type x,#function'
print ''
print '#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))'
print '#ifdef __arch64__'
print '# define GL_STUB(fn,off)\t\t\t\t\\'
print 'GLOBL_FN(fn) ; fn:\t\t\t\t\t\\'
print '\tsethi\t%hi(0x00000000), %g4 ;\t\t\t\\'
print '\tsethi\t%hi(0x00000000), %g1 ;\t\t\t\\'
print '\tor\t%g4, %lo(0x00000000), %g4 ;\t\t\\'
print '\tor\t%g1, %lo(0x00000000), %g1 ;\t\t\\'
print 'fn:\t\t\t\t\t\\'
print '\tsethi\t%hi(0xDEADBEEF), %g4 ;\t\t\t\\'
print '\tsethi\t%hi(0xDEADBEEF), %g1 ;\t\t\t\\'
print '\tor\t%g4, %lo(0xDEADBEEF), %g4 ;\t\t\\'
print '\tor\t%g1, %lo(0xDEADBEEF), %g1 ;\t\t\\'
print '\tsllx\t%g4, 32, %g4 ;\t\t\t\t\\'
print '\tldx\t[%g1 + %g4], %g1 ;\t\t\t\\'
print '\tsethi\t%hi(8 * off), %g4 ;\t\t\t\\'
@ -58,19 +56,19 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tnop'
print '#else'
print '# define GL_STUB(fn,off)\t\t\t\t\\'
print 'GLOBL_FN(fn) ; fn:\t\t\t\t\t\\'
print '\tsethi\t%hi(0x00000000), %g1 ;\t\t\t\\'
print '\tld\t[%g1 + %lo(0x00000000)], %g1 ;\t\t\\'
print 'fn:\t\t\t\t\t\\'
print '\tsethi\t%hi(0xDEADBEEF), %g1 ;\t\t\t\\'
print '\tld\t[%g1 + %lo(0xDEADBEEF)], %g1 ;\t\t\\'
print '\tld\t[%g1 + (4 * off)], %g5 ;\t\t\\'
print '\tjmpl\t%g5, %g0 ;\t\t\t\t\\'
print '\tnop'
print '#endif'
print ''
print '#define GL_STUB_ALIAS(fn,alias) GLOBL_FN(fn) ; fn = alias'
print '#define GL_STUB_ALIAS(fn,alias) fn = alias'
print ''
print '.text'
print '.align 32'
print 'GLOBL_FN(__glapi_sparc_icache_flush)'
print '\t\t.globl __glapi_sparc_icache_flush ; .type __glapi_sparc_icache_flush,#function'
print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
print '\tflush\t%o0'
print '\tretl'
@ -83,7 +81,10 @@ class PrintGenericStubs(gl_XML.gl_print_base):
def printBody(self, api):
print 'GLOBL_FN(_mesa_sparc_glapi_begin)'
for f in api.functionIterateByOffset():
print '\t\t.globl gl%s ; .type gl%s,#function' % (f.name, f.name)
print '\t\t.globl _mesa_sparc_glapi_begin ; .type _mesa_sparc_glapi_begin,#function'
print '_mesa_sparc_glapi_begin:'
print ''
@ -91,7 +92,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tGL_STUB(gl%s, _gloffset_%s)' % (f.name, f.name)
print ''
print 'GLOBL_FN(_mesa_sparc_glapi_end)'
print '\t\t.globl _mesa_sparc_glapi_end ; .type _mesa_sparc_glapi_end,#function'
print '_mesa_sparc_glapi_end:'
print ''
@ -99,7 +100,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
for f in api.functionIterateByOffset():
for n in f.entry_points:
if n != f.name:
print '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name)
print '\t.globl gl%s ; .type gl%s,#function ; gl%s = gl%s' % (n, n, n, f.name)
return

View File

@ -711,7 +711,7 @@ generate_entrypoint(GLuint functionOffset)
return (_glapi_proc) code;
#elif defined(USE_SPARC_ASM)
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
static const unsigned int insn_template[] = {
0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */
0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
@ -739,7 +739,7 @@ generate_entrypoint(GLuint functionOffset)
if (code) {
memcpy(code, insn_template, sizeof(insn_template));
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
code[0] |= (glapi_addr >> (32 + 10));
code[1] |= ((glapi_addr & 0xffffffff) >> 10);
__glapi_sparc_icache_flush(&code[0]);
@ -791,17 +791,17 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
/* XXX this hasn't been tested! */
unsigned int *code = (unsigned int *) entrypoint;
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
code[6] = 0x05000000; /* sethi %hi(8 * glapioffset), %g2 */
code[7] = 0x8410a000; /* or %g2, %lo(8 * glapioffset), %g2 */
code[6] |= ((offset * 8) >> 10);
code[7] |= ((offset * 8) & ((1 << 10) - 1));
__glapi_sparc_icache_flush(&code[6]);
#else /* __sparc_v9__ && !linux */
#else /* __arch64__ */
code[2] = 0xc6006000; /* ld [%g1 + %lo(4*glapioffset)], %g3 */
code[2] |= (offset * 4);
__glapi_sparc_icache_flush(&code[2]);
#endif /* __sparc_v9__ && !linux */
#endif /* __arch64__ */
#else

View File

@ -565,24 +565,24 @@ static void emit_destroy (emit **em)
static unsigned int emit_size (emit *_E)
{
unsigned int _N = 0;
unsigned int n = 0;
while (_E != NULL)
{
if (_E->m_emit_dest == ed_output)
{
if (_E->m_emit_type == et_position)
_N += 4; /* position is a 32-bit unsigned integer */
n += 4; /* position is a 32-bit unsigned integer */
else
_N++;
n++;
}
_E = _E->m_next;
}
return _N;
return n;
}
static int emit_push (emit *_E, byte *_P, byte _C, unsigned int _Pos, regbyte_ctx **_Ctx)
static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx **_Ctx)
{
while (_E != NULL)
{
@ -591,7 +591,7 @@ static int emit_push (emit *_E, byte *_P, byte _C, unsigned int _Pos, regbyte_ct
if (_E->m_emit_type == et_byte)
*_P++ = _E->m_byte;
else if (_E->m_emit_type == et_stream)
*_P++ = _C;
*_P++ = c;
else /* _Em->type == et_position */
{
*_P++ = (byte) (_Pos);
@ -614,7 +614,7 @@ static int emit_push (emit *_E, byte *_P, byte _C, unsigned int _Pos, regbyte_ct
if (_E->m_emit_type == et_byte)
new_rbc->m_current_value = _E->m_byte;
else if (_E->m_emit_type == et_stream)
new_rbc->m_current_value = _C;
new_rbc->m_current_value = c;
}
_E = _E->m_next;
@ -1013,22 +1013,22 @@ static void bytepool_create (bytepool **by, int len)
}
}
static int bytepool_reserve (bytepool *by, unsigned int _N)
static int bytepool_reserve (bytepool *by, unsigned int n)
{
byte *_P;
if (_N <= by->_Siz)
if (n <= by->_Siz)
return 0;
/* byte pool can only grow and at least by doubling its size */
_N = _N >= by->_Siz * 2 ? _N : by->_Siz * 2;
n = n >= by->_Siz * 2 ? n : by->_Siz * 2;
/* reallocate the memory and adjust pointers to the new memory location */
_P = (byte *) (mem_realloc (by->_F, sizeof (byte) * by->_Siz, sizeof (byte) * _N));
_P = (byte *) (mem_realloc (by->_F, sizeof (byte) * by->_Siz, sizeof (byte) * n));
if (_P != NULL)
{
by->_F = _P;
by->_Siz = _N;
by->_Siz = n;
return 0;
}

View File

@ -2,7 +2,7 @@
* Clip testing in SPARC assembly
*/
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#if __arch64__
#define LDPTR ldx
#define V4F_DATA 0x00
#define V4F_START 0x08
@ -25,7 +25,7 @@
#define VEC_SIZE_3 7
#define VEC_SIZE_4 15
#ifdef SVR4
#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
/* Solaris requires this for 64-bit. */
.register %g2, #scratch
.register %g3, #scratch

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* $Id: norm.S,v 1.4 2004/11/22 19:27:40 brianp Exp $ */
/* $Id: norm.S,v 1.5 2005/07/28 00:11:11 idr Exp $ */
#include "sparc_matrix.h"
#ifdef SVR4
#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
/* Solaris requires this for 64-bit. */
.register %g2, #scratch
.register %g3, #scratch
@ -10,7 +10,7 @@
.text
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
#define STACK_VAR_OFF (2047 + (8 * 16))
#else
#define STACK_VAR_OFF (4 * 16)

View File

@ -110,13 +110,9 @@ void _mesa_init_all_sparc_transform_asm(void)
ASSIGN_XFORM_GROUP(sparc, 3)
ASSIGN_XFORM_GROUP(sparc, 4)
#if 0
/* Disabled for now. See Mesa bug report # 544665. Evidently these
* functions are using SPARC registers that shouldn't be touched.
*/
_mesa_clip_tab[4] = _mesa_sparc_cliptest_points4;
_mesa_clip_np_tab[4] = _mesa_sparc_cliptest_points4_np;
#endif
#if 0
/* disable these too. See bug 673938 */
_mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] =
@ -162,7 +158,7 @@ void _mesa_init_sparc_glapi_relocs(void)
disp_addr = (unsigned long) &_glapi_Dispatch;
while (insn_ptr < end_ptr) {
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
insn_ptr[0] |= (disp_addr >> (32 + 10));
insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
__glapi_sparc_icache_flush(&insn_ptr[0]);

View File

@ -5,7 +5,7 @@
#ifndef _SPARC_MATRIX_H
#define _SPARC_MATRIX_H
#if (defined(__sparc_v9__) && (!defined(__linux__) || defined(__linux_sparc_64__)))
#ifdef __arch64__
#define LDPTR ldx
#define MAT_M 0x00
#define MAT_INV 0x08

View File

@ -1,4 +1,4 @@
/* $Id: xform.S,v 1.3 2004/04/26 10:10:25 alanh Exp $ */
/* $Id: xform.S,v 1.4 2005/07/28 00:11:11 idr Exp $ */
/* TODO
*
@ -18,7 +18,7 @@
#include "sparc_matrix.h"
#ifdef SVR4
#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
/* Solaris requires this for 64-bit. */
.register %g2, #scratch
.register %g3, #scratch