mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-13 08:35:46 +00:00
Add support for fast-isel of opcodes that require use of extract_subreg. Because of how extract_subreg is treated, it requires special case handling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
97efa36586
commit
b5dbcb538b
@ -172,6 +172,7 @@ struct OperandsSignature {
|
|||||||
struct InstructionMemo {
|
struct InstructionMemo {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
const CodeGenRegisterClass *RC;
|
const CodeGenRegisterClass *RC;
|
||||||
|
unsigned char SubRegNo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FastISelMap {
|
class FastISelMap {
|
||||||
@ -235,12 +236,19 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
|
|||||||
|
|
||||||
// For now, ignore instructions where the first operand is not an
|
// For now, ignore instructions where the first operand is not an
|
||||||
// output register.
|
// output register.
|
||||||
Record *Op0Rec = II.OperandList[0].Rec;
|
const CodeGenRegisterClass *DstRC = 0;
|
||||||
if (!Op0Rec->isSubClassOf("RegisterClass"))
|
unsigned SubRegNo = ~0;
|
||||||
continue;
|
if (Op->getName() != "EXTRACT_SUBREG") {
|
||||||
const CodeGenRegisterClass *DstRC = &Target.getRegisterClass(Op0Rec);
|
Record *Op0Rec = II.OperandList[0].Rec;
|
||||||
if (!DstRC)
|
if (!Op0Rec->isSubClassOf("RegisterClass"))
|
||||||
continue;
|
continue;
|
||||||
|
DstRC = &Target.getRegisterClass(Op0Rec);
|
||||||
|
if (!DstRC)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
SubRegNo = static_cast<IntInit*>(
|
||||||
|
Dst->getChild(1)->getLeafValue())->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
// Inspect the pattern.
|
// Inspect the pattern.
|
||||||
TreePatternNode *InstPatNode = Pattern.getSrcPattern();
|
TreePatternNode *InstPatNode = Pattern.getSrcPattern();
|
||||||
@ -274,7 +282,8 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
|
|||||||
// Ok, we found a pattern that we can handle. Remember it.
|
// Ok, we found a pattern that we can handle. Remember it.
|
||||||
InstructionMemo Memo = {
|
InstructionMemo Memo = {
|
||||||
Pattern.getDstPattern()->getOperator()->getName(),
|
Pattern.getDstPattern()->getOperator()->getName(),
|
||||||
DstRC
|
DstRC,
|
||||||
|
SubRegNo
|
||||||
};
|
};
|
||||||
assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT].count(PredicateCheck) &&
|
assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT].count(PredicateCheck) &&
|
||||||
"Duplicate pattern!");
|
"Duplicate pattern!");
|
||||||
@ -410,13 +419,19 @@ void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
|
|||||||
HasPred = true;
|
HasPred = true;
|
||||||
}
|
}
|
||||||
OS << " return FastEmitInst_";
|
OS << " return FastEmitInst_";
|
||||||
Operands.PrintManglingSuffix(OS);
|
if (Memo.SubRegNo == (unsigned char)~0) {
|
||||||
OS << "(" << InstNS << Memo.Name << ", ";
|
Operands.PrintManglingSuffix(OS);
|
||||||
OS << InstNS << Memo.RC->getName() << "RegisterClass";
|
OS << "(" << InstNS << Memo.Name << ", ";
|
||||||
if (!Operands.empty())
|
OS << InstNS << Memo.RC->getName() << "RegisterClass";
|
||||||
OS << ", ";
|
if (!Operands.empty())
|
||||||
Operands.PrintArguments(OS);
|
OS << ", ";
|
||||||
OS << ");\n";
|
Operands.PrintArguments(OS);
|
||||||
|
OS << ");\n";
|
||||||
|
} else {
|
||||||
|
OS << "extractsubreg(Op0, ";
|
||||||
|
OS << (unsigned)Memo.SubRegNo;
|
||||||
|
OS << ");\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Return 0 if none of the predicates were satisfied.
|
// Return 0 if none of the predicates were satisfied.
|
||||||
if (HasPred)
|
if (HasPred)
|
||||||
@ -482,13 +497,20 @@ void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
|
|||||||
HasPred = true;
|
HasPred = true;
|
||||||
}
|
}
|
||||||
OS << " return FastEmitInst_";
|
OS << " return FastEmitInst_";
|
||||||
Operands.PrintManglingSuffix(OS);
|
|
||||||
OS << "(" << InstNS << Memo.Name << ", ";
|
if (Memo.SubRegNo == (unsigned char)~0) {
|
||||||
OS << InstNS << Memo.RC->getName() << "RegisterClass";
|
Operands.PrintManglingSuffix(OS);
|
||||||
if (!Operands.empty())
|
OS << "(" << InstNS << Memo.Name << ", ";
|
||||||
OS << ", ";
|
OS << InstNS << Memo.RC->getName() << "RegisterClass";
|
||||||
Operands.PrintArguments(OS);
|
if (!Operands.empty())
|
||||||
OS << ");\n";
|
OS << ", ";
|
||||||
|
Operands.PrintArguments(OS);
|
||||||
|
OS << ");\n";
|
||||||
|
} else {
|
||||||
|
OS << "extractsubreg(Op0, ";
|
||||||
|
OS << (unsigned)Memo.SubRegNo;
|
||||||
|
OS << ");\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return 0 if none of the predicates were satisfied.
|
// Return 0 if none of the predicates were satisfied.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user