replaced components with internalFormat
[mesa.git] / src / mesa / glapi / glx86asm.py
1 #!/usr/bin/env python
2
3 # $Id: glx86asm.py,v 1.1 2000/05/11 23:14:57 brianp Exp $
4
5 # Mesa 3-D graphics library
6 # Version: 3.3
7 #
8 # Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 #
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:
16 #
17 # The above copyright notice and this permission notice shall be included
18 # in all copies or substantial portions of the Software.
19 #
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.
26
27
28 # Generate the glapi_x86.S assembly language file.
29 #
30 # Usage:
31 # glx86asm.py >glapi_x86.S
32 #
33 # Dependencies:
34 # The gl.spec file from the SI must be in the current directory.
35 #
36 # Brian Paul 11 May 2000
37
38
39 import string
40 import re
41
42
43 def PrintHead():
44 print '/* DO NOT EDIT - This file generated automatically with glx86asm.py script */'
45 print '#include "assyntax.h"'
46 print '#include "glapioffsets.h"'
47 print ''
48 print '#ifndef __WIN32__'
49 print ''
50 print '#if defined(USE_MGL_NAMESPACE)'
51 print '#define GL_PREFIX(n) GLNAME(mgl ## n)'
52 print '#else'
53 print '#define GL_PREFIX(n) GLNAME(gl ## n)'
54 print '#endif'
55 print ''
56 print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
57 print ''
58 print '#ifdef GNU_ASSEMBLER'
59 print '#define GLOBL_FN(x) GLOBL x ; .type x,@function'
60 print '#else'
61 print '#define GLOBL_FN(x) GLOBL x'
62 print '#endif'
63 print ''
64 print ''
65 return
66 #endif
67
68
69 def PrintTail():
70 print ''
71 print '#endif /* __WIN32__ */'
72 #endif
73
74
75 def GenerateDispatchCode(name, offset):
76 print 'ALIGNTEXT16'
77 print "GLOBL_FN(GL_PREFIX(%s))" % (name)
78 print "GL_PREFIX(%s):" % (name)
79 print '\tMOV_L(GLNAME(_glapi_Dispatch), EAX)'
80 print '\tTEST_L(EAX, EAX)'
81 print "\tJZ(GLNAME(_glapi_fallback_%s))" % (name)
82 print "\tJMP(GL_OFFSET(_gloffset_%s))" % (offset)
83 print ''
84 #enddef
85
86
87 def FindAlias(list, funcName):
88 for i in range(0, len(list)):
89 entry = list[i]
90 if entry[0] == funcName:
91 return entry[1]
92 #endif
93 #endfor
94 return ''
95 #enddef
96
97
98
99 def PrintDefines():
100 functionPattern = re.compile('^[a-zA-Z0-9]+\(')
101 functionNamePattern = re.compile('^[a-zA-Z0-9]+')
102
103 funcName = ''
104 functions = [ ]
105
106 f = open('gl.spec')
107 for line in f.readlines():
108
109 m = functionPattern.match(line)
110 if m:
111 # extract funcName
112 n = functionNamePattern.findall(line)
113 funcName = n[0]
114
115 m = string.split(line)
116 if len(m) > 1:
117 if m[0] == 'param':
118 paramName = m[1]
119 if m[0] == 'offset':
120 if m[1] == '?':
121 #print 'WARNING skipping', funcName
122 noop = 0
123 else:
124 entry = [ funcName, funcName ]
125 functions.append(entry)
126 #endif
127 elif m[0] == 'alias':
128 aliasedName = FindAlias(functions, m[1])
129 if aliasedName:
130 entry = [ funcName, aliasedName ]
131 functions.append(entry)
132 else:
133 print 'WARNING: alias to unknown function:', aliasedName
134 #endif
135 #endif
136 #endif
137 #endfor
138
139 # Now generate the assembly dispatch code
140 for i in range(0, len(functions)):
141 entry = functions[i]
142 GenerateDispatchCode( entry[0], entry[1] )
143
144 #enddef
145
146
147
148 PrintHead()
149 PrintDefines()
150 PrintTail()