Internals: Cleanup of InitArray stuff. No functional change intended.

This commit is contained in:
Wilson Snyder 2021-12-11 11:22:04 -05:00
parent 748fa4cb80
commit 9a722ccf62
6 changed files with 18 additions and 14 deletions

View File

@ -1344,7 +1344,7 @@ void AstIfaceRefDType::dumpSmall(std::ostream& str) const {
void AstInitArray::dump(std::ostream& str) const {
this->AstNode::dump(str);
int n = 0;
const AstInitArray::KeyItemMap& mapr = map();
const auto& mapr = map();
for (const auto& itr : mapr) {
if (n++ > 5) {
str << " ...";

View File

@ -34,6 +34,15 @@ class EmitCConstInit VL_NOT_FINAL : public EmitCBaseVisitor {
// METHODS
VL_DEBUG_FUNC; // Declare debug()
uint32_t tabModulus(AstNodeDType* dtypep) {
const uint32_t elemBytes = dtypep->widthTotalBytes();
return dtypep->isString() ? 1 // String
: elemBytes <= 2 ? 8 // CData, SData
: elemBytes <= 4 ? 4 // IData
: elemBytes <= 8 ? 2 // QData
: 1;
}
protected:
// VISITORS
virtual void visit(AstInitArray* nodep) override {
@ -41,12 +50,7 @@ protected:
= VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType);
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
const uint32_t size = dtypep->elementsConst();
const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes();
const uint32_t tabMod = dtypep->subDTypep()->isString() ? 1 // String
: elemBytes <= 2 ? 8 // CData, SData
: elemBytes <= 4 ? 4 // IData
: elemBytes <= 8 ? 2 // QData
: 1;
const uint32_t tabMod = tabModulus(dtypep->subDTypep());
VL_RESTORER(m_inUnpacked);
VL_RESTORER(m_unpackedWord);
m_inUnpacked = true;

View File

@ -629,7 +629,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) {
emitSetVarConstant(varNameProtected + "[__Vi]", VN_AS(initarp->defaultp(), Const));
puts("}\n");
}
const AstInitArray::KeyItemMap& mapr = initarp->map();
const auto& mapr = initarp->map();
for (const auto& itr : mapr) {
AstNode* const valuep = itr.second->valuep();
emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]",

View File

@ -498,7 +498,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
virtual void visit(AstInitArray* nodep) override {
putfs(nodep, "'{");
int comma = 0;
const AstInitArray::KeyItemMap& mapr = nodep->map();
const auto& mapr = nodep->map();
for (const auto& itr : mapr) {
if (comma++) putbs(", ");
puts(cvtToStr(itr.first));

View File

@ -163,12 +163,12 @@ class EmitXmlFileVisitor final : public AstNVisitor {
}
virtual void visit(AstInitArray* nodep) override {
puts("<initarray>\n");
const AstInitArray::KeyItemMap& map = nodep->map();
for (AstInitArray::KeyItemMap::const_iterator it = map.begin(); it != map.end(); ++it) {
const auto& mapr = nodep->map();
for (const auto& itr : mapr) {
puts("<inititem index=\"");
puts(cvtToStr(it->first));
puts(cvtToStr(itr.first));
puts("\">\n");
iterateChildren(it->second);
iterateChildren(itr.second);
puts("</inititem>\n");
}
puts("</initarray>\n");

View File

@ -44,7 +44,7 @@ module t (/*AUTOARG*/
else if (cyc==20) begin
e <= 'h11; // Unknown
end
else if (cyc==20) begin
else if (cyc==21) begin
`checks(e.name, ""); // Unknown
end
else if (cyc==99) begin