Skip to content

Commit 7aec717

Browse files
committed
Verilog: modernise signature of verilog_synthesist::assignment_rec
This replaces a return-by reference and a swap by an explicit return value in the signature of the method verilog_synthesist::assignment_rec(...).
1 parent ef9a06d commit 7aec717

File tree

2 files changed

+12
-38
lines changed

2 files changed

+12
-38
lines changed

src/verilog/verilog_synthesis.cpp

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ 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+
exprt new_rhs(rhs);
653+
auto new_value = assignment_rec(lhs, new_rhs); // start of recursion
654654

655655
if(new_value.is_not_nil())
656656
{
@@ -683,15 +683,11 @@ Function: verilog_synthesist::assignment_rec
683683
684684
\*******************************************************************/
685685

686-
void verilog_synthesist::assignment_rec(
687-
const exprt &lhs,
688-
exprt &rhs,
689-
exprt &new_value)
686+
exprt verilog_synthesist::assignment_rec(const exprt &lhs, const exprt &rhs)
690687
{
691688
if(lhs.id()==ID_symbol)
692689
{
693-
new_value.swap(rhs);
694-
rhs.clear();
690+
return rhs;
695691
}
696692
else if(lhs.id()==ID_index ||
697693
lhs.id()==ID_extractbit)
@@ -718,7 +714,7 @@ void verilog_synthesist::assignment_rec(
718714
new_rhs.where() = synth_expr(new_rhs.where(), symbol_statet::CURRENT);
719715

720716
// do the value
721-
assignment_rec(lhs_array, new_rhs, new_value); // recursive call
717+
return assignment_rec(lhs_array, new_rhs); // recursive call
722718
}
723719
else if(lhs.id() == ID_verilog_non_indexed_part_select)
724720
{
@@ -749,8 +745,7 @@ void verilog_synthesist::assignment_rec(
749745
// redundant?
750746
if(from == 0 && to == get_width(lhs_src.type()) - 1)
751747
{
752-
assignment_rec(lhs_src, rhs, new_value); // recursive call
753-
return;
748+
return assignment_rec(lhs_src, rhs); // recursive call
754749
}
755750

756751
// turn
@@ -791,7 +786,7 @@ void verilog_synthesist::assignment_rec(
791786
new_rhs.add_to_operands(std::move(rhs_extractbit));
792787

793788
// do the value
794-
assignment_rec(lhs_src, new_rhs, new_value); // recursive call
789+
exprt new_value = assignment_rec(lhs_src, new_rhs); // recursive call
795790

796791
if(last_value.is_nil())
797792
last_value.swap(new_value);
@@ -809,7 +804,7 @@ void verilog_synthesist::assignment_rec(
809804
}
810805
}
811806

812-
new_value.swap(last_value);
807+
return last_value;
813808
}
814809
else if(
815810
lhs.id() == ID_verilog_indexed_part_select_plus ||
@@ -878,7 +873,7 @@ void verilog_synthesist::assignment_rec(
878873
new_rhs.add_to_operands(std::move(rhs_extractbit));
879874

880875
// do the value
881-
assignment_rec(lhs_src, new_rhs, new_value); // recursive call
876+
exprt new_value = assignment_rec(lhs_src, new_rhs); // recursive call
882877

883878
if(last_value.is_nil())
884879
last_value.swap(new_value);
@@ -896,7 +891,7 @@ void verilog_synthesist::assignment_rec(
896891
}
897892
}
898893

899-
new_value.swap(last_value);
894+
return last_value;
900895
}
901896
else if(lhs.id() == ID_member)
902897
{
@@ -918,7 +913,7 @@ void verilog_synthesist::assignment_rec(
918913
synth_compound, member_designatort{component_name}, rhs};
919914

920915
// recursive call
921-
assignment_rec(lhs_compound, new_rhs, new_value); // recursive call
916+
return assignment_rec(lhs_compound, new_rhs); // recursive call
922917
}
923918
else
924919
{
@@ -929,24 +924,6 @@ void verilog_synthesist::assignment_rec(
929924
{
930925
throw errort() << "unexpected lhs: " << lhs.id();
931926
}
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
950927
}
951928

952929
/*******************************************************************\

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)