Files
clang-p2996/mlir/test/Bindings/Python/ir_location.py
Stella Laurenzo 2d1362e09a Add Location, Region and Block to MLIR Python bindings.
* This is just enough to create regions/blocks and iterate over them.
* Does not yet implement the preferred iteration strategy (python pseudo containers).
* Refinements need to come after doing basic mappings of operations and values so that the whole hierarchy can be used.

Differential Revision: https://reviews.llvm.org/D86683
2020-08-28 15:26:05 -07:00

32 lines
685 B
Python

# RUN: %PYTHON %s | FileCheck %s
import mlir
def run(f):
print("\nTEST:", f.__name__)
f()
# CHECK-LABEL: TEST: testUnknown
def testUnknown():
ctx = mlir.ir.Context()
loc = ctx.get_unknown_location()
# CHECK: unknown str: loc(unknown)
print("unknown str:", str(loc))
# CHECK: unknown repr: loc(unknown)
print("unknown repr:", repr(loc))
run(testUnknown)
# CHECK-LABEL: TEST: testFileLineCol
def testFileLineCol():
ctx = mlir.ir.Context()
loc = ctx.get_file_location("foo.txt", 123, 56)
# CHECK: file str: loc("foo.txt":123:56)
print("file str:", str(loc))
# CHECK: file repr: loc("foo.txt":123:56)
print("file repr:", repr(loc))
run(testFileLineCol)