return Changed;
}
-void TypeSetByHwMode::validate() const {
+bool TypeSetByHwMode::validate() const {
#ifndef NDEBUG
if (empty())
- return;
+ return true;
bool AllEmpty = true;
for (const auto &I : *this)
AllEmpty &= I.second.empty();
- assert(!AllEmpty &&
- "type set is empty for each HW mode: type contradiction?");
+ return !AllEmpty;
#endif
+ return true;
}
// --- TypeInfer
bool TypeInfer::MergeInTypeInfo(TypeSetByHwMode &Out,
const TypeSetByHwMode &In) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
In.validate();
if (In.empty() || Out == In || TP.hasError())
return false;
}
bool TypeInfer::forceArbitrary(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError())
return false;
assert(!Out.empty() && "cannot pick from an empty set");
}
bool TypeInfer::EnforceInteger(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError())
return false;
if (!Out.empty())
}
bool TypeInfer::EnforceFloatingPoint(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError())
return false;
if (!Out.empty())
}
bool TypeInfer::EnforceScalar(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError())
return false;
if (!Out.empty())
}
bool TypeInfer::EnforceVector(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError())
return false;
if (!Out.empty())
}
bool TypeInfer::EnforceAny(TypeSetByHwMode &Out) {
- ValidateOnExit _1(Out);
+ ValidateOnExit _1(Out, *this);
if (TP.hasError() || !Out.empty())
return false;
/// Make sure that for each type in Small, there exists a larger type in Big.
bool TypeInfer::EnforceSmallerThan(TypeSetByHwMode &Small,
TypeSetByHwMode &Big) {
- ValidateOnExit _1(Small), _2(Big);
+ ValidateOnExit _1(Small, *this), _2(Big, *this);
if (TP.hasError())
return false;
bool Changed = false;
/// type T in Vec, such that U is the element type of T.
bool TypeInfer::EnforceVectorEltTypeIs(TypeSetByHwMode &Vec,
TypeSetByHwMode &Elem) {
- ValidateOnExit _1(Vec), _2(Elem);
+ ValidateOnExit _1(Vec, *this), _2(Elem, *this);
if (TP.hasError())
return false;
bool Changed = false;
bool TypeInfer::EnforceVectorEltTypeIs(TypeSetByHwMode &Vec,
const ValueTypeByHwMode &VVT) {
TypeSetByHwMode Tmp(VVT);
- ValidateOnExit _1(Vec), _2(Tmp);
+ ValidateOnExit _1(Vec, *this), _2(Tmp, *this);
return EnforceVectorEltTypeIs(Vec, Tmp);
}
/// element type as T and at least as many elements as T.
bool TypeInfer::EnforceVectorSubVectorTypeIs(TypeSetByHwMode &Vec,
TypeSetByHwMode &Sub) {
- ValidateOnExit _1(Vec), _2(Sub);
+ ValidateOnExit _1(Vec, *this), _2(Sub, *this);
if (TP.hasError())
return false;
/// type T in V, such that T and U have the same number of elements
/// (reverse of 2).
bool TypeInfer::EnforceSameNumElts(TypeSetByHwMode &V, TypeSetByHwMode &W) {
- ValidateOnExit _1(V), _2(W);
+ ValidateOnExit _1(V, *this), _2(W, *this);
if (TP.hasError())
return false;
/// 2. Ensure that for each type U in B, there exists a type T in A
/// such that T and U have equal size in bits (reverse of 1).
bool TypeInfer::EnforceSameSize(TypeSetByHwMode &A, TypeSetByHwMode &B) {
- ValidateOnExit _1(A), _2(B);
+ ValidateOnExit _1(A, *this), _2(B, *this);
if (TP.hasError())
return false;
bool Changed = false;
}
void TypeInfer::expandOverloads(TypeSetByHwMode &VTS) {
- ValidateOnExit _1(VTS);
+ ValidateOnExit _1(VTS, *this);
TypeSetByHwMode Legal = getLegalTypes();
bool HaveLegalDef = Legal.hasDefault();
return VTS;
}
+#ifndef NDEBUG
+TypeInfer::ValidateOnExit::~ValidateOnExit() {
+ if (!VTS.validate()) {
+ dbgs() << "Type set is empty for each HW mode:\n"
+ "possible type contradiction in the pattern below "
+ "(use -print-records with llvm-tblgen to see all "
+ "expanded records).\n";
+ Infer.TP.dump();
+ llvm_unreachable(nullptr);
+ }
+}
+#endif
+
//===----------------------------------------------------------------------===//
// TreePredicateFn Implementation
//===----------------------------------------------------------------------===//