[mlir][py][c] Enable setting block arg locations. (#169033)

This enables changing the location of a block argument. Follows the
approach for updating type of block arg.
This commit is contained in:
Jacques Pienaar
2025-11-21 15:31:46 +02:00
committed by GitHub
parent 4fca7b05e3
commit 5ab49edde2
4 changed files with 30 additions and 0 deletions

View File

@@ -191,3 +191,18 @@ def testBlockEraseArgs():
blocks[0].erase_argument(0)
# CHECK: ^bb0:
op.print(enable_debug_info=True)
# CHECK-LABEL: TEST: testBlockArgSetLocation
# CHECK: ^bb0(%{{.+}}: f32 loc("new_loc")):
@run
def testBlockArgSetLocation():
with Context() as ctx, Location.unknown(ctx) as loc:
ctx.allow_unregistered_dialects = True
f32 = F32Type.get()
op = Operation.create("test", regions=1, loc=Location.unknown())
blocks = op.regions[0].blocks
blocks.append(f32)
arg = blocks[0].arguments[0]
arg.set_location(Location.name("new_loc"))
op.print(enable_debug_info=True)