34 DeviceOp deviceOp = getOperation();
36 for (
auto coreOp : deviceOp.getOps<CoreOp>()) {
40 auto thisTile = cast<TileOp>(coreOp.getTile().getDefiningOp());
41 int col = thisTile.colIndex();
42 int row = thisTile.rowIndex();
45 SmallVector<TileOp, 4> accessibleTiles;
46 for (
auto tile : deviceOp.getOps<TileOp>())
47 if (
int dstRow = tile.rowIndex();
48 targetModel.isLegalMemAffinity(col, row, tile.colIndex(), dstRow))
49 accessibleTiles.push_back(tile);
51 for (
auto tile : accessibleTiles) {
52 int dstCol = tile.colIndex();
53 int dstRow = tile.rowIndex();
56 for (
auto *user : tile.getResult().getUsers())
57 if (
auto lock = dyn_cast<LockOp>(user)) {
63 if (llvm::none_of(lock.getResult().getUsers(),
64 [&](Operation *user) {
65 return user->getParentOp() == coreOp;
69 auto lockIndexOffset =
70 targetModel.getLockLocalBaseIndex(col, row, dstCol, dstRow);
72 llvm_unreachable(
"Found illegal lock user!");
75 lockIndexOffset.value() + lock.getLockIDValue();
78 OpBuilder::atBlockBegin(&coreOp.getBody().front());
80 Value coreLockIDValue = arith::ConstantIndexOp::create(
81 builder, lock.getLoc(), localLockIndex);
82 lock.getResult().replaceUsesWithIf(
83 coreLockIDValue, [&](OpOperand &opOperand) {
84 return opOperand.getOwner()->getParentOp() == coreOp;