Apply 'make format'
This commit is contained in:
parent
9793737878
commit
809fba224b
|
|
@ -227,7 +227,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
AstNodeExpr* buildMemberSelChain(AstVarRef* rootVarRefp, const std::vector<AstVar*>& path) {
|
AstNodeExpr* buildMemberSelChain(AstVarRef* rootVarRefp, const std::vector<AstVar*>& path) {
|
||||||
AstNodeExpr* current = rootVarRefp->cloneTree(false);
|
AstNodeExpr* current = rootVarRefp->cloneTree(false);
|
||||||
for (AstVar* memberVarp : path) {
|
for (AstVar* memberVarp : path) {
|
||||||
AstMemberSel* memberSel = new AstMemberSel(rootVarRefp->fileline(), current, memberVarp);
|
AstMemberSel* memberSel
|
||||||
|
= new AstMemberSel(rootVarRefp->fileline(), current, memberVarp);
|
||||||
memberSel->user2p(m_classp); // Set containing class for all MemberSel nodes
|
memberSel->user2p(m_classp); // Set containing class for all MemberSel nodes
|
||||||
current = memberSel;
|
current = memberSel;
|
||||||
}
|
}
|
||||||
|
|
@ -242,11 +243,12 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
if (!classp) return;
|
if (!classp) return;
|
||||||
|
|
||||||
// Recursively process nested rand members first
|
// Recursively process nested rand members first
|
||||||
for (AstNode* memberNodep = classp->membersp(); memberNodep; memberNodep = memberNodep->nextp()) {
|
for (AstNode* memberNodep = classp->membersp(); memberNodep;
|
||||||
|
memberNodep = memberNodep->nextp()) {
|
||||||
if (AstVar* memberVarp = VN_CAST(memberNodep, Var)) {
|
if (AstVar* memberVarp = VN_CAST(memberNodep, Var)) {
|
||||||
if (memberVarp->rand().isRandomizable()) {
|
if (memberVarp->rand().isRandomizable()) {
|
||||||
const AstClassRefDType* memberClassRefp =
|
const AstClassRefDType* memberClassRefp
|
||||||
VN_CAST(memberVarp->dtypep()->skipRefp(), ClassRefDType);
|
= VN_CAST(memberVarp->dtypep()->skipRefp(), ClassRefDType);
|
||||||
if (memberClassRefp && memberClassRefp->classp()) {
|
if (memberClassRefp && memberClassRefp->classp()) {
|
||||||
AstClass* nestedClassp = memberClassRefp->classp();
|
AstClass* nestedClassp = memberClassRefp->classp();
|
||||||
|
|
||||||
|
|
@ -255,7 +257,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
newPath.push_back(memberVarp);
|
newPath.push_back(memberVarp);
|
||||||
|
|
||||||
// Clone constraints from the nested class
|
// Clone constraints from the nested class
|
||||||
nestedClassp->foreachMember([&](AstClass* const containingClassp, AstConstraint* const constrp) {
|
nestedClassp->foreachMember([&](AstClass* const containingClassp,
|
||||||
|
AstConstraint* const constrp) {
|
||||||
if (!constrp) return;
|
if (!constrp) return;
|
||||||
|
|
||||||
AstConstraint* cloneConstrp = constrp->cloneTree(false);
|
AstConstraint* cloneConstrp = constrp->cloneTree(false);
|
||||||
|
|
@ -268,7 +271,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update constraint name
|
// Update constraint name
|
||||||
cloneConstrp->name(pathPrefix + GLOBAL_CONSTRAINT_SEPARATOR + cloneConstrp->name());
|
cloneConstrp->name(pathPrefix + GLOBAL_CONSTRAINT_SEPARATOR
|
||||||
|
+ cloneConstrp->name());
|
||||||
|
|
||||||
// Replace VarRefs in the constraint with MemberSel chains
|
// Replace VarRefs in the constraint with MemberSel chains
|
||||||
cloneConstrp->foreach([&](AstVarRef* varRefp) {
|
cloneConstrp->foreach([&](AstVarRef* varRefp) {
|
||||||
|
|
@ -276,7 +280,8 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||||
|
|
||||||
// Build chain: rootVarRef.pathMember1.pathMember2...finalVar
|
// Build chain: rootVarRef.pathMember1.pathMember2...finalVar
|
||||||
AstNodeExpr* chain = buildMemberSelChain(rootVarRefp, newPath);
|
AstNodeExpr* chain = buildMemberSelChain(rootVarRefp, newPath);
|
||||||
AstMemberSel* finalSel = new AstMemberSel(varRefp->fileline(), chain, varRefp->varp());
|
AstMemberSel* finalSel = new AstMemberSel(varRefp->fileline(),
|
||||||
|
chain, varRefp->varp());
|
||||||
finalSel->user2p(m_classp); // Set containing class
|
finalSel->user2p(m_classp); // Set containing class
|
||||||
varRefp->replaceWith(finalSel);
|
varRefp->replaceWith(finalSel);
|
||||||
VL_DO_DANGLING(varRefp->deleteTree(), varRefp);
|
VL_DO_DANGLING(varRefp->deleteTree(), varRefp);
|
||||||
|
|
@ -1191,10 +1196,10 @@ class ConstraintExprVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the root variable participates in global constraints
|
// Check if the root variable participates in global constraints
|
||||||
AstVar* const constrainedVar = VN_IS(rootNode, VarRef)
|
AstVar* const constrainedVar
|
||||||
|
= VN_IS(rootNode, VarRef)
|
||||||
? VN_AS(rootNode, VarRef)->varp()
|
? VN_AS(rootNode, VarRef)->varp()
|
||||||
: (VN_IS(rootNode, MemberSel)
|
: (VN_IS(rootNode, MemberSel) ? VN_AS(rootNode, MemberSel)->varp()
|
||||||
? VN_AS(rootNode, MemberSel)->varp()
|
|
||||||
: nullptr);
|
: nullptr);
|
||||||
if (constrainedVar && constrainedVar->isGlobalConstrained()) {
|
if (constrainedVar && constrainedVar->isGlobalConstrained()) {
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue