3 # $Id: glsparcasm.py,v 1.6 2001/11/19 00:40:33 brianp Exp $
5 # Mesa 3-D graphics library
8 # Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
10 # Permission is hereby granted, free of charge, to any person obtaining a
11 # copy of this software and associated documentation files (the "Software"),
12 # to deal in the Software without restriction, including without limitation
13 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 # and/or sell copies of the Software, and to permit persons to whom the
15 # Software is furnished to do so, subject to the following conditions:
17 # The above copyright notice and this permission notice shall be included
18 # in all copies or substantial portions of the Software.
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 # Generate the src/SPARC/glapi_sparc.S file.
31 # gloffsets.py >glapi_sparc.S
34 # The apispec file must be in the current directory.
41 print '/* DO NOT EDIT - This file generated automatically with glsparcasm.py script */'
42 print '#include "glapioffsets.h"'
44 print '#define GL_PREFIX(n) gl##n'
45 print '#define GLOBL_FN(x) .globl x'
47 print '/* The _glapi_Dispatch symbol addresses get relocated into the'
48 print ' * sethi/or instruction sequences below at library init time.'
54 print '.globl __glapi_sparc_icache_flush'
55 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
63 print '.globl _mesa_sparc_glapi_begin'
64 print '.type _mesa_sparc_glapi_begin,#function'
65 print '_mesa_sparc_glapi_begin:'
72 print '.globl _mesa_sparc_glapi_end'
73 print '.type _mesa_sparc_glapi_end,#function'
74 print '_mesa_sparc_glapi_end:'
82 def FindOffset(funcName
):
83 for (name
, alias
, offset
) in records
:
91 def EmitFunction(name
, returnType
, argTypeList
, argNameList
, alias
, offset
):
92 argList
= apiparser
.MakeArgList(argTypeList
, argNameList
)
100 # try to find offset from alias name
101 assert dispatchName
!= ''
102 offset
= FindOffset(dispatchName
)
104 #print 'Cannot dispatch %s' % name
109 # save this info in case we need to look up an alias later
110 records
.append((name
, dispatchName
, offset
))
112 # print the assembly code
114 print "GLOBL_FN(GL_PREFIX(%s))" % (name
)
115 print '.type gl%s,#function' %(name)
116 print "GL_PREFIX(%s):" % (name
)
117 print '#ifdef __sparc_v9__'
118 print '\tsethi\t%hi(0x00000000), %g2'
119 print '\tsethi\t%hi(0x00000000), %g1'
120 print '\tor\t%g2, %lo(0x00000000), %g2'
121 print '\tor\t%g1, %lo(0x00000000), %g1'
122 print '\tsllx\t%g2, 32, %g2'
123 print '\tldx\t[%g1 + %g2], %g1'
124 print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (dispatchName
)
125 print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (dispatchName
)
126 print '\tldx\t[%g1 + %g2], %g3'
128 print '\tsethi\t%hi(0x00000000), %g1'
129 print '\tld\t[%g1 + %lo(0x00000000)], %g1'
130 print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (dispatchName
)
132 print '\tjmpl\t%g3, %g0'
138 apiparser
.ProcessSpecFile("APIspec", EmitFunction
)