3 # $Id: glsparcasm.py,v 1.1 2001/06/05 04:30:03 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.'
66 def GenerateDispatchCode(name
, offset
):
68 print "GLOBL_FN(GL_PREFIX(%s))" % (name
)
69 print "GL_PREFIX(%s):" % (name
)
70 print '#ifdef __sparc_v9__'
71 print '\tsethi\t%hi(0x00000000), %g2'
72 print '\tsethi\t%hi(0x00000000), %g1'
73 print '\tor\t%g2, %lo(0x00000000), %g2'
74 print '\tor\t%g1, %lo(0x00000000), %g1'
75 print '\tsllx\t%g2, 32, %g2'
76 print '\tor\t%g1, %g2, %g1'
77 print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (offset
)
78 print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (offset
)
79 print '\tldx\t[%g1 + %g2], %g3'
81 print '\tsethi\t%hi(0x00000000), %g1'
82 print '\tor\t%g1, %lo(0x00000000), %g1'
83 print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (offset
)
85 print '\tjmpl\t%g3, %g0'
89 def FindAlias(list, funcName
):
90 for i
in range(0, len(list)):
92 if entry
[0] == funcName
:
102 functionPattern
= re
.compile('^[a-zA-Z0-9]+\(')
103 functionNamePattern
= re
.compile('^[a-zA-Z0-9]+')
109 for line
in f
.readlines():
111 m
= functionPattern
.match(line
)
114 n
= functionNamePattern
.findall(line
)
117 m
= string
.split(line
)
123 #print 'WARNING skipping', funcName
126 entry
= [ funcName
, funcName
]
127 functions
.append(entry
)
129 elif m
[0] == 'alias':
130 aliasedName
= FindAlias(functions
, m
[1])
132 entry
= [ funcName
, aliasedName
]
133 functions
.append(entry
)
135 print 'WARNING: alias to unknown function:', aliasedName
141 # Now generate the assembly dispatch code
142 for i
in range(0, len(functions
)):
144 GenerateDispatchCode( entry
[0], entry
[1] )