@@ -208,7 +208,7 @@ class HashEvaluateExpr {
208
208
unsigned args = 13u ;
209
209
for (const auto &v : x.arguments ())
210
210
args -= getHashValue (v);
211
- return getHashValue (x.proc ()) * 101u ;
211
+ return getHashValue (x.proc ()) * 101u - args ;
212
212
}
213
213
template <typename A>
214
214
static unsigned
@@ -217,16 +217,15 @@ class HashEvaluateExpr {
217
217
return 127u ;
218
218
}
219
219
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 ;
222
221
}
223
222
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 ;
226
224
}
227
225
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 ());
230
229
}
231
230
static unsigned
232
231
getHashValue (const Fortran::evaluate::StructureConstructor &x) {
@@ -280,6 +279,10 @@ unsigned Fortran::lower::getHashValue(
280
279
[&](const auto *p) { return HashEvaluateExpr::getHashValue (*p); }, x);
281
280
}
282
281
282
+ unsigned Fortran::lower::getHashValue (Fortran::lower::FrontEndExpr x) {
283
+ return HashEvaluateExpr::getHashValue (*x);
284
+ }
285
+
283
286
namespace {
284
287
// Define the is equals test for using Fortran::evaluate::Expr values with
285
288
// llvm::DenseMap.
@@ -464,9 +467,8 @@ class IsEqualEvaluateExpr {
464
467
return isEqual (*xs, *ys);
465
468
return false ;
466
469
}
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 ());
470
472
}
471
473
static bool isEqual (const Fortran::evaluate::ProcedureDesignator &x,
472
474
const Fortran::evaluate::ProcedureDesignator &y) {
@@ -484,15 +486,16 @@ class IsEqualEvaluateExpr {
484
486
}
485
487
static bool isEqual (const Fortran::evaluate::ImpliedDoIndex &x,
486
488
const Fortran::evaluate::ImpliedDoIndex &y) {
487
- llvm::report_fatal_error ( " not implemented " );
489
+ return toStringRef (x. name ) == toStringRef (y. name );
488
490
}
489
491
static bool isEqual (const Fortran::evaluate::TypeParamInquiry &x,
490
492
const Fortran::evaluate::TypeParamInquiry &y) {
491
- llvm::report_fatal_error ( " not implemented " );
493
+ return isEqual (x. base (), y. base ()) && isEqual (x. parameter (), y. parameter () );
492
494
}
493
495
static bool isEqual (const Fortran::evaluate::DescriptorInquiry &x,
494
496
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 ();
496
499
}
497
500
static bool isEqual (const Fortran::evaluate::StructureConstructor &x,
498
501
const Fortran::evaluate::StructureConstructor &y) {
@@ -572,6 +575,16 @@ bool Fortran::lower::isEqual(
572
575
x, y);
573
576
}
574
577
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
+
575
588
namespace {
576
589
577
590
// / This class can recover the base array in an expression that contains
0 commit comments