From 6a724e542b9626a18c68a99a043703d9f1795f0a Mon Sep 17 00:00:00 2001 From: Fabian Schuiki Date: Sat, 28 Sep 2024 14:18:06 -0700 Subject: [PATCH] [ImportVerilog] Materialize constant calls directly Instead of lowering constant calls to functions and system tasks, materialize the constant value directly. --- lib/Conversion/ImportVerilog/Expressions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Conversion/ImportVerilog/Expressions.cpp b/lib/Conversion/ImportVerilog/Expressions.cpp index a17865043e74..15f1b4e0590e 100644 --- a/lib/Conversion/ImportVerilog/Expressions.cpp +++ b/lib/Conversion/ImportVerilog/Expressions.cpp @@ -636,6 +636,12 @@ struct RvalueExprVisitor { mlir::emitError(loc, "unsupported class method call"); return {}; } + + // Try to materialize constant values directly. + auto constant = context.evaluateConstant(expr); + if (auto value = context.materializeConstant(constant, *expr.type, loc)) + return value; + return std::visit( [&](auto &subroutine) { return visitCall(expr, subroutine); }, expr.subroutine);