add debugging for compresssed textures
[mesa.git] / src / mesa / glapi / glsparcasm.py
1 #!/usr/bin/env python
2
3 # Mesa 3-D graphics library
4 # Version: 5.1
5 #
6 # Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 #
8 # Permission is hereby granted, free of charge, to any person obtaining a
9 # copy of this software and associated documentation files (the "Software"),
10 # to deal in the Software without restriction, including without limitation
11 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 # and/or sell copies of the Software, and to permit persons to whom the
13 # Software is furnished to do so, subject to the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
26 # Generate the src/SPARC/glapi_sparc.S file.
27 #
28 # Usage:
29 # gloffsets.py >glapi_sparc.S
30 #
31 # Dependencies:
32 # The apispec file must be in the current directory.
33
34
35 import apiparser;
36
37
38 def PrintHead():
39 print '/* DO NOT EDIT - This file generated automatically with glsparcasm.py script */'
40 print '#include "glapioffsets.h"'
41 print ''
42 print '/* The _glapi_Dispatch symbol addresses get relocated into the'
43 print ' * sethi/or instruction sequences below at library init time.'
44 print ' */'
45 print ''
46 print ''
47 print '.text'
48 print '.align 32'
49 print '.globl __glapi_sparc_icache_flush'
50 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
51 print '\tflush\t%o0'
52 print '\tretl'
53 print '\tnop'
54 print ''
55 print '.data'
56 print '.align 64'
57 print ''
58 print '.globl _mesa_sparc_glapi_begin'
59 print '.type _mesa_sparc_glapi_begin,#function'
60 print '_mesa_sparc_glapi_begin:'
61 return
62 #endif
63
64 def PrintTail():
65 print '\t nop'
66 print ''
67 print '.globl _mesa_sparc_glapi_end'
68 print '.type _mesa_sparc_glapi_end,#function'
69 print '_mesa_sparc_glapi_end:'
70 print ''
71 #endif
72
73
74
75 records = []
76
77 def FindOffset(funcName):
78 for (name, alias, offset) in records:
79 if name == funcName:
80 return offset
81 #endif
82 #endfor
83 return -1
84 #enddef
85
86 def EmitFunction(name, returnType, argTypeList, argNameList, alias, offset):
87 argList = apiparser.MakeArgList(argTypeList, argNameList)
88 if alias != '':
89 dispatchName = alias
90 else:
91 dispatchName = name
92 #endif
93
94 if offset < 0:
95 # try to find offset from alias name
96 assert dispatchName != ''
97 offset = FindOffset(dispatchName)
98 if offset == -1:
99 #print 'Cannot dispatch %s' % name
100 return
101 #endif
102 #endif
103
104 # save this info in case we need to look up an alias later
105 records.append((name, dispatchName, offset))
106
107 # print the assembly code
108 print ''
109 print '.globl gl%s' % (name)
110 print '.type gl%s,#function' % (name)
111 print 'gl%s:' % (name)
112 print '#if defined(__sparc_v9__) && !defined(__linux__)'
113 print '\tsethi\t%hi(0x00000000), %g2'
114 print '\tsethi\t%hi(0x00000000), %g1'
115 print '\tor\t%g2, %lo(0x00000000), %g2'
116 print '\tor\t%g1, %lo(0x00000000), %g1'
117 print '\tsllx\t%g2, 32, %g2'
118 print '\tldx\t[%g1 + %g2], %g1'
119 print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (dispatchName)
120 print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (dispatchName)
121 print '\tldx\t[%g1 + %g2], %g3'
122 print '#else'
123 print '\tsethi\t%hi(0x00000000), %g1'
124 print '\tld\t[%g1 + %lo(0x00000000)], %g1'
125 print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (dispatchName)
126 print '#endif'
127 print '\tjmpl\t%g3, %g0'
128 print '\tnop'
129 #enddef
130
131
132 PrintHead()
133 apiparser.ProcessSpecFile("APIspec", EmitFunction)
134 PrintTail()