Tests: ignore all hashes in files_identical

Also add 'h' prefix to all printed hashes, to reduce ambiguity. No
functional change.
This commit is contained in:
Geza Lore 2021-08-11 16:22:52 +01:00
parent bc3e24c8cd
commit 5adc856950
6 changed files with 24 additions and 16 deletions

View File

@ -1065,8 +1065,8 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) {
UASSERT_OBJ(VN_IS(valuep, Const), valuep, "Const pool table entry must be Const");
}
// Try to find an existing table with the same content
const uint32_t hash = V3Hasher::uncachedHash(initp).value();
const auto& er = m_tables.equal_range(hash);
const V3Hash hash = V3Hasher::uncachedHash(initp);
const auto& er = m_tables.equal_range(hash.value());
for (auto it = er.first; it != er.second; ++it) {
AstVarScope* const varScopep = it->second;
const AstInitArray* const init2p = VN_CAST(varScopep->varp()->valuep(), InitArray);
@ -1076,11 +1076,11 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) {
}
// No such table yet, create it.
string name = "TABLE_";
name += cvtToHex(hash);
name += hash.toString();
name += "_";
name += cvtToStr(std::distance(er.first, er.second));
AstVarScope* const varScopep = createNewEntry(name, initp);
m_tables.emplace(hash, varScopep);
m_tables.emplace(hash.value(), varScopep);
return varScopep;
}
@ -1094,8 +1094,8 @@ static bool sameInit(const AstConst* ap, const AstConst* bp) {
AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) {
// Try to find an existing constant with the same value
const uint32_t hash = initp->num().toHash().value();
const auto& er = m_consts.equal_range(hash);
const V3Hash hash = initp->num().toHash();
const auto& er = m_consts.equal_range(hash.value());
for (auto it = er.first; it != er.second; ++it) {
AstVarScope* const varScopep = it->second;
const AstConst* const init2p = VN_CAST(varScopep->varp()->valuep(), Const);
@ -1106,11 +1106,11 @@ AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) {
}
// No such constant yet, create it.
string name = "CONST_";
name += cvtToHex(hash);
name += hash.toString();
name += "_";
name += cvtToStr(std::distance(er.first, er.second));
AstVarScope* const varScopep = createNewEntry(name, initp);
m_consts.emplace(hash, varScopep);
m_consts.emplace(hash.value(), varScopep);
return varScopep;
}

View File

@ -497,7 +497,7 @@ class EmitCImp final : EmitCFunc {
// disambiguate them
V3Hash hash;
for (const string& name : *m_requiredHeadersp) { hash += name; }
m_subFileName = "DepSet_" + cvtToHex(hash.value());
m_subFileName = "DepSet_" + hash.toString();
// Open output file
openNextOutputFile(*m_requiredHeadersp, m_subFileName);
// Emit functions in this dependency set

View File

@ -19,10 +19,17 @@
#include <functional>
#include <iomanip>
#include <iostream>
#include <sstream>
V3Hash::V3Hash(const std::string& val)
: m_value{static_cast<uint32_t>(std::hash<std::string>{}(val))} {}
std::ostream& operator<<(std::ostream& os, const V3Hash& rhs) {
return os << std::hex << std::setw(8) << std::setfill('0') << rhs.value();
return os << 'h' << std::hex << std::setw(8) << std::setfill('0') << rhs.value();
}
std::string V3Hash::toString() const {
std::ostringstream os;
os << *this;
return os.str();
}

View File

@ -46,6 +46,7 @@ public:
// METHODS
uint32_t value() const { return m_value; }
std::string toString() const;
// OPERATORS
// Comparisons

View File

@ -2192,7 +2192,7 @@ sub files_identical {
$l1[$l] =~ s/Version: Verilator[^\n]+/Version: Verilator ###/mig;
$l1[$l] =~ s/CPU Time: +[0-9.]+ seconds[^\n]+/CPU Time: ###/mig;
$l1[$l] =~ s/\?v=[0-9.]+/?v=latest/mig; # warning URL
$l1[$l] =~ s/DepSet_[a-f0-9]+_/DepSet_#_/mg;
$l1[$l] =~ s/_h[0-9a-f]{8}_/_h########_/mg;
if ($l1[$l] =~ s/Exiting due to.*/Exiting due to/mig) {
splice @l1, $l+1; # Trunc rest
last;

View File

@ -1501,12 +1501,12 @@
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root.h"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$unit.h"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_#__0__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_#__0__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_#__0.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_#__0.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_h########__0__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_h########__0__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_h########__0.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$root__DepSet_h########__0.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$unit__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$unit__DepSet_#__0__Slow.cpp"/>
<cfile fl="a0" loc="a,0,0,0,0" name="obj_vlt/t_xml_debugcheck/Vt_xml_debugcheck_$unit__DepSet_h########__0__Slow.cpp"/>
<typetable fl="a0" loc="a,0,0,0,0">
<basicdtype fl="d32" loc="d,32,24,32,27" id="1" name="logic"/>
<basicdtype fl="d52" loc="d,52,9,52,10" id="6" name="logic" left="31" right="0"/>