@@ -208,7 +208,7 @@ class HashEvaluateExpr {
208208 unsigned args = 13u ;
209209 for (const auto &v : x.arguments ())
210210 args -= getHashValue (v);
211- return getHashValue (x.proc ()) * 101u ;
211+ return getHashValue (x.proc ()) * 101u - args ;
212212 }
213213 template <typename A>
214214 static unsigned
@@ -217,16 +217,15 @@ class HashEvaluateExpr {
217217 return 127u ;
218218 }
219219 static unsigned getHashValue (const Fortran::evaluate::ImpliedDoIndex &x) {
220- // FIXME: hash the contents.
221- return 131u ;
220+ return llvm::hash_value (toStringRef (x.name ).str ()) * 131u ;
222221 }
223222 static unsigned getHashValue (const Fortran::evaluate::TypeParamInquiry &x) {
224- // FIXME: hash the contents.
225- return 137u ;
223+ return getHashValue (x.base ()) * 137u - getHashValue (x.parameter ()) * 3u ;
226224 }
227225 static unsigned getHashValue (const Fortran::evaluate::DescriptorInquiry &x) {
228- // FIXME: hash the contents.
229- return 139u ;
226+ return getHashValue (x.base ()) * 139u -
227+ static_cast <unsigned >(x.field ()) * 13u +
228+ static_cast <unsigned >(x.dimension ());
230229 }
231230 static unsigned
232231 getHashValue (const Fortran::evaluate::StructureConstructor &x) {
@@ -280,6 +279,10 @@ unsigned Fortran::lower::getHashValue(
280279 [&](const auto *p) { return HashEvaluateExpr::getHashValue (*p); }, x);
281280}
282281
282+ unsigned Fortran::lower::getHashValue (Fortran::lower::FrontEndExpr x) {
283+ return HashEvaluateExpr::getHashValue (*x);
284+ }
285+
283286namespace {
284287// Define the is equals test for using Fortran::evaluate::Expr values with
285288// llvm::DenseMap.
@@ -464,9 +467,8 @@ class IsEqualEvaluateExpr {
464467 return isEqual (*xs, *ys);
465468 return false ;
466469 }
467- if ([[maybe_unused]] const auto *ys = y.GetAssumedTypeDummy ())
468- return false ;
469- return isEqual (*x.UnwrapExpr (), *y.UnwrapExpr ());
470+ return !y.GetAssumedTypeDummy () &&
471+ isEqual (*x.UnwrapExpr (), *y.UnwrapExpr ());
470472 }
471473 static bool isEqual (const Fortran::evaluate::ProcedureDesignator &x,
472474 const Fortran::evaluate::ProcedureDesignator &y) {
@@ -484,15 +486,16 @@ class IsEqualEvaluateExpr {
484486 }
485487 static bool isEqual (const Fortran::evaluate::ImpliedDoIndex &x,
486488 const Fortran::evaluate::ImpliedDoIndex &y) {
487- llvm::report_fatal_error ( " not implemented " );
489+ return toStringRef (x. name ) == toStringRef (y. name );
488490 }
489491 static bool isEqual (const Fortran::evaluate::TypeParamInquiry &x,
490492 const Fortran::evaluate::TypeParamInquiry &y) {
491- llvm::report_fatal_error ( " not implemented " );
493+ return isEqual (x. base (), y. base ()) && isEqual (x. parameter (), y. parameter () );
492494 }
493495 static bool isEqual (const Fortran::evaluate::DescriptorInquiry &x,
494496 const Fortran::evaluate::DescriptorInquiry &y) {
495- llvm::report_fatal_error (" not implemented" );
497+ return isEqual (x.base (), y.base ()) && x.field () == y.field () &&
498+ x.dimension () == y.dimension ();
496499 }
497500 static bool isEqual (const Fortran::evaluate::StructureConstructor &x,
498501 const Fortran::evaluate::StructureConstructor &y) {
@@ -572,6 +575,16 @@ bool Fortran::lower::isEqual(
572575 x, y);
573576}
574577
578+ bool Fortran::lower::isEqual (Fortran::lower::FrontEndExpr x,
579+ Fortran::lower::FrontEndExpr y) {
580+ auto empty = llvm::DenseMapInfo<Fortran::lower::FrontEndExpr>::getEmptyKey ();
581+ auto tombstone =
582+ llvm::DenseMapInfo<Fortran::lower::FrontEndExpr>::getTombstoneKey ();
583+ if (x == empty || y == empty || x == tombstone || y == tombstone)
584+ return x == y;
585+ return x == y || IsEqualEvaluateExpr::isEqual (*x, *y);
586+ }
587+
575588namespace {
576589
577590// / This class can recover the base array in an expression that contains
0 commit comments