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 | 99e53b3b334866cdb5efc32fe983901d43c7d779 (patch) | |
tree | 7effe8ed3a4e6a24c56d9606c1450a399374b01b /llvm/utils/TableGen/DAGISelMatcher.cpp | |
parent | bdd6405f29ddf975fca9b1cd9bd0121470c427d5 (diff) | |
download | bcm5719-llvm-99e53b3b334866cdb5efc32fe983901d43c7d779.tar.gz bcm5719-llvm-99e53b3b334866cdb5efc32fe983901d43c7d779.zip |
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.
llvm-svn: 97355
Diffstat (limited to 'llvm/utils/TableGen/DAGISelMatcher.cpp')
-rw-r--r-- | llvm/utils/TableGen/DAGISelMatcher.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcher.cpp b/llvm/utils/TableGen/DAGISelMatcher.cpp index ade058ef5f9..3ea5b5d7fbf 100644 --- a/llvm/utils/TableGen/DAGISelMatcher.cpp +++ b/llvm/utils/TableGen/DAGISelMatcher.cpp @@ -260,25 +260,6 @@ unsigned CompleteMatchMatcher::getHashImpl() const { // isContradictoryImpl Implementations. -bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const { - if (const CheckOpcodeMatcher *COM = dyn_cast<CheckOpcodeMatcher>(M)) { - // One node can't have two different opcodes! - return &COM->getOpcode() != &getOpcode(); - } - - // TODO: CheckMultiOpcodeMatcher? - - // This is a special common case we see a lot in the X86 backend, we know that - // ISD::STORE nodes can't have non-void type. - if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M)) - // FIXME: This sucks, get void nodes from type constraints. - return (getOpcode().getEnumName() == "ISD::STORE" || - getOpcode().getEnumName() == "ISD::INTRINSIC_VOID") && - CT->getType() != MVT::isVoid; - - return false; -} - static bool TypesAreContradictory(MVT::SimpleValueType T1, MVT::SimpleValueType T2) { // If the two types are the same, then they are the same, so they don't @@ -297,6 +278,32 @@ static bool TypesAreContradictory(MVT::SimpleValueType T1, return true; } +bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const { + if (const CheckOpcodeMatcher *COM = dyn_cast<CheckOpcodeMatcher>(M)) { + // One node can't have two different opcodes! + return &COM->getOpcode() != &getOpcode(); + } + + // TODO: CheckMultiOpcodeMatcher? + + // If the node has a known type, and if the type we're checking for is + // different, then we know they contradict. For example, a check for + // ISD::STORE will never be true at the same time a check for Type i32 is. + if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M)) { + // FIXME: What result is this referring to? + unsigned NodeType; + if (getOpcode().getNumResults() == 0) + NodeType = MVT::isVoid; + else + NodeType = getOpcode().getKnownType(); + if (NodeType != EEVT::isUnknown) + return TypesAreContradictory((MVT::SimpleValueType)NodeType, + CT->getType()); + } + + return false; +} + bool CheckTypeMatcher::isContradictoryImpl(const Matcher *M) const { if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M)) return TypesAreContradictory(getType(), CT->getType()); |