aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/DAGISelEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/DAGISelEmitter.cpp')
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index c46b0883ae..5febddaa89 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<std::string, TreePatternNode*> InstInputs;
- std::map<std::string, TreePatternNode*> InstResults;
- std::vector<Record*> InstImpInputs;
- std::vector<Record*> 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<std::string, TreePatternNode*> InstInputs;
+ std::map<std::string, TreePatternNode*> InstResults;
+ std::vector<Record*> InstImpInputs;
+ std::vector<Record*> InstImpResults;
+ FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(),
+ InstInputs, InstResults,
+ InstImpInputs, InstImpResults);
+ }
// Promote the xform function to be an explicit node if set.
std::vector<TreePatternNode*> ResultNodeOperands;