[mlir] Fixup python bindings after splitting cf ops from std.
This commit is contained in:
parent
ace01605e0
commit
fe23a6fb75
|
|
@ -72,6 +72,14 @@ declare_mlir_dialect_python_bindings(
|
||||||
dialects/_builtin_ops_ext.py
|
dialects/_builtin_ops_ext.py
|
||||||
DIALECT_NAME builtin)
|
DIALECT_NAME builtin)
|
||||||
|
|
||||||
|
declare_mlir_dialect_python_bindings(
|
||||||
|
ADD_TO_PARENT MLIRPythonSources.Dialects
|
||||||
|
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
|
||||||
|
TD_FILE dialects/ControlFlowOps.td
|
||||||
|
SOURCES
|
||||||
|
dialects/cf.py
|
||||||
|
DIALECT_NAME cf)
|
||||||
|
|
||||||
declare_mlir_dialect_python_bindings(
|
declare_mlir_dialect_python_bindings(
|
||||||
ADD_TO_PARENT MLIRPythonSources.Dialects
|
ADD_TO_PARENT MLIRPythonSources.Dialects
|
||||||
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
|
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
//===-- ControlFlowOps.td - Python ControlFlowOps bindings -*- tablegen -*-===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===---------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef PYTHON_BINDINGS_CONTROL_FLOW_OPS
|
||||||
|
#define PYTHON_BINDINGS_CONTROL_FLOW_OPS
|
||||||
|
|
||||||
|
include "mlir/Bindings/Python/Attributes.td"
|
||||||
|
include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.td"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
# See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
|
from ._cf_ops_gen import *
|
||||||
|
|
@ -5,6 +5,7 @@ import io
|
||||||
import itertools
|
import itertools
|
||||||
from mlir.ir import *
|
from mlir.ir import *
|
||||||
from mlir.dialects import builtin
|
from mlir.dialects import builtin
|
||||||
|
from mlir.dialects import cf
|
||||||
# Note: std dialect needed for terminators.
|
# Note: std dialect needed for terminators.
|
||||||
from mlir.dialects import std
|
from mlir.dialects import std
|
||||||
|
|
||||||
|
|
@ -43,11 +44,11 @@ def testBlockCreation():
|
||||||
|
|
||||||
with InsertionPoint(entry_block) as entry_ip:
|
with InsertionPoint(entry_block) as entry_ip:
|
||||||
assert entry_ip.block == entry_block
|
assert entry_ip.block == entry_block
|
||||||
std.BranchOp([i16_arg], dest=middle_block)
|
cf.BranchOp([i16_arg], dest=middle_block)
|
||||||
|
|
||||||
with InsertionPoint(middle_block) as middle_ip:
|
with InsertionPoint(middle_block) as middle_ip:
|
||||||
assert middle_ip.block == middle_block
|
assert middle_ip.block == middle_block
|
||||||
std.BranchOp([i32_arg], dest=successor_block)
|
cf.BranchOp([i32_arg], dest=successor_block)
|
||||||
print(module.operation)
|
print(module.operation)
|
||||||
# Ensure region back references are coherent.
|
# Ensure region back references are coherent.
|
||||||
assert entry_block.region == middle_block.region == successor_block.region
|
assert entry_block.region == middle_block.region == successor_block.region
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue