[Mlir-commits] [mlir] [mlir][EmitC] Remove restrictions on include op (PR #106953)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 2 02:22:52 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-emitc
Author: Marius Brehler (marbre)
<details>
<summary>Changes</summary>
An `emitc.include` should be usable even though the parent is not a ModuleOp. This requirement is therefor therefor.
---
Full diff: https://github.com/llvm/llvm-project/pull/106953.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/EmitC/IR/EmitC.td (+1-1)
- (modified) mlir/test/Target/Cpp/common-cpp.mlir (+7)
``````````diff
diff --git a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
index 5122da599b4ce4..2c1ac27cfb8ff8 100644
--- a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
+++ b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
@@ -730,7 +730,7 @@ def EmitC_ReturnOp : EmitC_Op<"return", [Pure, HasParent<"FuncOp">,
}
def EmitC_IncludeOp
- : EmitC_Op<"include", [HasParent<"ModuleOp">]> {
+ : EmitC_Op<"include", []> {
let summary = "Include operation";
let description = [{
The `emitc.include` operation allows to define a source file inclusion via the
diff --git a/mlir/test/Target/Cpp/common-cpp.mlir b/mlir/test/Target/Cpp/common-cpp.mlir
index 2036a10e0cad15..45fef618621ccd 100644
--- a/mlir/test/Target/Cpp/common-cpp.mlir
+++ b/mlir/test/Target/Cpp/common-cpp.mlir
@@ -5,6 +5,13 @@ emitc.include "myheader.h"
// CHECK: #include <myheader.h>
emitc.include <"myheader.h">
+// CHECK: void test_include() {
+func.func @test_include() {
+ // CHECK: #include "myheader.h"
+ emitc.include "myheader.h"
+ return
+}
+
// CHECK: void test_foo_print() {
func.func @test_foo_print() {
// CHECK: [[V1:[^ ]*]] = foo::constant({0, 1});
``````````
</details>
https://github.com/llvm/llvm-project/pull/106953
More information about the Mlir-commits
mailing list