3 # $Id: glx86asm.py,v 1.3 2001/03/28 17:22:11 brianp 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_x86.S assembly language file.
31 # glx86asm.py >glapi_x86.S
34 # The gl.spec file from the SI must be in the current directory.
36 # Brian Paul 11 May 2000
44 print '/* DO NOT EDIT - This file generated automatically with glx86asm.py script */'
45 print '#include "assyntax.h"'
46 print '#include "glapioffsets.h"'
48 print '#ifndef __WIN32__'
50 print '#if defined(USE_MGL_NAMESPACE)'
51 print '#define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'
53 print '#define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
56 print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
58 print '#ifdef GNU_ASSEMBLER'
59 print '#define GLOBL_FN(x) GLOBL x ; .type x,@function'
61 print '#define GLOBL_FN(x) GLOBL x'
71 print '#endif /* __WIN32__ */'
75 def GenerateDispatchCode(name
, offset
):
77 print "GLOBL_FN(GL_PREFIX(%s))" % (name
)
78 print "GL_PREFIX(%s):" % (name
)
79 print '\tMOV_L(GLNAME(_glapi_Dispatch), EAX)'
80 print "\tJMP(GL_OFFSET(_gloffset_%s))" % (offset
)
85 def FindAlias(list, funcName
):
86 for i
in range(0, len(list)):
88 if entry
[0] == funcName
:
98 functionPattern
= re
.compile('^[a-zA-Z0-9]+\(')
99 functionNamePattern
= re
.compile('^[a-zA-Z0-9]+')
105 for line
in f
.readlines():
107 m
= functionPattern
.match(line
)
110 n
= functionNamePattern
.findall(line
)
113 m
= string
.split(line
)
119 #print 'WARNING skipping', funcName
122 entry
= [ funcName
, funcName
]
123 functions
.append(entry
)
125 elif m
[0] == 'alias':
126 aliasedName
= FindAlias(functions
, m
[1])
128 entry
= [ funcName
, aliasedName
]
129 functions
.append(entry
)
131 print 'WARNING: alias to unknown function:', aliasedName
137 # Now generate the assembly dispatch code
138 for i
in range(0, len(functions
)):
140 GenerateDispatchCode( entry
[0], entry
[1] )