mirror of
https://github.com/verilator/verilator.git
synced 2026-08-30 17:51:59 +02:00
Internals: Four state pre-pull (types) (#7520)
This commit is contained in:
+27
-27
@@ -430,7 +430,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
if (m_vup->prelim()) {
|
||||
// See similar handling in visit_cmp_eq_gt where created
|
||||
iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH);
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInt();
|
||||
}
|
||||
}
|
||||
void visit(AstPutcN* nodep) override {
|
||||
@@ -485,7 +485,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
// See similar handling in visit_cmp_eq_gt where created
|
||||
iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH);
|
||||
iterateCheckString(nodep, "RHS", nodep->rhsp(), BOTH);
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInt();
|
||||
}
|
||||
}
|
||||
void visit(AstAtoN* nodep) override {
|
||||
@@ -498,7 +498,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
if (nodep->format() == AstAtoN::ATOREAL) {
|
||||
nodep->dtypeSetDouble();
|
||||
} else {
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInteger();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -514,8 +514,8 @@ class WidthVisitor final : public VNVisitor {
|
||||
// Widths: Constant, terminal
|
||||
void visit(AstTime* nodep) override { nodep->dtypeSetUInt64(); }
|
||||
void visit(AstTimeD* nodep) override { nodep->dtypeSetDouble(); }
|
||||
void visit(AstTimePrecision* nodep) override { nodep->dtypeSetSigned32(); }
|
||||
void visit(AstGetInitialRandomSeed* nodep) override { nodep->dtypeSetSigned32(); }
|
||||
void visit(AstTimePrecision* nodep) override { nodep->dtypeSetInteger2State(); }
|
||||
void visit(AstGetInitialRandomSeed* nodep) override { nodep->dtypeSetInt(); }
|
||||
void visit(AstTimeUnit* nodep) override {
|
||||
nodep->replaceWith(
|
||||
new AstConst{nodep->fileline(), AstConst::Signed32{}, nodep->timeunit().powerOfTen()});
|
||||
@@ -950,7 +950,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
if (m_vup->prelim()) { // First stage evaluation
|
||||
iterateCheckSigned32(nodep, "seed", nodep->lhsp(), BOTH);
|
||||
iterateCheckSigned32(nodep, "RHS", nodep->rhsp(), BOTH);
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInteger();
|
||||
}
|
||||
}
|
||||
void visit(AstNodeDistTriop* nodep) override {
|
||||
@@ -958,7 +958,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
iterateCheckSigned32(nodep, "seed", nodep->lhsp(), BOTH);
|
||||
iterateCheckSigned32(nodep, "RHS", nodep->rhsp(), BOTH);
|
||||
iterateCheckSigned32(nodep, "THS", nodep->thsp(), BOTH);
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInteger();
|
||||
}
|
||||
}
|
||||
void visit(AstNodeStream* nodep) override {
|
||||
@@ -1723,7 +1723,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
if (nodep->urandom()) {
|
||||
nodep->dtypeSetUInt32(); // Says the spec
|
||||
} else {
|
||||
nodep->dtypeSetSigned32(); // Says the spec
|
||||
nodep->dtypeSetInt(); // Says the spec
|
||||
}
|
||||
if (nodep->seedp()) iterateCheckSigned32(nodep, "seed", nodep->seedp(), BOTH);
|
||||
}
|
||||
@@ -1783,7 +1783,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
}
|
||||
}
|
||||
void visit(AstUnbounded* nodep) override {
|
||||
nodep->dtypeSetSigned32(); // Used in int context
|
||||
nodep->dtypeSetInt(); // Used in int context
|
||||
if (VN_IS(nodep->backp(), IsUnbounded)) return; // Ok, leave
|
||||
if (VN_IS(nodep->backp(), BracketArrayDType)) return; // Ok, leave
|
||||
if (VN_IS(nodep->backp(), InsideRange)) return; // Ok, leave
|
||||
@@ -2043,7 +2043,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
AstNodeExpr* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeExpr);
|
||||
AstNode* const newp
|
||||
= new AstCMethodHard{nodep->fileline(), fromp, VCMethod::DYN_SIZE};
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInt();
|
||||
newp->didWidth(true);
|
||||
newp->protect(false);
|
||||
nodep->replaceWith(newp);
|
||||
@@ -2062,7 +2062,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
AstNodeExpr* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeExpr);
|
||||
AstNodeExpr* const sizep
|
||||
= new AstCMethodHard{nodep->fileline(), fromp, VCMethod::DYN_SIZE};
|
||||
sizep->dtypeSetSigned32();
|
||||
sizep->dtypeSetInt();
|
||||
sizep->didWidth(true);
|
||||
sizep->protect(false);
|
||||
AstNode* const newp
|
||||
@@ -2906,7 +2906,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
// UINFO below will print variable nodep
|
||||
} else {
|
||||
// Or, if nothing assigned, they're integral
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInteger();
|
||||
VL_DANGLING(bdtypep);
|
||||
}
|
||||
} else if (bdtypep && bdtypep->implicit()) { // Implicits get converted to size 1
|
||||
@@ -3016,7 +3016,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
<< badDtp->warnOther() << "... Location of failing data type "
|
||||
<< badDtp->prettyDTypeNameQ() << '\n'
|
||||
<< badDtp->warnContextSecondary());
|
||||
basicp = nodep->findSigned32DType()->basicp();
|
||||
basicp = nodep->findIntDType()->basicp();
|
||||
nodep->refDTypep(basicp);
|
||||
}
|
||||
nodep->widthFromSub(nodep->subDTypep());
|
||||
@@ -4127,7 +4127,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
VCMethod::ASSOC_SIZE}; // So don't need num()
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInt();
|
||||
} else if (nodep->name() == "first" // function int first(ref index)
|
||||
|| nodep->name() == "last" //
|
||||
|| nodep->name() == "next" //
|
||||
@@ -4224,7 +4224,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
VCMethod::ASSOC_SIZE}; // So don't need num()
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInt();
|
||||
} else if (nodep->name() == "first" // function int first(ref index)
|
||||
|| nodep->name() == "last" //
|
||||
|| nodep->name() == "next" //
|
||||
@@ -4237,7 +4237,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
= new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
VCMethod::arrayMethod(nodep->name()), // first/last/next/prev
|
||||
index_exprp->unlinkFrBack()};
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInteger();
|
||||
if (!nodep->firstAbovep()) newp->dtypeSetVoid();
|
||||
} else if (nodep->name() == "exists") { // function int exists(input index)
|
||||
// IEEE really should have made this a "bit" return
|
||||
@@ -4490,7 +4490,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
VCMethod::DYN_SIZE};
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInt();
|
||||
} else if (nodep->name() == "delete") { // function void delete()
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
@@ -4544,7 +4544,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
VCMethod::DYN_SIZE};
|
||||
newp->dtypeSetSigned32();
|
||||
newp->dtypeSetInt();
|
||||
} else if (nodep->name() == "delete") { // function void delete([input integer index])
|
||||
methodOkArguments(nodep, 0, 1);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
@@ -4870,7 +4870,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
<< "\n"
|
||||
<< (suggest.empty() ? "" : nodep->fileline()->warnMore() + suggest));
|
||||
}
|
||||
nodep->dtypeSetSigned32(); // Guess on error
|
||||
nodep->dtypeSetInteger(); // Guess on error
|
||||
}
|
||||
void methodCallConstraint(AstMethodCall* nodep, AstConstraintRefDType*) {
|
||||
if (nodep->name() == "constraint_mode") {
|
||||
@@ -6474,7 +6474,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
void visit(AstFGetS* nodep) override {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
nodep->dtypeSetInteger2State(); // Spec says integer return
|
||||
iterateCheckFileDesc(nodep, nodep->filep(), BOTH);
|
||||
userIterateAndNext(nodep->strgp(), WidthVP{SELF, BOTH}.p());
|
||||
}
|
||||
@@ -6490,7 +6490,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
void visit(AstFRead* nodep) override {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
nodep->dtypeSetInteger2State(); // Spec says integer return
|
||||
userIterateAndNext(nodep->memp(), WidthVP{SELF, BOTH}.p());
|
||||
iterateCheckFileDesc(nodep, nodep->filep(), BOTH);
|
||||
if (nodep->startp()) {
|
||||
@@ -6504,7 +6504,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
void visit(AstFScanF* nodep) override {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
nodep->dtypeSetInteger2State(); // Spec says integer return
|
||||
iterateCheckFileDesc(nodep, nodep->filep(), BOTH);
|
||||
userIterateAndNext(nodep->exprsp(), WidthVP{SELF, BOTH}.p());
|
||||
}
|
||||
@@ -6512,7 +6512,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
void visit(AstSScanF* nodep) override {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
nodep->dtypeSetInteger2State(); // Spec says integer return
|
||||
userIterateAndNext(nodep->fromp(), WidthVP{SELF, BOTH}.p());
|
||||
userIterateAndNext(nodep->exprsp(), WidthVP{SELF, BOTH}.p());
|
||||
}
|
||||
@@ -6525,7 +6525,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) {
|
||||
userIterateAndNext(nodep->lhsp(), WidthVP{SELF, BOTH}.p());
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
nodep->dtypeSetInteger2State(); // Spec says integer return
|
||||
}
|
||||
}
|
||||
void visit(AstSystemT* nodep) override {
|
||||
@@ -7632,7 +7632,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
assertAtExpr(nodep);
|
||||
if (m_vup->prelim()) { // First stage evaluation
|
||||
iterateCheckReal(nodep, "LHS", nodep->lhsp(), BOTH);
|
||||
nodep->dtypeSetSigned32();
|
||||
nodep->dtypeSetInteger();
|
||||
}
|
||||
}
|
||||
void visit_Ou64_Lr(AstNodeUniop* nodep) {
|
||||
@@ -8629,7 +8629,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
}
|
||||
void iterateCheckSigned32(AstNode* parentp, const char* side, AstNode* underp, Stage stage) {
|
||||
// Coerce child to signed32 if not already. Child is self-determined
|
||||
iterateCheckTypedSelfPrelim(parentp, side, underp, parentp->findSigned32DType(), stage);
|
||||
iterateCheckTypedSelfPrelim(parentp, side, underp, parentp->findIntDType(), stage);
|
||||
}
|
||||
void iterateCheckUInt32(AstNode* parentp, const char* side, AstNode* underp, Stage stage) {
|
||||
// Coerce child to unsigned32 if not already. Child is self-determined
|
||||
@@ -9398,7 +9398,7 @@ class WidthVisitor final : public VNVisitor {
|
||||
std::forward_as_tuple(nullptr));
|
||||
if (pair.second) {
|
||||
AstNodeArrayDType* const vardtypep
|
||||
= new AstUnpackArrayDType{nodep->fileline(), nodep->findSigned32DType(),
|
||||
= new AstUnpackArrayDType{nodep->fileline(), nodep->findIntDType(),
|
||||
new AstRange(nodep->fileline(), msbdim, 0)};
|
||||
AstInitArray* const initp = new AstInitArray{nodep->fileline(), vardtypep, nullptr};
|
||||
v3Global.rootp()->typeTablep()->addTypesp(vardtypep);
|
||||
|
||||
Reference in New Issue
Block a user