gallium/indices: implement prim-restart for line-loops
[mesa.git] / src / gallium / auxiliary / indices / u_indices_gen.py
index 397eea306b21c2abeb9246f3e3b52c916af995b6..ea53502f7024c056b0cf613ef353b80bad86ac95 100644 (file)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+from __future__ import print_function
+
 copyright = '''
 /*
  * Copyright 2009 VMware, Inc.
@@ -27,10 +28,12 @@ copyright = '''
 
 GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint'
 FIRST, LAST = 'first', 'last'
+PRDISABLE, PRENABLE = 'prdisable', 'prenable'
 
 INTYPES = (GENERATE, UBYTE, USHORT, UINT)
 OUTTYPES = (USHORT, UINT)
 PVS=(FIRST, LAST)
+PRS=(PRDISABLE, PRENABLE)
 PRIMS=('points', 
        'lines', 
        'linestrip', 
@@ -40,7 +43,11 @@ PRIMS=('points',
        'tristrip', 
        'quads', 
        'quadstrip', 
-       'polygon')
+       'polygon',
+       'linesadj',
+       'linestripadj',
+       'trisadj',
+       'tristripadj')
 
 LONGPRIMS=('PIPE_PRIM_POINTS', 
            'PIPE_PRIM_LINES', 
@@ -51,29 +58,30 @@ LONGPRIMS=('PIPE_PRIM_POINTS',
            'PIPE_PRIM_TRIANGLE_STRIP', 
            'PIPE_PRIM_QUADS', 
            'PIPE_PRIM_QUAD_STRIP', 
-           'PIPE_PRIM_POLYGON')
+           'PIPE_PRIM_POLYGON',
+           'PIPE_PRIM_LINES_ADJACENCY',
+           'PIPE_PRIM_LINE_STRIP_ADJACENCY',
+           'PIPE_PRIM_TRIANGLES_ADJACENCY',
+           'PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY')
 
 longprim = dict(zip(PRIMS, LONGPRIMS))
 intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
 outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT')
 pv_idx = dict(first='PV_FIRST', last='PV_LAST')
-
+pr_idx = dict(prdisable='PR_DISABLE', prenable='PR_ENABLE')
 
 def prolog():
-    print '''/* File automatically generated by indices.py */'''
-    print copyright
-    print r'''
+    print('''/* File automatically generated by u_indices_gen.py */''')
+    print(copyright)
+    print(r'''
 
 /**
  * @file
  * Functions to translate and generate index lists
  */
 
-#include "indices/u_indices.h"
 #include "indices/u_indices_priv.h"
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "pipe/p_defines.h"
+#include "util/u_debug.h"
 #include "util/u_memory.h"
 
 
@@ -97,11 +105,11 @@ static unsigned in_size_idx( unsigned index_size )
 }
 
 
-static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
+static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PR_COUNT][PRIM_COUNT];
 static u_generate_func  generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
 
 
-'''
+''')
 
 def vert( intype, outtype, v0 ):
     if intype == GENERATE:
@@ -110,16 +118,30 @@ def vert( intype, outtype, v0 ):
         return '(' + outtype + ')in[' + v0 + ']'
 
 def point( intype, outtype, ptr, v0 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+    print('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
 
 def line( intype, outtype, ptr, v0, v1 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
-    print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+    print('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
 
 def tri( intype, outtype, ptr, v0, v1, v2 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
-    print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
-    print '      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+    print('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+    print('      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
+
+def lineadj( intype, outtype, ptr, v0, v1, v2, v3 ):
+    print('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+    print('      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
+    print('      (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';')
+
+def triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 ):
+    print('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+    print('      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
+    print('      (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';')
+    print('      (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';')
+    print('      (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';')
 
 def do_point( intype, outtype, ptr, v0 ):
     point( intype, outtype, ptr, v0 )
@@ -139,113 +161,237 @@ def do_tri( intype, outtype, ptr, v0, v1, v2, inpv, outpv ):
         else:
             tri( intype, outtype, ptr, v2, v0, v1 )
 
+def do_quad( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
+    if inpv == LAST:
+        do_tri( intype, outtype, ptr+'+0',  v0, v1, v3, inpv, outpv );
+        do_tri( intype, outtype, ptr+'+3',  v1, v2, v3, inpv, outpv );
+    else:
+        do_tri( intype, outtype, ptr+'+0',  v0, v1, v2, inpv, outpv );
+        do_tri( intype, outtype, ptr+'+3',  v0, v2, v3, inpv, outpv );
 
-def name(intype, outtype, inpv, outpv, prim):
+def do_lineadj( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
+    if inpv == outpv:
+        lineadj( intype, outtype, ptr, v0, v1, v2, v3 )
+    else:
+        lineadj( intype, outtype, ptr, v3, v2, v1, v0 )
+
+def do_triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5, inpv, outpv ):
+    if inpv == outpv:
+        triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 )
+    else:
+        triadj( intype, outtype, ptr, v4, v5, v0, v1, v2, v3 )
+
+def name(intype, outtype, inpv, outpv, pr, prim):
     if intype == GENERATE:
         return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv
     else:
-        return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv
+        return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + '_' + pr
 
-def preamble(intype, outtype, inpv, outpv, prim):
-    print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
+def preamble(intype, outtype, inpv, outpv, pr, prim):
+    print('static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '(')
+    if intype != GENERATE:
+        print('    const void * _in,')
+    print('    unsigned start,')
     if intype != GENERATE:
-        print '    const void * _in,'
-    print '    unsigned nr,'
-    print '    void *_out )'
-    print '{'
+        print('    unsigned in_nr,')
+    print('    unsigned out_nr,')
     if intype != GENERATE:
-        print '  const ' + intype + '*in = (const ' + intype + '*)in;'
-    print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
-    print '  unsigned i, j;'
-    print '  (void)j;'
+        print('    unsigned restart_index,')
+    print('    void *_out )')
+    print('{')
+    if intype != GENERATE:
+        print('  const ' + intype + '*in = (const ' + intype + '*)_in;')
+    print('  ' + outtype + ' *out = (' + outtype + '*)_out;')
+    print('  unsigned i, j;')
+    print('  (void)j;')
 
 def postamble():
-    print '}'
-
-
-def points(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='points')
-    print '  for (i = 0; i < nr; i++) { '
-    do_point( intype, outtype, 'out+i',  'i' );
-    print '   }'
+    print('}')
+
+def prim_restart(in_verts, out_verts, out_prims, close_func = None):
+    print('restart:')
+    print('      if (i + ' + str(in_verts) + ' > in_nr) {')
+    for i in range(out_prims):
+        for j in range(out_verts):
+            print('         (out+j+' + str(out_verts * i) + ')[' + str(j) + '] = restart_index;')
+    print('         continue;')
+    print('      }')
+    for i in range(in_verts):
+        print('      if (in[i + ' + str(i) + '] == restart_index) {')
+        print('         i += ' + str(i + 1) + ';')
+
+        if close_func is not None:
+            close_func(i)
+
+        print('         goto restart;')
+        print('      }')
+
+def points(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='points')
+    print('  for (i = start, j = 0; j < out_nr; j++, i++) { ')
+    do_point( intype, outtype, 'out+j',  'i' );
+    print('   }')
     postamble()
 
-def lines(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='lines')
-    print '  for (i = 0; i < nr; i+=2) { '
-    do_line( intype, outtype, 'out+i',  'i', 'i+1', inpv, outpv );
-    print '   }'
+def lines(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='lines')
+    print('  for (i = start, j = 0; j < out_nr; j+=2, i+=2) { ')
+    do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
+    print('   }')
     postamble()
 
-def linestrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='linestrip')
-    print '  for (j = i = 0; j < nr; j+=2, i++) { '
+def linestrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='linestrip')
+    print('  for (i = start, j = 0; j < out_nr; j+=2, i++) { ')
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
-    print '   }'
+    print('   }')
     postamble()
 
-def lineloop(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='lineloop')
-    print '  for (j = i = 0; j < nr - 2; j+=2, i++) { '
+def lineloop(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='lineloop')
+    print('  unsigned end = start;')
+    print('  for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { ')
+    if pr == PRENABLE:
+        def close_func(index):
+            do_line( intype, outtype, 'out+j',  'end', 'start', inpv, outpv )
+            print('         start = i;')
+            print('         end = start;')
+            print('         j += 2;')
+
+        prim_restart(2, 2, 1, close_func)
+
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
-    print '   }'
-    do_line( intype, outtype, 'out+j',  'i', '0', inpv, outpv );
+    print('      end = i+1;')
+    print('   }')
+    do_line( intype, outtype, 'out+j',  'end', 'start', inpv, outpv );
     postamble()
 
-def tris(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='tris')
-    print '  for (i = 0; i < nr; i+=3) { '
-    do_tri( intype, outtype, 'out+i',  'i', 'i+1', 'i+2', inpv, outpv );
-    print '   }'
+def tris(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='tris')
+    print('  for (i = start, j = 0; j < out_nr; j+=3, i+=3) { ')
+    do_tri( intype, outtype, 'out+j',  'i', 'i+1', 'i+2', inpv, outpv );
+    print('   }')
     postamble()
 
 
-def tristrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='tristrip')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
+def tristrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='tristrip')
+    print('  for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
     if inpv == FIRST:
         do_tri( intype, outtype, 'out+j',  'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
     else:
         do_tri( intype, outtype, 'out+j',  'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
-    print '   }'
+    print('   }')
     postamble()
 
 
-def trifan(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='trifan')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
-    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
-    print '   }'
+def trifan(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='trifan')
+    print('  for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
+    do_tri( intype, outtype, 'out+j',  'start', 'i+1', 'i+2', inpv, outpv );
+    print('   }')
     postamble()
 
 
 
-def polygon(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='polygon')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
+def polygon(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='polygon')
+    print('  for (i = start, j = 0; j < out_nr; j+=3, i++) { ')
+    if pr == PRENABLE:
+        print('restart:')
+        print('      if (i + 3 > in_nr) {')
+        print('         (out+j+0)[0] = restart_index;')
+        print('         (out+j+0)[1] = restart_index;')
+        print('         (out+j+0)[2] = restart_index;')
+        print('         continue;')
+        print('      }')
+        print('      if (in[i + 0] == restart_index) {')
+        print('         i += 1;')
+        print('         start = i;')
+        print('         goto restart;')
+        print('      }')
+        print('      if (in[i + 1] == restart_index) {')
+        print('         i += 2;')
+        print('         start = i;')
+        print('         goto restart;')
+        print('      }')
+        print('      if (in[i + 2] == restart_index) {')
+        print('         i += 3;')
+        print('         start = i;')
+        print('         goto restart;')
+        print('      }')
+
     if inpv == FIRST:
-        do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
+        do_tri( intype, outtype, 'out+j',  'start', 'i+1', 'i+2', inpv, outpv );
     else:
-        do_tri( intype, outtype, 'out+j',  'i+1', 'i+2', '0', inpv, outpv );
-    print '   }'
+        do_tri( intype, outtype, 'out+j',  'i+1', 'i+2', 'start', inpv, outpv );
+    print('   }')
     postamble()
 
 
-def quads(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='quads')
-    print '  for (j = i = 0; j < nr; j+=6, i+=4) { '
-    do_tri( intype, outtype, 'out+j+0',  'i+0', 'i+1', 'i+3', inpv, outpv );
-    do_tri( intype, outtype, 'out+j+3',  'i+1', 'i+2', 'i+3', inpv, outpv );
-    print '   }'
+def quads(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='quads')
+    print('  for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ')
+    if pr == PRENABLE:
+        prim_restart(4, 3, 2)
+
+    do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
+    print('   }')
     postamble()
 
 
-def quadstrip(intype, outtype, inpv, outpv):
-    preamble(intype, outtype, inpv, outpv, prim='quadstrip')
-    print '  for (j = i = 0; j < nr; j+=6, i+=2) { '
-    do_tri( intype, outtype, 'out+j+0',  'i+0', 'i+1', 'i+3', inpv, outpv );
-    do_tri( intype, outtype, 'out+j+3',  'i+1', 'i+2', 'i+3', inpv, outpv );
-    print '   }'
+def quadstrip(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip')
+    print('  for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ')
+    if pr == PRENABLE:
+        prim_restart(4, 3, 2)
+
+    if inpv == LAST:
+        do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
+    else:
+        do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+3', 'i+2', inpv, outpv );
+    print('   }')
+    postamble()
+
+
+def linesadj(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='linesadj')
+    print('  for (i = start, j = 0; j < out_nr; j+=4, i+=4) { ')
+    do_lineadj( intype, outtype, 'out+j',  'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
+    print('  }')
+    postamble()
+
+
+def linestripadj(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='linestripadj')
+    print('  for (i = start, j = 0; j < out_nr; j+=4, i++) {')
+    do_lineadj( intype, outtype, 'out+j',  'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv )
+    print('  }')
+    postamble()
+
+
+def trisadj(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='trisadj')
+    print('  for (i = start, j = 0; j < out_nr; j+=6, i+=6) { ')
+    do_triadj( intype, outtype, 'out+j',  'i+0', 'i+1', 'i+2', 'i+3',
+               'i+4', 'i+5', inpv, outpv )
+    print('  }')
+    postamble()
+
+
+def tristripadj(intype, outtype, inpv, outpv, pr):
+    preamble(intype, outtype, inpv, outpv, pr, prim='tristripadj')
+    print('  for (i = start, j = 0; j < out_nr; i+=2, j+=6) { ')
+    print('    if (i % 4 == 0) {')
+    print('      /* even triangle */')
+    do_triadj( intype, outtype, 'out+j',
+               'i+0', 'i+1', 'i+2', 'i+3', 'i+4', 'i+5', inpv, outpv )
+    print('    } else {')
+    print('      /* odd triangle */')
+    do_triadj( intype, outtype, 'out+j',
+               'i+2', 'i-2', 'i+0', 'i+3', 'i+4', 'i+6', inpv, outpv )
+    print('    }')
+    print('  }')
     postamble()
 
 
@@ -254,33 +400,41 @@ def emit_funcs():
         for outtype in OUTTYPES:
             for inpv in (FIRST, LAST):
                 for outpv in (FIRST, LAST):
-                    points(intype, outtype, inpv, outpv)
-                    lines(intype, outtype, inpv, outpv)
-                    linestrip(intype, outtype, inpv, outpv)
-                    lineloop(intype, outtype, inpv, outpv)
-                    tris(intype, outtype, inpv, outpv)
-                    tristrip(intype, outtype, inpv, outpv)
-                    trifan(intype, outtype, inpv, outpv)
-                    quads(intype, outtype, inpv, outpv)
-                    quadstrip(intype, outtype, inpv, outpv)
-                    polygon(intype, outtype, inpv, outpv)
-
-def init(intype, outtype, inpv, outpv, prim):
+                    for pr in (PRDISABLE, PRENABLE):
+                        if pr == PRENABLE and intype == GENERATE:
+                            continue
+                        points(intype, outtype, inpv, outpv, pr)
+                        lines(intype, outtype, inpv, outpv, pr)
+                        linestrip(intype, outtype, inpv, outpv, pr)
+                        lineloop(intype, outtype, inpv, outpv, pr)
+                        tris(intype, outtype, inpv, outpv, pr)
+                        tristrip(intype, outtype, inpv, outpv, pr)
+                        trifan(intype, outtype, inpv, outpv, pr)
+                        quads(intype, outtype, inpv, outpv, pr)
+                        quadstrip(intype, outtype, inpv, outpv, pr)
+                        polygon(intype, outtype, inpv, outpv, pr)
+                        linesadj(intype, outtype, inpv, outpv, pr)
+                        linestripadj(intype, outtype, inpv, outpv, pr)
+                        trisadj(intype, outtype, inpv, outpv, pr)
+                        tristripadj(intype, outtype, inpv, outpv, pr)
+
+def init(intype, outtype, inpv, outpv, pr, prim):
     if intype == GENERATE:
         print ('generate[' + 
                outtype_idx[outtype] + 
                '][' + pv_idx[inpv] + 
                '][' + pv_idx[outpv] + 
                '][' + longprim[prim] + 
-               '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
+               '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';')
     else:
         print ('translate[' + 
                intype_idx[intype] + 
                '][' + outtype_idx[outtype] + 
                '][' + pv_idx[inpv] + 
-               '][' + pv_idx[outpv] + 
+               '][' + pv_idx[outpv] +
+               '][' + pr_idx[pr] + 
                '][' + longprim[prim] + 
-               '] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
+               '] = ' + name( intype, outtype, inpv, outpv, pr, prim ) + ';')
 
 
 def emit_all_inits():
@@ -288,23 +442,24 @@ def emit_all_inits():
         for outtype in OUTTYPES:
             for inpv in PVS:
                 for outpv in PVS:
-                    for prim in PRIMS:
-                        init(intype, outtype, inpv, outpv, prim)
+                    for pr in PRS:
+                        for prim in PRIMS:
+                            init(intype, outtype, inpv, outpv, pr, prim)
 
 def emit_init():
-    print 'void u_index_init( void )'
-    print '{'
-    print '  static int firsttime = 1;'
-    print '  if (!firsttime) return;'
-    print '  firsttime = 0;'
+    print('void u_index_init( void )')
+    print('{')
+    print('  static int firsttime = 1;')
+    print('  if (!firsttime) return;')
+    print('  firsttime = 0;')
     emit_all_inits()
-    print '}'
+    print('}')
 
 
     
 
 def epilog():
-    print '#include "indices/u_indices.c"'
+    print('#include "indices/u_indices.c"')
 
 
 def main():