3 # Mesa 3-D graphics library
6 # Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
8 # Permission is hereby granted, free of charge, to any person obtaining a
9 # copy of this software and associated documentation files (the "Software"),
10 # to deal in the Software without restriction, including without limitation
11 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 # and/or sell copies of the Software, and to permit persons to whom the
13 # Software is furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 # Generate the src/SPARC/glapi_sparc.S file.
29 # gloffsets.py >glapi_sparc.S
32 # The apispec file must be in the current directory.
39 print '/* DO NOT EDIT - This file generated automatically with glsparcasm.py script */'
40 print '#include "glapioffsets.h"'
42 print '/* The _glapi_Dispatch symbol addresses get relocated into the'
43 print ' * sethi/or instruction sequences below at library init time.'
49 print '.globl __glapi_sparc_icache_flush'
50 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
58 print '.globl _mesa_sparc_glapi_begin'
59 print '.type _mesa_sparc_glapi_begin,#function'
60 print '_mesa_sparc_glapi_begin:'
67 print '.globl _mesa_sparc_glapi_end'
68 print '.type _mesa_sparc_glapi_end,#function'
69 print '_mesa_sparc_glapi_end:'
77 def FindOffset(funcName
):
78 for (name
, alias
, offset
) in records
:
86 def EmitFunction(name
, returnType
, argTypeList
, argNameList
, alias
, offset
):
87 argList
= apiparser
.MakeArgList(argTypeList
, argNameList
)
95 # try to find offset from alias name
96 assert dispatchName
!= ''
97 offset
= FindOffset(dispatchName
)
99 #print 'Cannot dispatch %s' % name
104 # save this info in case we need to look up an alias later
105 records
.append((name
, dispatchName
, offset
))
107 # print the assembly code
109 print '.globl gl%s' % (name
)
110 print '.type gl%s,#function' % (name
)
111 print 'gl%s:' % (name
)
112 print '#if defined(__sparc_v9__) && !defined(__linux__)'
113 print '\tsethi\t%hi(0x00000000), %g2'
114 print '\tsethi\t%hi(0x00000000), %g1'
115 print '\tor\t%g2, %lo(0x00000000), %g2'
116 print '\tor\t%g1, %lo(0x00000000), %g1'
117 print '\tsllx\t%g2, 32, %g2'
118 print '\tldx\t[%g1 + %g2], %g1'
119 print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (dispatchName
)
120 print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (dispatchName
)
121 print '\tldx\t[%g1 + %g2], %g3'
123 print '\tsethi\t%hi(0x00000000), %g1'
124 print '\tld\t[%g1 + %lo(0x00000000)], %g1'
125 print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (dispatchName
)
127 print '\tjmpl\t%g3, %g0'
133 apiparser
.ProcessSpecFile("APIspec", EmitFunction
)