mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
don't allow 'imm' or specific imms, like '1' on the LHS of a binop.
This shrinks X86GenDAGISel by ~330 lines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30574 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -800,6 +800,17 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// OnlyOnRHSOfCommutative - Return true if this value is only allowed on the
|
||||||
|
/// RHS of a commutative operation, not the on LHS.
|
||||||
|
static bool OnlyOnRHSOfCommutative(TreePatternNode *N) {
|
||||||
|
if (!N->isLeaf() && N->getOperator()->getName() == "imm")
|
||||||
|
return true;
|
||||||
|
if (N->isLeaf() && dynamic_cast<IntInit*>(N->getLeafValue()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// canPatternMatch - If it is impossible for this pattern to match on this
|
/// canPatternMatch - If it is impossible for this pattern to match on this
|
||||||
/// target, fill in Reason and return false. Otherwise, return true. This is
|
/// target, fill in Reason and return false. Otherwise, return true. This is
|
||||||
/// used as a santity check for .td files (to prevent people from writing stuff
|
/// used as a santity check for .td files (to prevent people from writing stuff
|
||||||
@@ -825,11 +836,9 @@ bool TreePatternNode::canPatternMatch(std::string &Reason, DAGISelEmitter &ISE){
|
|||||||
if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
|
if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
|
||||||
// Scan all of the operands of the node and make sure that only the last one
|
// Scan all of the operands of the node and make sure that only the last one
|
||||||
// is a constant node, unless the RHS also is.
|
// is a constant node, unless the RHS also is.
|
||||||
if (getChild(getNumChildren()-1)->isLeaf() ||
|
if (!OnlyOnRHSOfCommutative(getChild(getNumChildren()-1))) {
|
||||||
getChild(getNumChildren()-1)->getOperator()->getName() != "imm") {
|
|
||||||
for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i)
|
for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i)
|
||||||
if (!getChild(i)->isLeaf() &&
|
if (OnlyOnRHSOfCommutative(getChild(i))) {
|
||||||
getChild(i)->getOperator()->getName() == "imm") {
|
|
||||||
Reason="Immediate value must be on the RHS of commutative operators!";
|
Reason="Immediate value must be on the RHS of commutative operators!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user