This commit moves FuncOp out of the builtin dialect, and into the Func dialect. This move has been planned in some capacity from the moment we made FuncOp an operation (years ago). This commit handles the functional aspects of the move, but various aspects are left untouched to ease migration: func::FuncOp is re-exported into mlir to reduce the actual API churn, the assembly format still accepts the unqualified `func`. These temporary measures will remain for a little while to simplify migration before being removed. Differential Revision: https://reviews.llvm.org/D121266
42 lines
1.2 KiB
MLIR
42 lines
1.2 KiB
MLIR
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func.func(canonicalize{top-down=true})' | FileCheck %s --check-prefix=TD
|
|
// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func.func(canonicalize)' | FileCheck %s --check-prefix=BU
|
|
|
|
|
|
// BU-LABEL: func @default_insertion_position
|
|
// TD-LABEL: func @default_insertion_position
|
|
func @default_insertion_position(%cond: i1) {
|
|
// Constant should be folded into the entry block.
|
|
|
|
// BU: arith.constant 2
|
|
// BU-NEXT: scf.if
|
|
|
|
// TD: arith.constant 2
|
|
// TD-NEXT: scf.if
|
|
scf.if %cond {
|
|
%0 = arith.constant 1 : i32
|
|
%2 = arith.addi %0, %0 : i32
|
|
"foo.yield"(%2) : (i32) -> ()
|
|
}
|
|
return
|
|
}
|
|
|
|
// This shows that we don't pull the constant out of the region because it
|
|
// wants to be the insertion point for the constant.
|
|
// BU-LABEL: func @custom_insertion_position
|
|
// TD-LABEL: func @custom_insertion_position
|
|
func @custom_insertion_position() {
|
|
// BU: test.one_region_op
|
|
// BU-NEXT: arith.constant 2
|
|
|
|
// TD: test.one_region_op
|
|
// TD-NEXT: arith.constant 2
|
|
"test.one_region_op"() ({
|
|
|
|
%0 = arith.constant 1 : i32
|
|
%2 = arith.addi %0, %0 : i32
|
|
"foo.yield"(%2) : (i32) -> ()
|
|
}) : () -> ()
|
|
return
|
|
}
|
|
|