mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Prevent unnecessary CopyToReg when the same HW register appears in two spots
in the pattern. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25437 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1835,6 +1835,7 @@ private:
|
|||||||
std::map<std::string, Record*> OperatorMap;
|
std::map<std::string, Record*> OperatorMap;
|
||||||
// Names of all the folded nodes which produce chains.
|
// Names of all the folded nodes which produce chains.
|
||||||
std::vector<std::pair<std::string, unsigned> > FoldedChains;
|
std::vector<std::pair<std::string, unsigned> > FoldedChains;
|
||||||
|
std::set<std::string> Duplicates;
|
||||||
unsigned TmpNo;
|
unsigned TmpNo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1952,6 +1953,7 @@ public:
|
|||||||
// previously named thing.
|
// previously named thing.
|
||||||
OS << " if (" << VarMapEntry << " != " << RootName << OpNo
|
OS << " if (" << VarMapEntry << " != " << RootName << OpNo
|
||||||
<< ") goto P" << PatternNo << "Fail;\n";
|
<< ") goto P" << PatternNo << "Fail;\n";
|
||||||
|
Duplicates.insert(RootName + utostr(OpNo));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2351,6 +2353,13 @@ private:
|
|||||||
EmitCopyToRegs(Child, RootName + utostr(OpNo), ChainEmitted);
|
EmitCopyToRegs(Child, RootName + utostr(OpNo), ChainEmitted);
|
||||||
} else {
|
} else {
|
||||||
if (DefInit *DI = dynamic_cast<DefInit*>(Child->getLeafValue())) {
|
if (DefInit *DI = dynamic_cast<DefInit*>(Child->getLeafValue())) {
|
||||||
|
if (!Child->getName().empty()) {
|
||||||
|
std::string Name = RootName + utostr(OpNo);
|
||||||
|
if (Duplicates.find(Name) != Duplicates.end())
|
||||||
|
// A duplicate! Do not emit a copy for this node.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Record *RR = DI->getDef();
|
Record *RR = DI->getDef();
|
||||||
if (RR->isSubClassOf("Register")) {
|
if (RR->isSubClassOf("Register")) {
|
||||||
MVT::ValueType RVT = getRegisterValueType(RR, T);
|
MVT::ValueType RVT = getRegisterValueType(RR, T);
|
||||||
|
Reference in New Issue
Block a user