From 2f5d66656c42178716ce7a75d274a2447af452b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= <15837247+mofeing@users.noreply.github.com> Date: Tue, 11 Mar 2025 14:47:40 +0100 Subject: [PATCH 1/2] [ReactantExtra] Fix `mlirOperationParse` and add `mlirOperationInject` --- deps/ReactantExtra/API.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/deps/ReactantExtra/API.cpp b/deps/ReactantExtra/API.cpp index e5a5c7bbe5..b8d4aac5c7 100644 --- a/deps/ReactantExtra/API.cpp +++ b/deps/ReactantExtra/API.cpp @@ -227,13 +227,31 @@ extern "C" MlirAttribute mlirComplexAttrDoubleGetChecked(MlirLocation loc, unwrap(loc), cast(unwrap(type)), real, imag)); } +extern "C" bool mlirOperationInject(MlirContext ctx, + MlirBlock block, + MlirStringRef code, + MlirLocation location, + bool verify_after_parse +) { + ParserConfig config(unwrap(ctx), verify_after_parse); + if (failed(parseSourceString(unwrap(code), unwrap(block), config))) + return false; + return true; +} + extern "C" MlirOperation mlirOperationParse(MlirContext ctx, - MlirStringRef code) { - ParserConfig config(unwrap(ctx)); - OwningOpRef owning_op = parseSourceString(unwrap(code), config); - if (!owning_op) + MlirBlock block, + MlirStringRef code, + MlirLocation location, + bool verify_after_parse +) { + ParserConfig config(unwrap(ctx), verify_after_parse); + if (failed(parseSourceString(unwrap(code), unwrap(block), config))) return MlirOperation{nullptr}; - return MlirOperation{owning_op.release()}; + return MlirOperation{ + mlir::detail::constructContainerOpForParserIfNecessary( + unwrap(block), config.getContext(), unwrap(location)).release() + }; } // TODO mlirComplexAttrGetnValue From 6a305e7fab2756dc6d2355b720ed202799aa66b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= <15837247+mofeing@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:53:56 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- deps/ReactantExtra/API.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/deps/ReactantExtra/API.cpp b/deps/ReactantExtra/API.cpp index b8d4aac5c7..f64fd63829 100644 --- a/deps/ReactantExtra/API.cpp +++ b/deps/ReactantExtra/API.cpp @@ -227,31 +227,26 @@ extern "C" MlirAttribute mlirComplexAttrDoubleGetChecked(MlirLocation loc, unwrap(loc), cast(unwrap(type)), real, imag)); } -extern "C" bool mlirOperationInject(MlirContext ctx, - MlirBlock block, - MlirStringRef code, - MlirLocation location, - bool verify_after_parse -) { +extern "C" bool mlirOperationInject(MlirContext ctx, MlirBlock block, + MlirStringRef code, MlirLocation location, + bool verify_after_parse) { ParserConfig config(unwrap(ctx), verify_after_parse); if (failed(parseSourceString(unwrap(code), unwrap(block), config))) return false; return true; } -extern "C" MlirOperation mlirOperationParse(MlirContext ctx, - MlirBlock block, - MlirStringRef code, - MlirLocation location, - bool verify_after_parse -) { +extern "C" MlirOperation mlirOperationParse(MlirContext ctx, MlirBlock block, + MlirStringRef code, + MlirLocation location, + bool verify_after_parse) { ParserConfig config(unwrap(ctx), verify_after_parse); if (failed(parseSourceString(unwrap(code), unwrap(block), config))) return MlirOperation{nullptr}; return MlirOperation{ - mlir::detail::constructContainerOpForParserIfNecessary( - unwrap(block), config.getContext(), unwrap(location)).release() - }; + mlir::detail::constructContainerOpForParserIfNecessary( + unwrap(block), config.getContext(), unwrap(location)) + .release()}; } // TODO mlirComplexAttrGetnValue