mirror of
https://github.com/verilator/verilator.git
synced 2026-09-02 18:58:51 +02:00
DFG: Special case representation of AstSel
AstSel is a ternary node, but the 'widthp' is always constant and is hence redundant, and 'lsbp' is very often constant. As AstSel is fairly common, we special case as a DfgSel for the constant 'lsbp', and as 'DfgMux` for the non-constant 'lsbp'.
This commit is contained in:
@@ -332,6 +332,22 @@ class DfgToAstVisitor final : DfgVisitor {
|
||||
m_resultp = vtxp->constp()->cloneTree(false);
|
||||
}
|
||||
|
||||
void visit(DfgSel* vtxp) override {
|
||||
FileLine* const flp = vtxp->fileline();
|
||||
AstNodeMath* const fromp = convertSource(vtxp->fromp());
|
||||
AstConst* const lsbp = new AstConst{flp, vtxp->lsb()};
|
||||
AstConst* const widthp = new AstConst{flp, vtxp->width()};
|
||||
m_resultp = new AstSel{flp, fromp, lsbp, widthp};
|
||||
}
|
||||
|
||||
void visit(DfgMux* vtxp) override {
|
||||
FileLine* const flp = vtxp->fileline();
|
||||
AstNodeMath* const fromp = convertSource(vtxp->fromp());
|
||||
AstNodeMath* const lsbp = convertSource(vtxp->lsbp());
|
||||
AstConst* const widthp = new AstConst{flp, vtxp->width()};
|
||||
m_resultp = new AstSel{flp, fromp, lsbp, widthp};
|
||||
}
|
||||
|
||||
// The rest of the 'visit' methods are generated by 'astgen'
|
||||
#include "V3Dfg__gen_dfg_to_ast.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user