From a354849c27ef5a4bc55d03a15ce6f89f22a1ca5c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 20 Jun 2006 00:18:02 +0000 Subject: [PATCH] Make sure to use the result of the pattern to infer the result type of the instruction, and the result type of the instruction to refine the pattern. This allows us to write things like this: def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>; as: def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (VR128:$src)> and fixes a ppc64 issue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28863 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 56 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index c46b0883aef..5febddaa893 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -1554,22 +1554,6 @@ void DAGISelEmitter::ParsePatterns() { // Inline pattern fragments into it. Pattern->InlinePatternFragments(); - // Infer as many types as possible. If we cannot infer all of them, we can - // never do anything with this pattern: report it to the user. - if (!Pattern->InferAllTypes()) - Pattern->error("Could not infer all types in pattern!"); - - // Validate that the input pattern is correct. - { - std::map InstInputs; - std::map InstResults; - std::vector InstImpInputs; - std::vector InstImpResults; - FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(), - InstInputs, InstResults, - InstImpInputs, InstImpResults); - } - ListInit *LI = Patterns[i]->getValueAsListInit("ResultInstrs"); if (LI->getSize() == 0) continue; // no pattern. @@ -1578,15 +1562,43 @@ void DAGISelEmitter::ParsePatterns() { // Inline pattern fragments into it. Result->InlinePatternFragments(); - - // Infer as many types as possible. If we cannot infer all of them, we can - // never do anything with this pattern: report it to the user. - if (!Result->InferAllTypes()) - Result->error("Could not infer all types in pattern result!"); - + if (Result->getNumTrees() != 1) Result->error("Cannot handle instructions producing instructions " "with temporaries yet!"); + + bool IterateInference; + do { + // Infer as many types as possible. If we cannot infer all of them, we + // can never do anything with this pattern: report it to the user. + if (!Pattern->InferAllTypes()) + Pattern->error("Could not infer all types in pattern!"); + + // Infer as many types as possible. If we cannot infer all of them, we can + // never do anything with this pattern: report it to the user. + if (!Result->InferAllTypes()) + Result->error("Could not infer all types in pattern result!"); + + // Apply the type of the result to the source pattern. This helps us + // resolve cases where the input type is known to be a pointer type (which + // is considered resolved), but the result knows it needs to be 32- or + // 64-bits. Infer the other way for good measure. + IterateInference = Pattern->getOnlyTree()-> + UpdateNodeType(Result->getOnlyTree()->getExtTypes(), *Result); + IterateInference |= Result->getOnlyTree()-> + UpdateNodeType(Pattern->getOnlyTree()->getExtTypes(), *Result); + } while (IterateInference); + + // Validate that the input pattern is correct. + { + std::map InstInputs; + std::map InstResults; + std::vector InstImpInputs; + std::vector InstImpResults; + FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(), + InstInputs, InstResults, + InstImpInputs, InstImpResults); + } // Promote the xform function to be an explicit node if set. std::vector ResultNodeOperands; -- 2.34.1