@@ -2332,9 +2332,14 @@ def If(self, expression, uniform: Optional[Uniformity] = None,
23322332 guard = guard )
23332333
23342334 def For (self , argument , unroll = False ,
2335- uniform : Optional [Uniformity ] = None ) -> '_RawBlock' :
2335+ uniform : Optional [Uniformity ] = None ,
2336+ batch : bool = False ) -> '_RawBlock' :
2337+ """A loop whose head is text. `batch` says it is the traversal of
2338+ the batch -- the block's group spelled as text (`BatchLoop`) -- which
2339+ the passes that place something ahead of that loop look for
2340+ (`shards.shard_loads`)."""
23362341 return _RawBlock (self , f'{ _unroll_pragma (unroll )} for ({ argument } )' ,
2337- uniform = uniform )
2342+ uniform = uniform , batch = batch )
23382343
23392344 def While (self , argument ) -> '_RawBlock' :
23402345 return _RawBlock (self , f'while ({ argument } )' )
@@ -2426,12 +2431,13 @@ class _RawBlock:
24262431
24272432 def __init__ (self , builder : IRBuilder , text : str , pragma : Optional [str ] = None ,
24282433 uniform : Optional [Uniformity ] = None ,
2429- guard : Optional [str ] = None ):
2434+ guard : Optional [str ] = None , batch : bool = False ):
24302435 self .builder = builder
24312436 self .text = text
24322437 self .pragma = pragma
24332438 self .uniform = uniform
24342439 self .guard = guard
2440+ self .batch = batch
24352441
24362442 def __enter__ (self ):
24372443 self .builder .push (kind = 'rawblock' )
@@ -2446,6 +2452,8 @@ def __exit__(self, exc_type, exc, tb):
24462452 attrs = attrs + (('uniform' , self .uniform ),)
24472453 if self .guard is not None :
24482454 attrs = attrs + (('guard' , self .guard ),)
2455+ if self .batch :
2456+ attrs = attrs + (('batch' , True ),)
24492457 self .builder .emit (Stmt (op = Op .RAWBLOCK , regions = (region ,), text = self .text ,
24502458 pure = False , movable = False , effect = Effect .NONE ,
24512459 attrs = attrs ))
0 commit comments