add debugging for compresssed textures
[mesa.git] / src / mesa / glapi / gl_SPARC_asm.py
1 #!/usr/bin/python2
2
3 # (C) Copyright IBM Corporation 2004
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # on the rights to use, copy, modify, merge, publish, distribute, sub
10 # license, and/or sell copies of the Software, and to permit persons to whom
11 # the Software is furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice (including the next
14 # paragraph) shall be included in all copies or substantial portions of the
15 # Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 # IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 # IN THE SOFTWARE.
24 #
25 # Authors:
26 # Ian Romanick <idr@us.ibm.com>
27
28 from xml.sax import saxutils
29 from xml.sax import make_parser
30 from xml.sax.handler import feature_namespaces
31
32 import gl_XML
33 import license
34 import sys, getopt
35
36 class PrintGenericStubs(gl_XML.FilterGLAPISpecBase):
37 name = "gl_SPARC_asm.py (from Mesa)"
38
39 def __init__(self):
40 gl_XML.FilterGLAPISpecBase.__init__(self)
41 self.license = license.bsd_license_template % ( \
42 """Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
43 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
44
45
46 def printRealHeader(self):
47 print '#include "glapioffsets.h"'
48 print ''
49 print '#define GLOBL_FN(x) .globl x ; .type x,#function'
50 print ''
51 print '#if defined(__sparc_v9__) && !defined(__linux__)'
52 print '# define GL_STUB(fn,off)\t\t\t\t\\'
53 print 'GLOBL_FN(fn) ; fn:\t\t\t\t\t\\'
54 print '\tsethi\t%hi(0x00000000), %g4 ;\t\t\t\\'
55 print '\tsethi\t%hi(0x00000000), %g1 ;\t\t\t\\'
56 print '\tor\t%g4, %lo(0x00000000), %g4 ;\t\t\\'
57 print '\tor\t%g1, %lo(0x00000000), %g1 ;\t\t\\'
58 print '\tsllx\t%g4, 32, %g4 ;\t\t\t\t\\'
59 print '\tldx\t[%g1 + %g4], %g1 ;\t\t\t\\'
60 print '\tsethi\t%hi(8 * off), %g4 ;\t\t\t\\'
61 print '\tor\t%g4, %lo(8 * off), %g4 ;\t\t\\'
62 print '\tldx\t[%g1 + %g4], %g5 ;\t\t\t\\'
63 print '\tjmpl\t%g5, %g0 ;\t\t\t\t\\'
64 print '\tnop'
65 print '#else'
66 print '# define GL_STUB(fn,off)\t\t\t\t\\'
67 print 'GLOBL_FN(fn) ; fn:\t\t\t\t\t\\'
68 print '\tsethi\t%hi(0x00000000), %g1 ;\t\t\t\\'
69 print '\tld\t[%g1 + %lo(0x00000000)], %g1 ;\t\t\\'
70 print '\tld\t[%g1 + (4 * off)], %g5 ;\t\t\\'
71 print '\tjmpl\t%g5, %g0 ;\t\t\t\t\\'
72 print '\tnop'
73 print '#endif'
74 print ''
75 print '.text'
76 print '.align 32'
77 print 'GLOBL_FN(__glapi_sparc_icache_flush)'
78 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
79 print '\tflush\t%o0'
80 print '\tretl'
81 print '\tnop'
82 print ''
83 print '.data'
84 print '.align 64'
85 print ''
86 print 'GLOBL_FN(_mesa_sparc_glapi_begin)'
87 print '_mesa_sparc_glapi_begin:'
88 print ''
89 return
90
91 def printRealFooter(self):
92 print ''
93 print 'GLOBL_FN(_mesa_sparc_glapi_end)'
94 print '_mesa_sparc_glapi_end:'
95 return
96
97 def printFunction(self, f):
98 print '\tGL_STUB(gl%s, _gloffset_%s)' % (f.name, f.real_name)
99 return
100
101 def show_usage():
102 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
103 sys.exit(1)
104
105 if __name__ == '__main__':
106 file_name = "gl_API.xml"
107 mode = "generic"
108
109 try:
110 (args, trail) = getopt.getopt(sys.argv[1:], "m:f:")
111 except Exception,e:
112 show_usage()
113
114 for (arg,val) in args:
115 if arg == '-m':
116 mode = val
117 elif arg == "-f":
118 file_name = val
119
120 if mode == "generic":
121 dh = PrintGenericStubs()
122 else:
123 print "ERROR: Invalid mode \"%s\" specified." % mode
124 show_usage()
125
126 parser = make_parser()
127 parser.setFeature(feature_namespaces, 0)
128 parser.setContentHandler(dh)
129
130 f = open(file_name)
131
132 dh.printHeader()
133 parser.parse(f)
134 dh.printFooter()