Internals: Create FuncRef/TaskRef directly from Func/Task pointer. No functional change intended
This commit is contained in:
parent
6aa7123a8c
commit
4b4ca90c71
|
|
@ -77,6 +77,12 @@ int AstNodeArrayDType::lo() const VL_MT_STABLE { return rangep()->loConst(); }
|
||||||
int AstNodeArrayDType::elementsConst() const VL_MT_STABLE { return rangep()->elementsConst(); }
|
int AstNodeArrayDType::elementsConst() const VL_MT_STABLE { return rangep()->elementsConst(); }
|
||||||
VNumRange AstNodeArrayDType::declRange() const VL_MT_STABLE { return VNumRange{left(), right()}; }
|
VNumRange AstNodeArrayDType::declRange() const VL_MT_STABLE { return VNumRange{left(), right()}; }
|
||||||
|
|
||||||
|
AstFuncRef::AstFuncRef(FileLine* fl, AstFunc* taskp, AstNodeExpr* pinsp)
|
||||||
|
: ASTGEN_SUPER_FuncRef(fl, taskp->name(), pinsp) {
|
||||||
|
this->taskp(taskp);
|
||||||
|
dtypeFrom(taskp);
|
||||||
|
}
|
||||||
|
|
||||||
AstRange::AstRange(FileLine* fl, int left, int right)
|
AstRange::AstRange(FileLine* fl, int left, int right)
|
||||||
: ASTGEN_SUPER_Range(fl) {
|
: ASTGEN_SUPER_Range(fl) {
|
||||||
leftp(new AstConst{fl, static_cast<uint32_t>(left)});
|
leftp(new AstConst{fl, static_cast<uint32_t>(left)});
|
||||||
|
|
@ -96,11 +102,6 @@ int AstRange::rightConst() const VL_MT_STABLE {
|
||||||
return (constp ? constp->toSInt() : 0);
|
return (constp ? constp->toSInt() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AstQueueDType::boundConst() const VL_MT_STABLE {
|
|
||||||
AstConst* const constp = VN_CAST(boundp(), Const);
|
|
||||||
return (constp ? constp->toSInt() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
AstPin::AstPin(FileLine* fl, int pinNum, AstVarRef* varname, AstNode* exprp)
|
AstPin::AstPin(FileLine* fl, int pinNum, AstVarRef* varname, AstNode* exprp)
|
||||||
: ASTGEN_SUPER_Pin(fl)
|
: ASTGEN_SUPER_Pin(fl)
|
||||||
, m_pinNum{pinNum}
|
, m_pinNum{pinNum}
|
||||||
|
|
@ -127,6 +128,17 @@ AstPackArrayDType::AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange*
|
||||||
widthForce(width, width);
|
widthForce(width, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AstQueueDType::boundConst() const VL_MT_STABLE {
|
||||||
|
AstConst* const constp = VN_CAST(boundp(), Const);
|
||||||
|
return (constp ? constp->toSInt() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
AstTaskRef::AstTaskRef(FileLine* fl, AstTask* taskp, AstNodeExpr* pinsp)
|
||||||
|
: ASTGEN_SUPER_TaskRef(fl, taskp->name(), pinsp) {
|
||||||
|
this->taskp(taskp);
|
||||||
|
dtypeSetVoid();
|
||||||
|
}
|
||||||
|
|
||||||
int AstBasicDType::hi() const { return (rangep() ? rangep()->hiConst() : m.m_nrange.hi()); }
|
int AstBasicDType::hi() const { return (rangep() ? rangep()->hiConst() : m.m_nrange.hi()); }
|
||||||
int AstBasicDType::lo() const { return (rangep() ? rangep()->loConst() : m.m_nrange.lo()); }
|
int AstBasicDType::lo() const { return (rangep() ? rangep()->loConst() : m.m_nrange.lo()); }
|
||||||
int AstBasicDType::elements() const {
|
int AstBasicDType::elements() const {
|
||||||
|
|
|
||||||
|
|
@ -4375,6 +4375,7 @@ class AstFuncRef final : public AstNodeFTaskRef {
|
||||||
// A reference to a function
|
// A reference to a function
|
||||||
bool m_superReference = false; // Called with super reference
|
bool m_superReference = false; // Called with super reference
|
||||||
public:
|
public:
|
||||||
|
inline AstFuncRef(FileLine* fl, AstFunc* taskp, AstNodeExpr* pinsp);
|
||||||
AstFuncRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp)
|
AstFuncRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp)
|
||||||
: ASTGEN_SUPER_FuncRef(fl, (AstNode*)namep, pinsp) {}
|
: ASTGEN_SUPER_FuncRef(fl, (AstNode*)namep, pinsp) {}
|
||||||
AstFuncRef(FileLine* fl, const string& name, AstNodeExpr* pinsp)
|
AstFuncRef(FileLine* fl, const string& name, AstNodeExpr* pinsp)
|
||||||
|
|
@ -4415,6 +4416,7 @@ class AstTaskRef final : public AstNodeFTaskRef {
|
||||||
// A reference to a task
|
// A reference to a task
|
||||||
bool m_superReference = false; // Called with super reference
|
bool m_superReference = false; // Called with super reference
|
||||||
public:
|
public:
|
||||||
|
inline AstTaskRef(FileLine* fl, AstTask* taskp, AstNodeExpr* pinsp);
|
||||||
AstTaskRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp)
|
AstTaskRef(FileLine* fl, AstParseRef* namep, AstNodeExpr* pinsp)
|
||||||
: ASTGEN_SUPER_TaskRef(fl, (AstNode*)namep, pinsp) {
|
: ASTGEN_SUPER_TaskRef(fl, (AstNode*)namep, pinsp) {
|
||||||
dtypeSetVoid();
|
dtypeSetVoid();
|
||||||
|
|
|
||||||
|
|
@ -603,9 +603,7 @@ class ForkVisitor final : public VNVisitor {
|
||||||
m_modp->addStmtsp(taskp);
|
m_modp->addStmtsp(taskp);
|
||||||
UINFO(9, "new " << taskp << endl);
|
UINFO(9, "new " << taskp << endl);
|
||||||
|
|
||||||
AstTaskRef* const taskrefp
|
AstTaskRef* const taskrefp = new AstTaskRef{nodep->fileline(), taskp, m_capturedVarRefsp};
|
||||||
= new AstTaskRef{nodep->fileline(), taskp->name(), m_capturedVarRefsp};
|
|
||||||
taskrefp->taskp(taskp);
|
|
||||||
AstStmtExpr* const taskcallp = taskrefp->makeStmt();
|
AstStmtExpr* const taskcallp = taskrefp->makeStmt();
|
||||||
// Replaced nodes will be revisited, so we don't need to "lift" the arguments
|
// Replaced nodes will be revisited, so we don't need to "lift" the arguments
|
||||||
// as captures in case of nested forks.
|
// as captures in case of nested forks.
|
||||||
|
|
|
||||||
|
|
@ -1105,13 +1105,11 @@ class CaptureVisitor final : public VNVisitor {
|
||||||
AstNodeExpr* const pinsp
|
AstNodeExpr* const pinsp
|
||||||
= nodep->pinsp() ? nodep->pinsp()->unlinkFrBackWithNext() : nullptr;
|
= nodep->pinsp() ? nodep->pinsp()->unlinkFrBackWithNext() : nullptr;
|
||||||
AstNodeFTaskRef* taskRefp = nullptr;
|
AstNodeFTaskRef* taskRefp = nullptr;
|
||||||
if (VN_IS(nodep->taskp(), Task))
|
if (AstTask* const taskp = VN_CAST(nodep->taskp(), Task))
|
||||||
taskRefp = new AstTaskRef{nodep->fileline(), nodep->name(), pinsp};
|
taskRefp = new AstTaskRef{nodep->fileline(), taskp, pinsp};
|
||||||
else if (VN_IS(nodep->taskp(), Func))
|
else if (AstFunc* const taskp = VN_CAST(nodep->taskp(), Func))
|
||||||
taskRefp = new AstFuncRef{nodep->fileline(), nodep->name(), pinsp};
|
taskRefp = new AstFuncRef{nodep->fileline(), taskp, pinsp};
|
||||||
UASSERT_OBJ(taskRefp, nodep, "Node needs to point to regular method");
|
UASSERT_OBJ(taskRefp, nodep, "Node needs to point to regular method");
|
||||||
taskRefp->taskp(nodep->taskp());
|
|
||||||
taskRefp->dtypep(nodep->dtypep());
|
|
||||||
fixupClassOrPackage(nodep->taskp(), taskRefp);
|
fixupClassOrPackage(nodep->taskp(), taskRefp);
|
||||||
taskRefp->user1(nodep->user1());
|
taskRefp->user1(nodep->user1());
|
||||||
nodep->replaceWith(taskRefp);
|
nodep->replaceWith(taskRefp);
|
||||||
|
|
@ -1596,9 +1594,7 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
void addPrePostCall(AstClass* const classp, AstFunc* const funcp, const string& name) {
|
void addPrePostCall(AstClass* const classp, AstFunc* const funcp, const string& name) {
|
||||||
if (AstTask* userFuncp = VN_CAST(m_memberMap.findMember(classp, name), Task)) {
|
if (AstTask* userFuncp = VN_CAST(m_memberMap.findMember(classp, name), Task)) {
|
||||||
AstTaskRef* const callp
|
AstTaskRef* const callp = new AstTaskRef{userFuncp->fileline(), userFuncp, nullptr};
|
||||||
= new AstTaskRef{userFuncp->fileline(), userFuncp->name(), nullptr};
|
|
||||||
callp->taskp(userFuncp);
|
|
||||||
funcp->addStmtsp(callp->makeStmt());
|
funcp->addStmtsp(callp->makeStmt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1940,8 +1936,7 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
constrp->user2p(taskp);
|
constrp->user2p(taskp);
|
||||||
}
|
}
|
||||||
AstTaskRef* const setupTaskRefp
|
AstTaskRef* const setupTaskRefp
|
||||||
= new AstTaskRef{constrp->fileline(), taskp->name(), nullptr};
|
= new AstTaskRef{constrp->fileline(), taskp, nullptr};
|
||||||
setupTaskRefp->taskp(taskp);
|
|
||||||
setupTaskRefp->classOrPackagep(classp);
|
setupTaskRefp->classOrPackagep(classp);
|
||||||
|
|
||||||
AstTask* const setupAllTaskp = getCreateConstraintSetupFunc(nodep);
|
AstTask* const setupAllTaskp = getCreateConstraintSetupFunc(nodep);
|
||||||
|
|
@ -1951,8 +1946,7 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
if (AstTask* const resizeTaskp = VN_CAST(constrp->user3p(), Task)) {
|
if (AstTask* const resizeTaskp = VN_CAST(constrp->user3p(), Task)) {
|
||||||
AstTask* const resizeAllTaskp = getCreateAggrResizeTask(nodep);
|
AstTask* const resizeAllTaskp = getCreateAggrResizeTask(nodep);
|
||||||
AstTaskRef* const resizeTaskRefp
|
AstTaskRef* const resizeTaskRefp
|
||||||
= new AstTaskRef{constrp->fileline(), resizeTaskp->name(), nullptr};
|
= new AstTaskRef{constrp->fileline(), resizeTaskp, nullptr};
|
||||||
resizeTaskRefp->taskp(resizeTaskp);
|
|
||||||
resizeTaskRefp->classOrPackagep(classp);
|
resizeTaskRefp->classOrPackagep(classp);
|
||||||
resizeAllTaskp->addStmtsp(resizeTaskRefp->makeStmt());
|
resizeAllTaskp->addStmtsp(resizeTaskRefp->makeStmt());
|
||||||
}
|
}
|
||||||
|
|
@ -1965,8 +1959,7 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
});
|
});
|
||||||
randomizep->addStmtsp(implementConstraintsClear(fl, genp));
|
randomizep->addStmtsp(implementConstraintsClear(fl, genp));
|
||||||
AstTask* setupAllTaskp = getCreateConstraintSetupFunc(nodep);
|
AstTask* setupAllTaskp = getCreateConstraintSetupFunc(nodep);
|
||||||
AstTaskRef* const setupTaskRefp = new AstTaskRef{fl, setupAllTaskp->name(), nullptr};
|
AstTaskRef* const setupTaskRefp = new AstTaskRef{fl, setupAllTaskp, nullptr};
|
||||||
setupTaskRefp->taskp(setupAllTaskp);
|
|
||||||
randomizep->addStmtsp(setupTaskRefp->makeStmt());
|
randomizep->addStmtsp(setupTaskRefp->makeStmt());
|
||||||
|
|
||||||
AstNodeModule* const genModp = VN_AS(genp->user2p(), NodeModule);
|
AstNodeModule* const genModp = VN_AS(genp->user2p(), NodeModule);
|
||||||
|
|
@ -1994,17 +1987,14 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
|
|
||||||
if (AstTask* const resizeAllTaskp
|
if (AstTask* const resizeAllTaskp
|
||||||
= VN_AS(m_memberMap.findMember(nodep, "__Vresize_constrained_arrays"), Task)) {
|
= VN_AS(m_memberMap.findMember(nodep, "__Vresize_constrained_arrays"), Task)) {
|
||||||
AstTaskRef* const resizeTaskRefp = new AstTaskRef{fl, resizeAllTaskp->name(), nullptr};
|
AstTaskRef* const resizeTaskRefp = new AstTaskRef{fl, resizeAllTaskp, nullptr};
|
||||||
resizeTaskRefp->taskp(resizeAllTaskp);
|
|
||||||
randomizep->addStmtsp(resizeTaskRefp->makeStmt());
|
randomizep->addStmtsp(resizeTaskRefp->makeStmt());
|
||||||
}
|
}
|
||||||
|
|
||||||
AstFunc* const basicRandomizep
|
AstFunc* const basicRandomizep
|
||||||
= V3Randomize::newRandomizeFunc(m_memberMap, nodep, "__Vbasic_randomize");
|
= V3Randomize::newRandomizeFunc(m_memberMap, nodep, "__Vbasic_randomize");
|
||||||
addBasicRandomizeBody(basicRandomizep, nodep, randModeVarp);
|
addBasicRandomizeBody(basicRandomizep, nodep, randModeVarp);
|
||||||
AstFuncRef* const basicRandomizeCallp = new AstFuncRef{fl, "__Vbasic_randomize", nullptr};
|
AstFuncRef* const basicRandomizeCallp = new AstFuncRef{fl, basicRandomizep, nullptr};
|
||||||
basicRandomizeCallp->taskp(basicRandomizep);
|
|
||||||
basicRandomizeCallp->dtypep(basicRandomizep->dtypep());
|
|
||||||
AstVarRef* const fvarRefReadp = fvarRefp->cloneTree(false);
|
AstVarRef* const fvarRefReadp = fvarRefp->cloneTree(false);
|
||||||
fvarRefReadp->access(VAccess::READ);
|
fvarRefReadp->access(VAccess::READ);
|
||||||
|
|
||||||
|
|
@ -2176,16 +2166,12 @@ class RandomizeVisitor final : public VNVisitor {
|
||||||
AstFunc* const basicRandomizeFuncp
|
AstFunc* const basicRandomizeFuncp
|
||||||
= V3Randomize::newRandomizeFunc(m_memberMap, classp, "__Vbasic_randomize");
|
= V3Randomize::newRandomizeFunc(m_memberMap, classp, "__Vbasic_randomize");
|
||||||
AstFuncRef* const basicRandomizeFuncCallp
|
AstFuncRef* const basicRandomizeFuncCallp
|
||||||
= new AstFuncRef{nodep->fileline(), "__Vbasic_randomize", nullptr};
|
= new AstFuncRef{nodep->fileline(), basicRandomizeFuncp, nullptr};
|
||||||
basicRandomizeFuncCallp->taskp(basicRandomizeFuncp);
|
|
||||||
basicRandomizeFuncCallp->dtypep(basicRandomizeFuncp->dtypep());
|
|
||||||
|
|
||||||
// Copy (derive) class constraints if present
|
// Copy (derive) class constraints if present
|
||||||
if (classGenp) {
|
if (classGenp) {
|
||||||
AstTask* const constrSetupFuncp = getCreateConstraintSetupFunc(classp);
|
AstTask* const constrSetupFuncp = getCreateConstraintSetupFunc(classp);
|
||||||
AstTaskRef* const callp
|
AstTaskRef* const callp = new AstTaskRef{nodep->fileline(), constrSetupFuncp, nullptr};
|
||||||
= new AstTaskRef{nodep->fileline(), constrSetupFuncp->name(), nullptr};
|
|
||||||
callp->taskp(constrSetupFuncp);
|
|
||||||
randomizeFuncp->addStmtsp(callp->makeStmt());
|
randomizeFuncp->addStmtsp(callp->makeStmt());
|
||||||
randomizeFuncp->addStmtsp(new AstAssign{
|
randomizeFuncp->addStmtsp(new AstAssign{
|
||||||
nodep->fileline(), new AstVarRef{nodep->fileline(), localGenp, VAccess::WRITE},
|
nodep->fileline(), new AstVarRef{nodep->fileline(), localGenp, VAccess::WRITE},
|
||||||
|
|
|
||||||
|
|
@ -1849,16 +1849,13 @@ AstNodeFTask* V3Task::taskConnectWrapNew(AstNodeFTask* taskp, const string& newn
|
||||||
newFVarp->name(newTaskp->name());
|
newFVarp->name(newTaskp->name());
|
||||||
newTaskp->fvarp(newFVarp);
|
newTaskp->fvarp(newFVarp);
|
||||||
newTaskp->dtypeFrom(newFVarp);
|
newTaskp->dtypeFrom(newFVarp);
|
||||||
newCallp = new AstFuncRef{taskp->fileline(), taskp->name(), nullptr};
|
newCallp = new AstFuncRef{taskp->fileline(), VN_AS(taskp, Func), nullptr};
|
||||||
newCallp->taskp(taskp);
|
|
||||||
newCallp->dtypeFrom(newFVarp);
|
|
||||||
newCallInsertp
|
newCallInsertp
|
||||||
= new AstAssign{taskp->fileline(),
|
= new AstAssign{taskp->fileline(),
|
||||||
new AstVarRef{fvarp->fileline(), newFVarp, VAccess::WRITE}, newCallp};
|
new AstVarRef{fvarp->fileline(), newFVarp, VAccess::WRITE}, newCallp};
|
||||||
newCallInsertp->dtypeFrom(newFVarp);
|
newCallInsertp->dtypeFrom(newFVarp);
|
||||||
} else if (VN_IS(taskp, Task)) {
|
} else if (VN_IS(taskp, Task)) {
|
||||||
newCallp = new AstTaskRef{taskp->fileline(), taskp->name(), nullptr};
|
newCallp = new AstTaskRef{taskp->fileline(), VN_AS(taskp, Task), nullptr};
|
||||||
newCallp->taskp(taskp);
|
|
||||||
newCallInsertp = new AstStmtExpr{taskp->fileline(), newCallp};
|
newCallInsertp = new AstStmtExpr{taskp->fileline(), newCallp};
|
||||||
} else {
|
} else {
|
||||||
taskp->v3fatalSrc("Unsupported: Non-constant default value in missing argument in a "
|
taskp->v3fatalSrc("Unsupported: Non-constant default value in missing argument in a "
|
||||||
|
|
|
||||||
|
|
@ -3788,11 +3788,10 @@ class WidthVisitor final : public VNVisitor {
|
||||||
if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext();
|
if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext();
|
||||||
AstNodeFTaskRef* newp = nullptr;
|
AstNodeFTaskRef* newp = nullptr;
|
||||||
if (VN_IS(ftaskp, Task)) {
|
if (VN_IS(ftaskp, Task)) {
|
||||||
newp = new AstTaskRef{nodep->fileline(), ftaskp->name(), argsp};
|
newp = new AstTaskRef{nodep->fileline(), VN_AS(ftaskp, Task), argsp};
|
||||||
} else {
|
} else {
|
||||||
newp = new AstFuncRef{nodep->fileline(), ftaskp->name(), argsp};
|
newp = new AstFuncRef{nodep->fileline(), VN_AS(ftaskp, Func), argsp};
|
||||||
}
|
}
|
||||||
newp->taskp(ftaskp);
|
|
||||||
newp->classOrPackagep(ifacep);
|
newp->classOrPackagep(ifacep);
|
||||||
nodep->replaceWith(newp);
|
nodep->replaceWith(newp);
|
||||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||||
|
|
@ -3927,11 +3926,10 @@ class WidthVisitor final : public VNVisitor {
|
||||||
if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext();
|
if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext();
|
||||||
AstNodeFTaskRef* newp = nullptr;
|
AstNodeFTaskRef* newp = nullptr;
|
||||||
if (VN_IS(ftaskp, Task)) {
|
if (VN_IS(ftaskp, Task)) {
|
||||||
newp = new AstTaskRef{nodep->fileline(), ftaskp->name(), argsp};
|
newp = new AstTaskRef{nodep->fileline(), VN_AS(ftaskp, Task), argsp};
|
||||||
} else {
|
} else {
|
||||||
newp = new AstFuncRef{nodep->fileline(), ftaskp->name(), argsp};
|
newp = new AstFuncRef{nodep->fileline(), VN_AS(ftaskp, Func), argsp};
|
||||||
}
|
}
|
||||||
newp->taskp(ftaskp);
|
|
||||||
newp->classOrPackagep(classp);
|
newp->classOrPackagep(classp);
|
||||||
nodep->replaceWith(newp);
|
nodep->replaceWith(newp);
|
||||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue