(self,
argTypes,
bodyBuilder,
inputs,
evalCond,
evalStep,
orElseBuilder=None)
| 1354 | self.emitFatalError(msg, annotation) |
| 1355 | |
| 1356 | def createForLoop(self, |
| 1357 | argTypes, |
| 1358 | bodyBuilder, |
| 1359 | inputs, |
| 1360 | evalCond, |
| 1361 | evalStep, |
| 1362 | orElseBuilder=None): |
| 1363 | |
| 1364 | # post-conditional would be a do-while loop |
| 1365 | isPostConditional = BoolAttr.get(False) |
| 1366 | loop = cc.LoopOp(argTypes, inputs, isPostConditional) |
| 1367 | |
| 1368 | whileBlock = Block.create_at_start(loop.whileRegion, argTypes) |
| 1369 | with InsertionPoint(whileBlock): |
| 1370 | condVal = evalCond(whileBlock.arguments) |
| 1371 | cc.ConditionOp(condVal, whileBlock.arguments) |
| 1372 | |
| 1373 | bodyBlock = Block.create_at_start(loop.bodyRegion, argTypes) |
| 1374 | with InsertionPoint(bodyBlock): |
| 1375 | self.symbolTable.beginBlock() |
| 1376 | self.pushForBodyStack(bodyBlock.arguments) |
| 1377 | bodyBuilder(bodyBlock.arguments) |
| 1378 | if not self.hasTerminator(bodyBlock): |
| 1379 | cc.ContinueOp(bodyBlock.arguments) |
| 1380 | self.popForBodyStack() |
| 1381 | self.symbolTable.endBlock() |
| 1382 | |
| 1383 | stepBlock = Block.create_at_start(loop.stepRegion, argTypes) |
| 1384 | with InsertionPoint(stepBlock): |
| 1385 | stepVals = evalStep(stepBlock.arguments) |
| 1386 | cc.ContinueOp(stepVals) |
| 1387 | |
| 1388 | if orElseBuilder: |
| 1389 | elseBlock = Block.create_at_start(loop.elseRegion, argTypes) |
| 1390 | with InsertionPoint(elseBlock): |
| 1391 | self.symbolTable.beginBlock() |
| 1392 | orElseBuilder(elseBlock.arguments) |
| 1393 | if not self.hasTerminator(elseBlock): |
| 1394 | cc.ContinueOp(elseBlock.arguments) |
| 1395 | self.symbolTable.endBlock() |
| 1396 | |
| 1397 | return loop |
| 1398 | |
| 1399 | def createMonotonicForLoop(self, |
| 1400 | bodyBuilder, |
no test coverage detected