From 08752453b4e1bcdf222f0f92bbcf862bc3e67eea Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 22 Dec 2007 17:19:45 -0500 Subject: [PATCH] File line information for expressions Add ivl_target support for file and line numbers of expressions. --- elab_expr.cc | 1 + ivl.def | 2 ++ ivl_target.h | 2 ++ t-dll-api.cc | 11 +++++++++++ t-dll-expr.cc | 3 +++ t-dll-proc.cc | 10 ---------- t-dll.h | 18 ++++++++++++++++++ tgt-stub/expression.c | 5 +++-- 8 files changed, 40 insertions(+), 12 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 92bd68a73..903c69bea 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -512,6 +512,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope, int expr_w NetESFunc*fun = new NetESFunc(peek_tail_name(path_), sfunc_type, wid, nparms); + fun->set_line(*this); if (sfunc_info->signed_flag) fun->cast_signed(true); diff --git a/ivl.def b/ivl.def index c3dcd1696..ded7f8a89 100644 --- a/ivl.def +++ b/ivl.def @@ -29,6 +29,8 @@ ivl_expr_bits ivl_expr_def ivl_expr_dvalue ivl_expr_event +ivl_expr_file +ivl_expr_lineno ivl_expr_name ivl_expr_opcode ivl_expr_oper1 diff --git a/ivl_target.h b/ivl_target.h index cd8ffa1e8..71a8acf02 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -646,6 +646,8 @@ extern ivl_nexus_t ivl_event_pos(ivl_event_t net, unsigned idx); extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net); extern ivl_variable_type_t ivl_expr_value(ivl_expr_t net); +extern const char*ivl_expr_file(ivl_expr_t net); +extern unsigned ivl_expr_lineno(ivl_expr_t net); /* IVL_EX_NUMBER */ extern const char* ivl_expr_bits(ivl_expr_t net); diff --git a/t-dll-api.cc b/t-dll-api.cc index 792c8c390..071a6d879 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -91,6 +91,17 @@ extern "C" ivl_expr_type_t ivl_expr_type(ivl_expr_t net) return net->type_; } +extern "C" const char*ivl_expr_file(ivl_expr_t net) +{ + assert(net); + return net->file.str(); +} + +extern "C" unsigned ivl_expr_lineno(ivl_expr_t net) +{ + assert(net); + return net->lineno; +} inline static const char *basename(ivl_scope_t scope, const char *inst) { diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 8ad48cf34..16e90d91e 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -334,6 +334,7 @@ void dll_target::expr_sfunc(const NetESFunc*net) assert(expr); expr->type_ = IVL_EX_SFUNC; + FILE_NAME(expr, net); expr->value_= net->expr_type(); expr->width_= net->expr_width(); expr->signed_ = net->has_sign()? 1 : 0; @@ -363,6 +364,7 @@ void dll_target::expr_ternary(const NetETernary*net) assert(expr); expr->type_ = IVL_EX_TERNARY; + FILE_NAME(expr, net); expr->value_= net->expr_type(); expr->width_ = net->expr_width(); expr->signed_ = net->has_sign()? 1 : 0; @@ -429,6 +431,7 @@ void dll_target::expr_ufunc(const NetEUFunc*net) assert(expr); expr->type_ = IVL_EX_UFUNC; + FILE_NAME(expr, net); expr->value_= net->expr_type(); expr->width_= net->expr_width(); expr->signed_ = net->has_sign()? 1 : 0; diff --git a/t-dll-proc.cc b/t-dll-proc.cc index c85777ec5..b3c998768 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -34,16 +34,6 @@ #endif # include -/* - * The FILE_NAME function is a shorthand for attaching file/line - * information to the statement object. - */ -static inline void FILE_NAME(ivl_statement_t stmt, const LineInfo*info) -{ - stmt->file = info->get_file(); - stmt->lineno = info->get_lineno(); -} - bool dll_target::process(const NetProcTop*net) { ivl_process_t obj = (struct ivl_process_s*) diff --git a/t-dll.h b/t-dll.h index 1f6ab711b..b54789b62 100644 --- a/t-dll.h +++ b/t-dll.h @@ -199,6 +199,8 @@ struct ivl_event_s { struct ivl_expr_s { ivl_expr_type_t type_; ivl_variable_type_t value_; + perm_string file; + unsigned lineno; unsigned width_; unsigned signed_ : 1; @@ -683,4 +685,20 @@ struct ivl_statement_s { } u_; }; +/* + * The FILE_NAME function is a shorthand for attaching file/line + * information to the statement object. + */ +static inline void FILE_NAME(ivl_statement_t stmt, const LineInfo*info) +{ + stmt->file = info->get_file(); + stmt->lineno = info->get_lineno(); +} + +static inline void FILE_NAME(ivl_expr_t expr, const LineInfo*info) +{ + expr->file = info->get_file(); + expr->lineno = info->get_lineno(); +} + #endif diff --git a/tgt-stub/expression.c b/tgt-stub/expression.c index b992d15f5..2de7b787e 100644 --- a/tgt-stub/expression.c +++ b/tgt-stub/expression.c @@ -233,8 +233,9 @@ void show_expression(ivl_expr_t net, unsigned ind) break; case IVL_EX_SFUNC: - fprintf(out, "%*s\n", - ind, "", ivl_expr_name(net), width, sign, vt); + fprintf(out, "%*s\n", + ind, "", ivl_expr_name(net), width, sign, vt, + ivl_expr_file(net), ivl_expr_lineno(net)); { unsigned cnt = ivl_expr_parms(net); unsigned idx; for (idx = 0 ; idx < cnt ; idx += 1)