mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Fix to bug 1951: tblgen gratuitously renames variables when no temporary was
generated. This feature would only show up in fairly complex patterns, such as this one in CellSPU: def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)), (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>; which generated the following emit code: SDNode *Emit_0(const SDOperand &N, unsigned Opc0, unsigned Opc1, MVT::ValueType VT0, MVT::ValueType VT1) DISABLE_INLINE { SDOperand N0 = N.getOperand(0); SDOperand N00 = N0.getOperand(0); SDOperand N01 = N0.getOperand(1); SDOperand N1 = N.getOperand(1); SDOperand N10 = N1.getOperand(0); SDOperand N11 = N1.getOperand(1); SDOperand Tmp3(CurDAG->getTargetNode(Opc0, VT0, N00), 0); return CurDAG->SelectNodeTo(N.Val, Opc1, VT1, Tmp3, Tmp2); /* Tmp2 s/b N00 */ } Tested against the test suites without incident. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
55030dc460
commit
6be48d49cf
@ -694,7 +694,9 @@ public:
|
|||||||
std::vector<std::string> NodeOps;
|
std::vector<std::string> NodeOps;
|
||||||
// This is something selected from the pattern we matched.
|
// This is something selected from the pattern we matched.
|
||||||
if (!N->getName().empty()) {
|
if (!N->getName().empty()) {
|
||||||
std::string &Val = VariableMap[N->getName()];
|
const std::string &VarName = N->getName();
|
||||||
|
std::string Val = VariableMap[VarName];
|
||||||
|
bool ModifiedVal = false;
|
||||||
assert(!Val.empty() &&
|
assert(!Val.empty() &&
|
||||||
"Variable referenced but not defined and not caught earlier!");
|
"Variable referenced but not defined and not caught earlier!");
|
||||||
if (Val[0] == 'T' && Val[1] == 'm' && Val[2] == 'p') {
|
if (Val[0] == 'T' && Val[1] == 'm' && Val[2] == 'p') {
|
||||||
@ -708,6 +710,7 @@ public:
|
|||||||
if (!N->isLeaf() && N->getOperator()->getName() == "imm") {
|
if (!N->isLeaf() && N->getOperator()->getName() == "imm") {
|
||||||
assert(N->getExtTypes().size() == 1 && "Multiple types not handled!");
|
assert(N->getExtTypes().size() == 1 && "Multiple types not handled!");
|
||||||
std::string CastType;
|
std::string CastType;
|
||||||
|
std::string TmpVar = "Tmp" + utostr(ResNo);
|
||||||
switch (N->getTypeNum(0)) {
|
switch (N->getTypeNum(0)) {
|
||||||
default:
|
default:
|
||||||
cerr << "Cannot handle " << getEnumName(N->getTypeNum(0))
|
cerr << "Cannot handle " << getEnumName(N->getTypeNum(0))
|
||||||
@ -719,56 +722,53 @@ public:
|
|||||||
case MVT::i32: CastType = "unsigned"; break;
|
case MVT::i32: CastType = "unsigned"; break;
|
||||||
case MVT::i64: CastType = "uint64_t"; break;
|
case MVT::i64: CastType = "uint64_t"; break;
|
||||||
}
|
}
|
||||||
emitCode("SDOperand Tmp" + utostr(ResNo) +
|
emitCode("SDOperand " + TmpVar +
|
||||||
" = CurDAG->getTargetConstant(((" + CastType +
|
" = CurDAG->getTargetConstant(((" + CastType +
|
||||||
") cast<ConstantSDNode>(" + Val + ")->getValue()), " +
|
") cast<ConstantSDNode>(" + Val + ")->getValue()), " +
|
||||||
getEnumName(N->getTypeNum(0)) + ");");
|
getEnumName(N->getTypeNum(0)) + ");");
|
||||||
NodeOps.push_back("Tmp" + utostr(ResNo));
|
|
||||||
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select this
|
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select this
|
||||||
// value if used multiple times by this pattern result.
|
// value if used multiple times by this pattern result.
|
||||||
Val = "Tmp"+utostr(ResNo);
|
Val = TmpVar;
|
||||||
|
ModifiedVal = true;
|
||||||
|
NodeOps.push_back(Val);
|
||||||
} else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
|
} else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
|
||||||
Record *Op = OperatorMap[N->getName()];
|
Record *Op = OperatorMap[N->getName()];
|
||||||
// Transform ExternalSymbol to TargetExternalSymbol
|
// Transform ExternalSymbol to TargetExternalSymbol
|
||||||
if (Op && Op->getName() == "externalsym") {
|
if (Op && Op->getName() == "externalsym") {
|
||||||
emitCode("SDOperand Tmp" + utostr(ResNo) + " = CurDAG->getTarget"
|
std::string TmpVar = "Tmp"+utostr(ResNo);
|
||||||
|
emitCode("SDOperand " + TmpVar + " = CurDAG->getTarget"
|
||||||
"ExternalSymbol(cast<ExternalSymbolSDNode>(" +
|
"ExternalSymbol(cast<ExternalSymbolSDNode>(" +
|
||||||
Val + ")->getSymbol(), " +
|
Val + ")->getSymbol(), " +
|
||||||
getEnumName(N->getTypeNum(0)) + ");");
|
getEnumName(N->getTypeNum(0)) + ");");
|
||||||
NodeOps.push_back("Tmp" + utostr(ResNo));
|
|
||||||
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select
|
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select
|
||||||
// this value if used multiple times by this pattern result.
|
// this value if used multiple times by this pattern result.
|
||||||
Val = "Tmp"+utostr(ResNo);
|
Val = TmpVar;
|
||||||
} else {
|
ModifiedVal = true;
|
||||||
NodeOps.push_back(Val);
|
|
||||||
}
|
}
|
||||||
|
NodeOps.push_back(Val);
|
||||||
} else if (!N->isLeaf() && (N->getOperator()->getName() == "tglobaladdr"
|
} else if (!N->isLeaf() && (N->getOperator()->getName() == "tglobaladdr"
|
||||||
|| N->getOperator()->getName() == "tglobaltlsaddr")) {
|
|| N->getOperator()->getName() == "tglobaltlsaddr")) {
|
||||||
Record *Op = OperatorMap[N->getName()];
|
Record *Op = OperatorMap[N->getName()];
|
||||||
// Transform GlobalAddress to TargetGlobalAddress
|
// Transform GlobalAddress to TargetGlobalAddress
|
||||||
if (Op && (Op->getName() == "globaladdr" ||
|
if (Op && (Op->getName() == "globaladdr" ||
|
||||||
Op->getName() == "globaltlsaddr")) {
|
Op->getName() == "globaltlsaddr")) {
|
||||||
emitCode("SDOperand Tmp" + utostr(ResNo) + " = CurDAG->getTarget"
|
std::string TmpVar = "Tmp" + utostr(ResNo);
|
||||||
|
emitCode("SDOperand " + TmpVar + " = CurDAG->getTarget"
|
||||||
"GlobalAddress(cast<GlobalAddressSDNode>(" + Val +
|
"GlobalAddress(cast<GlobalAddressSDNode>(" + Val +
|
||||||
")->getGlobal(), " + getEnumName(N->getTypeNum(0)) +
|
")->getGlobal(), " + getEnumName(N->getTypeNum(0)) +
|
||||||
");");
|
");");
|
||||||
NodeOps.push_back("Tmp" + utostr(ResNo));
|
|
||||||
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select
|
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select
|
||||||
// this value if used multiple times by this pattern result.
|
// this value if used multiple times by this pattern result.
|
||||||
Val = "Tmp"+utostr(ResNo);
|
Val = TmpVar;
|
||||||
} else {
|
ModifiedVal = true;
|
||||||
NodeOps.push_back(Val);
|
|
||||||
}
|
}
|
||||||
} else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
|
|
||||||
NodeOps.push_back(Val);
|
NodeOps.push_back(Val);
|
||||||
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select this
|
} else if (!N->isLeaf()
|
||||||
// value if used multiple times by this pattern result.
|
&& (N->getOperator()->getName() == "texternalsym"
|
||||||
Val = "Tmp"+utostr(ResNo);
|
|| N->getOperator()->getName() == "tconstpool")) {
|
||||||
} else if (!N->isLeaf() && N->getOperator()->getName() == "tconstpool") {
|
// Do not rewrite the variable name, since we don't generate a new
|
||||||
|
// temporary.
|
||||||
NodeOps.push_back(Val);
|
NodeOps.push_back(Val);
|
||||||
// Add Tmp<ResNo> to VariableMap, so that we don't multiply select this
|
|
||||||
// value if used multiple times by this pattern result.
|
|
||||||
Val = "Tmp"+utostr(ResNo);
|
|
||||||
} else if (N->isLeaf() && (CP = NodeGetComplexPattern(N, CGP))) {
|
} else if (N->isLeaf() && (CP = NodeGetComplexPattern(N, CGP))) {
|
||||||
for (unsigned i = 0; i < CP->getNumOperands(); ++i) {
|
for (unsigned i = 0; i < CP->getNumOperands(); ++i) {
|
||||||
emitCode("AddToISelQueue(CPTmp" + utostr(i) + ");");
|
emitCode("AddToISelQueue(CPTmp" + utostr(i) + ");");
|
||||||
@ -786,6 +786,10 @@ public:
|
|||||||
}
|
}
|
||||||
NodeOps.push_back(Val);
|
NodeOps.push_back(Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ModifiedVal) {
|
||||||
|
VariableMap[VarName] = Val;
|
||||||
|
}
|
||||||
return NodeOps;
|
return NodeOps;
|
||||||
}
|
}
|
||||||
if (N->isLeaf()) {
|
if (N->isLeaf()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user