@@ -281,18 +281,17 @@ namespace vast::conv {
281281 : base(mctx), models(models)
282282 {}
283283
284- static std::optional< function_model > get_model (
285- const function_models &models, string_ref name
286- ) {
287- if (auto kv = models.find (name); kv != models.end ()) {
284+ static std::optional< function_model >
285+ get_model (const function_models &models, hl::FuncOp func) {
286+ if (auto kv = models.find (func.getSymName ()); kv != models.end ()) {
288287 return kv->second ;
289288 }
290289
291290 return std::nullopt ;
292291 }
293292
294- std::optional< function_model > get_model (string_ref name ) const {
295- return get_model (models, name );
293+ std::optional< function_model > get_model (hl::FuncOp func ) const {
294+ return get_model (models, func );
296295 }
297296
298297 const function_models ⊧
@@ -494,7 +493,7 @@ namespace vast::conv {
494493 op_t op, adaptor_t adaptor, conversion_rewriter &rewriter
495494 ) const override {
496495 auto func = op->getParentOfType < hl::FuncOp >();
497- auto model = get_model (func. getSymName () );
496+ auto model = get_model (func);
498497
499498 auto rty = model
500499 ? model->get_return_type (rewriter.getContext ())
@@ -534,7 +533,7 @@ namespace vast::conv {
534533 logical_result matchAndRewrite (
535534 op_t op, adaptor_t adaptor, conversion_rewriter &rewriter
536535 ) const override {
537- auto tc = function_type_converter (*rewriter.getContext (), get_model (op. getSymName () ));
536+ auto tc = function_type_converter (*rewriter.getContext (), get_model (op));
538537 if (auto func_op = mlir::dyn_cast< core::function_op_interface >(op.getOperation ())) {
539538 return this ->replace (func_op, rewriter, tc);
540539 }
@@ -545,9 +544,8 @@ namespace vast::conv {
545544 static void legalize (parser_conversion_config &cfg) {
546545 cfg.target .addLegalOp < mlir::UnrealizedConversionCastOp >();
547546 cfg.target .addDynamicallyLegalOp < op_t >([models = cfg.models ](op_t op) {
548- return function_type_converter (
549- *op.getContext (), get_model (models, op.getSymName ())
550- ).isLegal (op.getFunctionType ());
547+ return function_type_converter (*op.getContext (), get_model (models, op))
548+ .isLegal (op.getFunctionType ());
551549 });
552550 }
553551 };
0 commit comments