diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-28 00:22:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-28 00:22:30 +0000 |
commit | 225798143dbec36685f9d1e2fa82f5c4e70b0bf5 (patch) | |
tree | 41d8015147c4cd21aef5d8dd3a57f4064a517bcf /utils/TableGen/CodeGenDAGPatterns.cpp | |
parent | 874cadaf210d4ab05eadc64a41228df0f5078eb7 (diff) |
Generalize my hack to use SDNodeInfo to find out when a
node is always guaranteed to have a particular type
instead of hacking in ISD::STORE explicitly. This allows
us to use implied types for a broad range of nodes, even
target specific ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index d52038ce52..8f4788f872 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -447,6 +447,30 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) { TypeConstraints.assign(ConstraintList.begin(), ConstraintList.end()); } +/// getKnownType - If the type constraints on this node imply a fixed type +/// (e.g. all stores return void, etc), then return it as an +/// MVT::SimpleValueType. Otherwise, return EEVT::isUnknown. +unsigned SDNodeInfo::getKnownType() const { + unsigned NumResults = getNumResults(); + assert(NumResults <= 1 && + "We only work with nodes with zero or one result so far!"); + + for (unsigned i = 0, e = TypeConstraints.size(); i != e; ++i) { + // Make sure that this applies to the correct node result. + if (TypeConstraints[i].OperandNo >= NumResults) // FIXME: need value # + continue; + + switch (TypeConstraints[i].ConstraintType) { + default: break; + case SDTypeConstraint::SDTCisVT: + return TypeConstraints[i].x.SDTCisVT_Info.VT; + case SDTypeConstraint::SDTCisPtrTy: + return MVT::iPTR; + } + } + return EEVT::isUnknown; +} + //===----------------------------------------------------------------------===// // TreePatternNode implementation // |