Skip to content

Commit

Permalink
pr: Fix cond yield conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Jan 31, 2025
1 parent 9d095ed commit 4de5f79
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/vast/Conversion/Parser/ToParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,24 @@ namespace vast::conv {
logical_result matchAndRewrite(
op_t op, adaptor_t adaptor, conversion_rewriter &rewriter
) const override {
auto operand = adaptor.getResult().getDefiningOp();
if (auto cast = mlir::dyn_cast< mlir::UnrealizedConversionCastOp >(operand)) {
auto operand = adaptor.getResult();

if (auto cast = mlir::dyn_cast< mlir::UnrealizedConversionCastOp >(operand.getDefiningOp())) {
if (pr::is_parser_type(cast.getOperand(0).getType())) {
rewriter.replaceOpWithNewOp< op_t >(op, cast.getOperand(0));
return mlir::success();
}
}

if (pr::is_parser_type(operand.getType())) {
rewriter.replaceOpWithNewOp< op_t >(op, operand);
return mlir::success();
}

auto cast = rewriter.create< mlir::UnrealizedConversionCastOp >(
op.getLoc(), pr::MaybeDataType::get(op.getContext()), operand
);
rewriter.replaceOpWithNewOp< op_t >(op, cast.getResult(0));
return mlir::success();
}

Expand Down

0 comments on commit 4de5f79

Please sign in to comment.