30 DeviceOp deviceOp = getOperation();
32 for (
auto coreOp : deviceOp.getOps<CoreOp>()) {
36 auto thisTile = dyn_cast<TileOp>(coreOp.getTile().getDefiningOp());
37 int col = thisTile.colIndex();
38 int row = thisTile.rowIndex();
41 SmallVector<TileOp, 4> accessibleTiles;
42 for (
auto tile : deviceOp.getOps<TileOp>())
43 if (
int dstRow = tile.rowIndex();
44 targetModel.isLegalMemAffinity(
col,
row, tile.colIndex(), dstRow))
45 accessibleTiles.push_back(tile);
47 for (
auto tile : accessibleTiles) {
48 int dstCol = tile.colIndex();
49 int dstRow = tile.rowIndex();
52 for (
auto user : tile.getResult().getUsers())
53 if (
auto lock = dyn_cast<LockOp>(user)) {
54 auto lockIndexOffset =
55 targetModel.getLockLocalBaseIndex(
col,
row, dstCol, dstRow);
57 llvm_unreachable(
"Found illegal lock user!");
60 lockIndexOffset.value() + lock.getLockIDValue();
63 OpBuilder::atBlockBegin(&coreOp.getBody().front());
65 Value coreLockIDValue = builder.create<arith::ConstantIndexOp>(
66 builder.getUnknownLoc(), localLockIndex);
67 lock.getResult().replaceUsesWithIf(
68 coreLockIDValue, [&](OpOperand &opOperand) {
69 return opOperand.getOwner()->getParentOp() == coreOp;