3 # $Id: glx86asm.py,v 1.6 2002/06/11 01:26:58 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/X86/glapi_x86.S file.
31 # gloffsets.py >glapi_x86.S
34 # The apispec file must be in the current directory.
41 print '/* DO NOT EDIT - This file generated automatically with glx86asm.py script */'
42 print '#include "assyntax.h"'
43 print '#include "glapioffsets.h"'
45 print '#ifndef __WIN32__'
47 print '#if defined(USE_MGL_NAMESPACE)'
48 print '#define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'
50 print '#define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
53 print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
55 print '#if defined(GNU_ASSEMBLER) && !defined(DJGPP)'
56 print '#define GLOBL_FN(x) GLOBL x ; .type x,@function'
58 print '#define GLOBL_FN(x) GLOBL x'
62 print 'EXTERN GLNAME(_glapi_Dispatch)'
70 print '#endif /* __WIN32__ */'
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_FN(GL_PREFIX(%s))" % (name
)
110 print "GL_PREFIX(%s):" % (name
)
111 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX)'
112 print "\tJMP(GL_OFFSET(_gloffset_%s))" % (dispatchName
)
120 apiparser
.ProcessSpecFile("APIspec", EmitFunction
)