3 # $Id: glsparcasm.py,v 1.2 2001/06/05 23:54:00 davem69 Exp $
5 # Mesa 3-D graphics library
8 # Copyright (C) 1999-2000 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 glapi_sparc.S assembly language file.
31 # glsparcasm.py >glapi_sparc.S
34 # The gl.spec file from the SI must be in the current directory.
36 # Brian Paul 11 May 2000
37 # David S. Miller 4 Jun 2001
44 print '/* DO NOT EDIT - This file generated automatically with glsparcasm.py script */'
45 print '#include "glapioffsets.h"'
47 print '#define GL_PREFIX(n) gl##n'
48 print '#define GLOBL_FN(x) .globl x ; .type x,@function'
50 print '/* The _glapi_Dispatch symbol addresses get relocated into the'
51 print ' * sethi/or instruction sequences below at library init time.'
57 print '.globl _mesa_sparc_glapi_begin'
58 print '_mesa_sparc_glapi_begin:'
66 print '.globl _mesa_sparc_glapi_end'
67 print '_mesa_sparc_glapi_end:'
72 def GenerateDispatchCode(name
, offset
):
74 print "GLOBL_FN(GL_PREFIX(%s))" % (name
)
75 print "GL_PREFIX(%s):" % (name
)
76 print '#ifdef __sparc_v9__'
77 print '\tsethi\t%hi(0x00000000), %g2'
78 print '\tsethi\t%hi(0x00000000), %g1'
79 print '\tor\t%g2, %lo(0x00000000), %g2'
80 print '\tor\t%g1, %lo(0x00000000), %g1'
81 print '\tsllx\t%g2, 32, %g2'
82 print '\tldx\t[%g1 + %g2], %g1'
83 print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (offset
)
84 print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (offset
)
85 print '\tldx\t[%g1 + %g2], %g3'
87 print '\tsethi\t%hi(0x00000000), %g1'
88 print '\tld\t[%g1 + %lo(0x00000000)], %g1'
89 print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (offset
)
91 print '\tjmpl\t%g3, %g0'
95 def FindAlias(list, funcName
):
96 for i
in range(0, len(list)):
98 if entry
[0] == funcName
:
108 functionPattern
= re
.compile('^[a-zA-Z0-9]+\(')
109 functionNamePattern
= re
.compile('^[a-zA-Z0-9]+')
115 for line
in f
.readlines():
117 m
= functionPattern
.match(line
)
120 n
= functionNamePattern
.findall(line
)
123 m
= string
.split(line
)
129 #print 'WARNING skipping', funcName
132 entry
= [ funcName
, funcName
]
133 functions
.append(entry
)
135 elif m
[0] == 'alias':
136 aliasedName
= FindAlias(functions
, m
[1])
138 entry
= [ funcName
, aliasedName
]
139 functions
.append(entry
)
141 print 'WARNING: alias to unknown function:', aliasedName
147 # Now generate the assembly dispatch code
148 for i
in range(0, len(functions
)):
150 GenerateDispatchCode( entry
[0], entry
[1] )