| 2490 | } |
| 2491 | |
| 2492 | void ForOp::build( |
| 2493 | OpBuilder &builder, OperationState &result, Value lb, Value ub, Value step, |
| 2494 | ValueRange initArgs, |
| 2495 | function_ref<void(OpBuilder &, Location, Value, ValueRange)> bodyBuilder, |
| 2496 | bool unsignedCmp) { |
| 2497 | OpBuilder::InsertionGuard guard(builder); |
| 2498 | |
| 2499 | result.addOperands({lb, ub, step}); |
| 2500 | result.addOperands(initArgs); |
| 2501 | if (unsignedCmp) |
| 2502 | result.addAttribute(getUnsignedCmpAttrName(result.name), |
| 2503 | builder.getUnitAttr()); |
| 2504 | Region *bodyRegion = result.addRegion(); |
| 2505 | Block *bodyBlock = builder.createBlock(bodyRegion); |
| 2506 | bodyBlock->addArgument(lb.getType(), result.location); |
| 2507 | for (Value v : initArgs) { |
| 2508 | result.addTypes(v.getType()); |
| 2509 | bodyBlock->addArgument(v.getType(), v.getLoc()); |
| 2510 | } |
| 2511 | // Create the default terminator if the builder is not provided and if the |
| 2512 | // iteration arguments are not provided. Otherwise, leave this to the caller |
| 2513 | // because we don't know which values to return from the loop. |
| 2514 | if (initArgs.empty() && !bodyBuilder) { |
| 2515 | ForOp::ensureTerminator(*bodyRegion, builder, result.location); |
| 2516 | } else if (bodyBuilder) { |
| 2517 | OpBuilder::InsertionGuard guard(builder); |
| 2518 | builder.setInsertionPointToStart(bodyBlock); |
| 2519 | bodyBuilder(builder, result.location, bodyBlock->getArgument(0), |
| 2520 | bodyBlock->getArguments().drop_front()); |
| 2521 | } |
| 2522 | } |
| 2523 | |
| 2524 | LogicalResult ForOp::verifyRegions() { |
| 2525 | // First block argument must be the induction variable. |
nothing calls this directly
no test coverage detected