mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Add support in TableGen for unknown operands that infer their type from the pattern their used in. This will be used to allow insert/extract subreg patterns in .td files!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -864,7 +864,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
CDP.getTargetInfo().getInstruction(getOperator()->getName());
|
CDP.getTargetInfo().getInstruction(getOperator()->getName());
|
||||||
// Apply the result type to the node
|
// Apply the result type to the node
|
||||||
if (NumResults == 0 || InstInfo.NumDefs == 0) {
|
if (NumResults == 0 || InstInfo.NumDefs == 0) {
|
||||||
MadeChange = UpdateNodeType(MVT::isVoid, TP);
|
MadeChange = UpdateNodeType(MVT::isVoid, TP);
|
||||||
} else {
|
} else {
|
||||||
Record *ResultNode = Inst.getResult(0);
|
Record *ResultNode = Inst.getResult(0);
|
||||||
|
|
||||||
@@ -872,6 +872,10 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
std::vector<unsigned char> VT;
|
std::vector<unsigned char> VT;
|
||||||
VT.push_back(MVT::iPTR);
|
VT.push_back(MVT::iPTR);
|
||||||
MadeChange = UpdateNodeType(VT, TP);
|
MadeChange = UpdateNodeType(VT, TP);
|
||||||
|
} else if (ResultNode->getName() == "unknown") {
|
||||||
|
std::vector<unsigned char> VT;
|
||||||
|
VT.push_back(MVT::isUnknown);
|
||||||
|
MadeChange = UpdateNodeType(VT, TP);
|
||||||
} else {
|
} else {
|
||||||
assert(ResultNode->isSubClassOf("RegisterClass") &&
|
assert(ResultNode->isSubClassOf("RegisterClass") &&
|
||||||
"Operands should be register classes!");
|
"Operands should be register classes!");
|
||||||
@@ -910,14 +914,16 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
MadeChange |= Child->UpdateNodeType(VT, TP);
|
MadeChange |= Child->UpdateNodeType(VT, TP);
|
||||||
} else if (OperandNode->getName() == "ptr_rc") {
|
} else if (OperandNode->getName() == "ptr_rc") {
|
||||||
MadeChange |= Child->UpdateNodeType(MVT::iPTR, TP);
|
MadeChange |= Child->UpdateNodeType(MVT::iPTR, TP);
|
||||||
|
} else if (OperandNode->getName() == "unknown") {
|
||||||
|
MadeChange |= Child->UpdateNodeType(MVT::isUnknown, TP);
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Unknown operand type!");
|
assert(0 && "Unknown operand type!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
MadeChange |= Child->ApplyTypeConstraints(TP, NotRegisters);
|
MadeChange |= Child->ApplyTypeConstraints(TP, NotRegisters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ChildNo != getNumChildren())
|
if (ChildNo != getNumChildren() && !InstInfo.isVariadic)
|
||||||
TP.error("Instruction '" + getOperator()->getName() +
|
TP.error("Instruction '" + getOperator()->getName() +
|
||||||
"' was provided too many operands!");
|
"' was provided too many operands!");
|
||||||
|
|
||||||
|
@@ -163,7 +163,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
|
|||||||
isVariadic = true;
|
isVariadic = true;
|
||||||
continue;
|
continue;
|
||||||
} else if (!Rec->isSubClassOf("RegisterClass") &&
|
} else if (!Rec->isSubClassOf("RegisterClass") &&
|
||||||
Rec->getName() != "ptr_rc")
|
Rec->getName() != "ptr_rc" && Rec->getName() != "unknown")
|
||||||
throw "Unknown operand class '" + Rec->getName() +
|
throw "Unknown operand class '" + Rec->getName() +
|
||||||
"' in instruction '" + R->getName() + "' instruction!";
|
"' in instruction '" + R->getName() + "' instruction!";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user