Skip to content

Commit 641c09e

Browse files
authored
Merge pull request #1324 from diffblue/synth-assignment-rec-signature
Verilog: modernise signature of `verilog_synthesist::assignment_rec`
2 parents ef9a06d + a913502 commit 641c09e

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

src/verilog/verilog_synthesis.cpp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ void verilog_synthesist::assignment_rec(
649649
{
650650
assert(value_map!=NULL);
651651

652-
exprt new_rhs(rhs), new_value;
653-
assignment_rec(lhs, new_rhs, new_value); // start of recursion
652+
auto new_value = assignment_rec(lhs, rhs); // start of recursion
654653

655654
if(new_value.is_not_nil())
656655
{
@@ -683,15 +682,11 @@ Function: verilog_synthesist::assignment_rec
683682
684683
\*******************************************************************/
685684

686-
void verilog_synthesist::assignment_rec(
687-
const exprt &lhs,
688-
exprt &rhs,
689-
exprt &new_value)
685+
exprt verilog_synthesist::assignment_rec(const exprt &lhs, const exprt &rhs)
690686
{
691687
if(lhs.id()==ID_symbol)
692688
{
693-
new_value.swap(rhs);
694-
rhs.clear();
689+
return rhs;
695690
}
696691
else if(lhs.id()==ID_index ||
697692
lhs.id()==ID_extractbit)
@@ -718,7 +713,7 @@ void verilog_synthesist::assignment_rec(
718713
new_rhs.where() = synth_expr(new_rhs.where(), symbol_statet::CURRENT);
719714

720715
// do the value
721-
assignment_rec(lhs_array, new_rhs, new_value); // recursive call
716+
return assignment_rec(lhs_array, new_rhs); // recursive call
722717
}
723718
else if(lhs.id() == ID_verilog_non_indexed_part_select)
724719
{
@@ -749,8 +744,7 @@ void verilog_synthesist::assignment_rec(
749744
// redundant?
750745
if(from == 0 && to == get_width(lhs_src.type()) - 1)
751746
{
752-
assignment_rec(lhs_src, rhs, new_value); // recursive call
753-
return;
747+
return assignment_rec(lhs_src, rhs); // recursive call
754748
}
755749

756750
// turn
@@ -791,7 +785,7 @@ void verilog_synthesist::assignment_rec(
791785
new_rhs.add_to_operands(std::move(rhs_extractbit));
792786

793787
// do the value
794-
assignment_rec(lhs_src, new_rhs, new_value); // recursive call
788+
exprt new_value = assignment_rec(lhs_src, new_rhs); // recursive call
795789

796790
if(last_value.is_nil())
797791
last_value.swap(new_value);
@@ -809,7 +803,7 @@ void verilog_synthesist::assignment_rec(
809803
}
810804
}
811805

812-
new_value.swap(last_value);
806+
return last_value;
813807
}
814808
else if(
815809
lhs.id() == ID_verilog_indexed_part_select_plus ||
@@ -878,7 +872,7 @@ void verilog_synthesist::assignment_rec(
878872
new_rhs.add_to_operands(std::move(rhs_extractbit));
879873

880874
// do the value
881-
assignment_rec(lhs_src, new_rhs, new_value); // recursive call
875+
exprt new_value = assignment_rec(lhs_src, new_rhs); // recursive call
882876

883877
if(last_value.is_nil())
884878
last_value.swap(new_value);
@@ -896,7 +890,7 @@ void verilog_synthesist::assignment_rec(
896890
}
897891
}
898892

899-
new_value.swap(last_value);
893+
return last_value;
900894
}
901895
else if(lhs.id() == ID_member)
902896
{
@@ -918,7 +912,7 @@ void verilog_synthesist::assignment_rec(
918912
synth_compound, member_designatort{component_name}, rhs};
919913

920914
// recursive call
921-
assignment_rec(lhs_compound, new_rhs, new_value); // recursive call
915+
return assignment_rec(lhs_compound, new_rhs); // recursive call
922916
}
923917
else
924918
{
@@ -929,24 +923,6 @@ void verilog_synthesist::assignment_rec(
929923
{
930924
throw errort() << "unexpected lhs: " << lhs.id();
931925
}
932-
933-
#if 0
934-
// do "with" merging
935-
936-
if(new_value.id()==ID_with &&
937-
new_value.op0().id()==ID_with)
938-
{
939-
exprt tmp;
940-
941-
tmp.swap(new_value.op0());
942-
943-
tmp.reserve_operands(tmp.operands().size()+2);
944-
tmp.add_to_operands(std::move(new_value.op1()));
945-
tmp.add_to_operands(std::move(new_value.op2()));
946-
947-
new_value.swap(tmp);
948-
}
949-
#endif
950926
}
951927

952928
/*******************************************************************\

src/verilog/verilog_synthesis_class.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,7 @@ class verilog_synthesist:
222222

223223
void assignment_rec(const exprt &lhs, const exprt &rhs, bool blocking);
224224

225-
void assignment_rec(
226-
const exprt &lhs,
227-
exprt &rhs,
228-
exprt &new_value);
225+
exprt assignment_rec(const exprt &lhs, const exprt &rhs);
229226

230227
const symbolt &assignment_symbol(const exprt &lhs);
231228

0 commit comments

Comments
 (0)