From 1f32f1988c24d62235864a37f5195feb0ae9be77 Mon Sep 17 00:00:00 2001 From: Chris Leary Date: Tue, 2 Apr 2024 16:18:08 -0700 Subject: [PATCH] [DSLX:TS] Rename InstantiateParametricArgs to AppendArgsForInstantiation. It wasn't doing anything with parametrics, was just inferring the types of expressions in a way that was typically used /as preparation/ for parametric instantiation. Between the name and the comment being more appropriate I think it's less confusing now. PiperOrigin-RevId: 621326853 --- xls/dslx/type_system/deduce.cc | 4 ++-- xls/dslx/type_system/deduce_invocation.cc | 8 ++++---- xls/dslx/type_system/deduce_invocation.h | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/xls/dslx/type_system/deduce.cc b/xls/dslx/type_system/deduce.cc index 83cbf78ce2..57c28d22a9 100644 --- a/xls/dslx/type_system/deduce.cc +++ b/xls/dslx/type_system/deduce.cc @@ -2202,13 +2202,13 @@ absl::StatusOr> DeduceSpawn(const Spawn* node, // Gather up the type of all the (actual) arguments. std::vector config_args; - XLS_RETURN_IF_ERROR(InstantiateParametricArgs( + XLS_RETURN_IF_ERROR(AppendArgsForInstantiation( node, node->callee(), node->config()->args(), ctx, &config_args)); std::vector next_args; next_args.push_back( InstantiateArg{std::make_unique(), node->span()}); - XLS_RETURN_IF_ERROR(InstantiateParametricArgs( + XLS_RETURN_IF_ERROR(AppendArgsForInstantiation( node, node->callee(), node->next()->args(), ctx, &next_args)); // For each [constexpr] arg, mark the associated Param as constexpr. diff --git a/xls/dslx/type_system/deduce_invocation.cc b/xls/dslx/type_system/deduce_invocation.cc index 7b3552f121..d7f1418423 100644 --- a/xls/dslx/type_system/deduce_invocation.cc +++ b/xls/dslx/type_system/deduce_invocation.cc @@ -199,14 +199,14 @@ absl::StatusOr DeduceInstantiation( {}}; } -absl::Status InstantiateParametricArgs( +absl::Status AppendArgsForInstantiation( const Instantiation* inst, const Expr* callee, absl::Span args, DeduceCtx* ctx, std::vector* instantiate_args) { for (Expr* arg : args) { XLS_ASSIGN_OR_RETURN(std::unique_ptr type, DeduceAndResolve(arg, ctx)); VLOG(5) << absl::StreamFormat( - "InstantiateParametricArgs; arg: `%s` deduced: `%s` @ %s", + "AppendArgsForInstantiation; arg: `%s` deduced: `%s` @ %s", arg->ToString(), type->ToString(), arg->span().ToString()); XLS_RET_CHECK(!type->IsMeta()) << "parametric arg: " << arg->ToString() << " type: " << type->ToString(); @@ -240,8 +240,8 @@ absl::StatusOr> DeduceInvocation(const Invocation* node, // Gather up the type of all the (actual) arguments. std::vector args; - XLS_RETURN_IF_ERROR(InstantiateParametricArgs(node, node->callee(), - node->args(), ctx, &args)); + XLS_RETURN_IF_ERROR(AppendArgsForInstantiation(node, node->callee(), + node->args(), ctx, &args)); // Find the callee as a DSLX Function from the expression. auto resolve_fn = [](const Instantiation* node, diff --git a/xls/dslx/type_system/deduce_invocation.h b/xls/dslx/type_system/deduce_invocation.h index a7e795b8f6..46be6588c1 100644 --- a/xls/dslx/type_system/deduce_invocation.h +++ b/xls/dslx/type_system/deduce_invocation.h @@ -17,15 +17,12 @@ #include #include -#include #include -#include "absl/container/flat_hash_map.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/span.h" #include "xls/dslx/frontend/ast.h" -#include "xls/dslx/interp_value.h" #include "xls/dslx/type_system/ast_env.h" #include "xls/dslx/type_system/deduce_ctx.h" #include "xls/dslx/type_system/parametric_constraint.h" @@ -37,9 +34,10 @@ namespace xls::dslx { absl::StatusOr> DeduceInvocation(const Invocation* node, DeduceCtx* ctx); -// Helper that deduces the concrete types of the arguments to a parametric -// function or proc and returns them to the caller. -absl::Status InstantiateParametricArgs( +// Helper that deduces the concrete types of the arguments and appends them to +// "instantiate_args" -- getting them in this form is often a pre-step in +// instantiating a parametric function or proc. +absl::Status AppendArgsForInstantiation( const Instantiation* inst, const Expr* callee, absl::Span args, DeduceCtx* ctx, std::vector* instantiate_args);