mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
make FillWithPossibleTypes take a predicate to filter types so that
we don't blow the smallvector as often. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -28,14 +28,15 @@ using namespace llvm;
|
|||||||
static inline bool isInteger(MVT::SimpleValueType VT) {
|
static inline bool isInteger(MVT::SimpleValueType VT) {
|
||||||
return EVT(VT).isInteger();
|
return EVT(VT).isInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isFloatingPoint(MVT::SimpleValueType VT) {
|
static inline bool isFloatingPoint(MVT::SimpleValueType VT) {
|
||||||
return EVT(VT).isFloatingPoint();
|
return EVT(VT).isFloatingPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool isVector(MVT::SimpleValueType VT) {
|
static inline bool isVector(MVT::SimpleValueType VT) {
|
||||||
return EVT(VT).isVector();
|
return EVT(VT).isVector();
|
||||||
}
|
}
|
||||||
|
static inline bool isScalar(MVT::SimpleValueType VT) {
|
||||||
|
return !EVT(VT).isVector();
|
||||||
|
}
|
||||||
|
|
||||||
EEVT::TypeSet::TypeSet(MVT::SimpleValueType VT, TreePattern &TP) {
|
EEVT::TypeSet::TypeSet(MVT::SimpleValueType VT, TreePattern &TP) {
|
||||||
if (VT == MVT::iAny)
|
if (VT == MVT::iAny)
|
||||||
@@ -67,9 +68,28 @@ EEVT::TypeSet::TypeSet(const std::vector<MVT::SimpleValueType> &VTList) {
|
|||||||
|
|
||||||
/// FillWithPossibleTypes - Set to all legal types and return true, only valid
|
/// FillWithPossibleTypes - Set to all legal types and return true, only valid
|
||||||
/// on completely unknown type sets.
|
/// on completely unknown type sets.
|
||||||
bool EEVT::TypeSet::FillWithPossibleTypes(TreePattern &TP) {
|
bool EEVT::TypeSet::FillWithPossibleTypes(TreePattern &TP,
|
||||||
|
bool (*Pred)(MVT::SimpleValueType),
|
||||||
|
const char *PredicateName) {
|
||||||
assert(isCompletelyUnknown());
|
assert(isCompletelyUnknown());
|
||||||
*this = TP.getDAGPatterns().getTargetInfo().getLegalValueTypes();
|
const std::vector<MVT::SimpleValueType> &LegalTypes =
|
||||||
|
TP.getDAGPatterns().getTargetInfo().getLegalValueTypes();
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = LegalTypes.size(); i != e; ++i)
|
||||||
|
if (Pred == 0 || Pred(LegalTypes[i]))
|
||||||
|
TypeVec.push_back(LegalTypes[i]);
|
||||||
|
|
||||||
|
// If we have nothing that matches the predicate, bail out.
|
||||||
|
if (TypeVec.empty())
|
||||||
|
TP.error("Type inference contradiction found, no " +
|
||||||
|
std::string(PredicateName) + " types found");
|
||||||
|
// No need to sort with one element.
|
||||||
|
if (TypeVec.size() == 1) return true;
|
||||||
|
|
||||||
|
// Remove duplicates.
|
||||||
|
array_pod_sort(TypeVec.begin(), TypeVec.end());
|
||||||
|
TypeVec.erase(std::unique(TypeVec.begin(), TypeVec.end()), TypeVec.end());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,86 +225,84 @@ bool EEVT::TypeSet::MergeInTypeInfo(const EEVT::TypeSet &InVT, TreePattern &TP){
|
|||||||
|
|
||||||
/// EnforceInteger - Remove all non-integer types from this set.
|
/// EnforceInteger - Remove all non-integer types from this set.
|
||||||
bool EEVT::TypeSet::EnforceInteger(TreePattern &TP) {
|
bool EEVT::TypeSet::EnforceInteger(TreePattern &TP) {
|
||||||
TypeSet InputSet(*this);
|
|
||||||
bool MadeChange = false;
|
|
||||||
|
|
||||||
// If we know nothing, then get the full set.
|
// If we know nothing, then get the full set.
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
MadeChange = FillWithPossibleTypes(TP);
|
return FillWithPossibleTypes(TP, isInteger, "integer");
|
||||||
|
|
||||||
if (!hasFloatingPointTypes())
|
if (!hasFloatingPointTypes())
|
||||||
return MadeChange;
|
return false;
|
||||||
|
|
||||||
|
TypeSet InputSet(*this);
|
||||||
|
|
||||||
// Filter out all the fp types.
|
// Filter out all the fp types.
|
||||||
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
||||||
if (isFloatingPoint(TypeVec[i]))
|
if (!isInteger(TypeVec[i]))
|
||||||
TypeVec.erase(TypeVec.begin()+i--);
|
TypeVec.erase(TypeVec.begin()+i--);
|
||||||
|
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
TP.error("Type inference contradiction found, '" +
|
TP.error("Type inference contradiction found, '" +
|
||||||
InputSet.getName() + "' needs to be integer");
|
InputSet.getName() + "' needs to be integer");
|
||||||
return MadeChange;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EnforceFloatingPoint - Remove all integer types from this set.
|
/// EnforceFloatingPoint - Remove all integer types from this set.
|
||||||
bool EEVT::TypeSet::EnforceFloatingPoint(TreePattern &TP) {
|
bool EEVT::TypeSet::EnforceFloatingPoint(TreePattern &TP) {
|
||||||
TypeSet InputSet(*this);
|
|
||||||
bool MadeChange = false;
|
|
||||||
|
|
||||||
// If we know nothing, then get the full set.
|
// If we know nothing, then get the full set.
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
MadeChange = FillWithPossibleTypes(TP);
|
return FillWithPossibleTypes(TP, isFloatingPoint, "floating point");
|
||||||
|
|
||||||
if (!hasIntegerTypes())
|
if (!hasIntegerTypes())
|
||||||
return MadeChange;
|
return false;
|
||||||
|
|
||||||
|
TypeSet InputSet(*this);
|
||||||
|
|
||||||
// Filter out all the fp types.
|
// Filter out all the fp types.
|
||||||
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
||||||
if (isInteger(TypeVec[i]))
|
if (!isFloatingPoint(TypeVec[i]))
|
||||||
TypeVec.erase(TypeVec.begin()+i--);
|
TypeVec.erase(TypeVec.begin()+i--);
|
||||||
|
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
TP.error("Type inference contradiction found, '" +
|
TP.error("Type inference contradiction found, '" +
|
||||||
InputSet.getName() + "' needs to be floating point");
|
InputSet.getName() + "' needs to be floating point");
|
||||||
return MadeChange;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EnforceScalar - Remove all vector types from this.
|
/// EnforceScalar - Remove all vector types from this.
|
||||||
bool EEVT::TypeSet::EnforceScalar(TreePattern &TP) {
|
bool EEVT::TypeSet::EnforceScalar(TreePattern &TP) {
|
||||||
TypeSet InputSet(*this);
|
|
||||||
bool MadeChange = false;
|
|
||||||
|
|
||||||
// If we know nothing, then get the full set.
|
// If we know nothing, then get the full set.
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
MadeChange = FillWithPossibleTypes(TP);
|
return FillWithPossibleTypes(TP, isScalar, "scalar");
|
||||||
|
|
||||||
if (!hasVectorTypes())
|
if (!hasVectorTypes())
|
||||||
return MadeChange;
|
return false;
|
||||||
|
|
||||||
|
TypeSet InputSet(*this);
|
||||||
|
|
||||||
// Filter out all the vector types.
|
// Filter out all the vector types.
|
||||||
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
||||||
if (isVector(TypeVec[i]))
|
if (!isScalar(TypeVec[i]))
|
||||||
TypeVec.erase(TypeVec.begin()+i--);
|
TypeVec.erase(TypeVec.begin()+i--);
|
||||||
|
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
TP.error("Type inference contradiction found, '" +
|
TP.error("Type inference contradiction found, '" +
|
||||||
InputSet.getName() + "' needs to be scalar");
|
InputSet.getName() + "' needs to be scalar");
|
||||||
return MadeChange;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EnforceVector - Remove all vector types from this.
|
/// EnforceVector - Remove all vector types from this.
|
||||||
bool EEVT::TypeSet::EnforceVector(TreePattern &TP) {
|
bool EEVT::TypeSet::EnforceVector(TreePattern &TP) {
|
||||||
|
// If we know nothing, then get the full set.
|
||||||
|
if (TypeVec.empty())
|
||||||
|
return FillWithPossibleTypes(TP, isVector, "vector");
|
||||||
|
|
||||||
TypeSet InputSet(*this);
|
TypeSet InputSet(*this);
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
// If we know nothing, then get the full set.
|
|
||||||
if (TypeVec.empty())
|
|
||||||
MadeChange = FillWithPossibleTypes(TP);
|
|
||||||
|
|
||||||
// Filter out all the scalar types.
|
// Filter out all the scalar types.
|
||||||
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
for (unsigned i = 0; i != TypeVec.size(); ++i)
|
||||||
if (!isVector(TypeVec[i]))
|
if (!isVector(TypeVec[i])) {
|
||||||
TypeVec.erase(TypeVec.begin()+i--);
|
TypeVec.erase(TypeVec.begin()+i--);
|
||||||
|
MadeChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
TP.error("Type inference contradiction found, '" +
|
TP.error("Type inference contradiction found, '" +
|
||||||
@@ -384,7 +402,7 @@ bool EEVT::TypeSet::EnforceVectorEltTypeIs(MVT::SimpleValueType VT,
|
|||||||
|
|
||||||
// If we know nothing, then get the full set.
|
// If we know nothing, then get the full set.
|
||||||
if (TypeVec.empty())
|
if (TypeVec.empty())
|
||||||
MadeChange = FillWithPossibleTypes(TP);
|
MadeChange = FillWithPossibleTypes(TP, isVector, "vector");
|
||||||
|
|
||||||
// Filter out all the non-vector types and types which don't have the right
|
// Filter out all the non-vector types and types which don't have the right
|
||||||
// element type.
|
// element type.
|
||||||
|
@@ -54,7 +54,7 @@ namespace EEVT {
|
|||||||
/// Vector has one concrete type: The type is completely known.
|
/// Vector has one concrete type: The type is completely known.
|
||||||
///
|
///
|
||||||
class TypeSet {
|
class TypeSet {
|
||||||
SmallVector<MVT::SimpleValueType, 2> TypeVec;
|
SmallVector<MVT::SimpleValueType, 4> TypeVec;
|
||||||
public:
|
public:
|
||||||
TypeSet() {}
|
TypeSet() {}
|
||||||
TypeSet(MVT::SimpleValueType VT, TreePattern &TP);
|
TypeSet(MVT::SimpleValueType VT, TreePattern &TP);
|
||||||
@@ -136,8 +136,11 @@ namespace EEVT {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// FillWithPossibleTypes - Set to all legal types and return true, only
|
/// FillWithPossibleTypes - Set to all legal types and return true, only
|
||||||
/// valid on completely unknown type sets
|
/// valid on completely unknown type sets. If Pred is non-null, only MVTs
|
||||||
bool FillWithPossibleTypes(TreePattern &TP);
|
/// that pass the predicate are added.
|
||||||
|
bool FillWithPossibleTypes(TreePattern &TP,
|
||||||
|
bool (*Pred)(MVT::SimpleValueType) = 0,
|
||||||
|
const char *PredicateName = 0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user