mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-23 22:23:00 +00:00
[AVX] Make Inits Foldable
Manage Inits in a FoldingSet. This provides several benefits: - Memory for Inits is properly managed - Duplicate Inits are folded into Flyweights, saving memory - It enforces const-correctness, protecting against certain classes of bugs The above benefits allow Inits to be used in more contexts, which in turn provides more dynamism to TableGen. This enhanced capability will be used by the AVX code generator to a fold common patterns together. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,11 +24,11 @@ using namespace llvm;
|
||||
// a single dag, so we can do fancier things.
|
||||
|
||||
unsigned PseudoLoweringEmitter::
|
||||
addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn,
|
||||
addDagOperandMapping(Record *Rec, const DagInit *Dag, CodeGenInstruction &Insn,
|
||||
IndexedMap<OpData> &OperandMap, unsigned BaseIdx) {
|
||||
unsigned OpsAdded = 0;
|
||||
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
|
||||
if (DefInit *DI = dynamic_cast<DefInit*>(Dag->getArg(i))) {
|
||||
if (const DefInit *DI = dynamic_cast<const DefInit*>(Dag->getArg(i))) {
|
||||
// Physical register reference. Explicit check for the special case
|
||||
// "zero_reg" definition.
|
||||
if (DI->getDef()->isSubClassOf("Register") ||
|
||||
@@ -54,11 +54,13 @@ addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn,
|
||||
for (unsigned I = 0, E = Insn.Operands[i].MINumOperands; I != E; ++I)
|
||||
OperandMap[BaseIdx + i + I].Kind = OpData::Operand;
|
||||
OpsAdded += Insn.Operands[i].MINumOperands;
|
||||
} else if (IntInit *II = dynamic_cast<IntInit*>(Dag->getArg(i))) {
|
||||
} else if (const IntInit *II =
|
||||
dynamic_cast<const IntInit*>(Dag->getArg(i))) {
|
||||
OperandMap[BaseIdx + i].Kind = OpData::Imm;
|
||||
OperandMap[BaseIdx + i].Data.Imm = II->getValue();
|
||||
++OpsAdded;
|
||||
} else if (DagInit *SubDag = dynamic_cast<DagInit*>(Dag->getArg(i))) {
|
||||
} else if (const DagInit *SubDag =
|
||||
dynamic_cast<const DagInit*>(Dag->getArg(i))) {
|
||||
// Just add the operands recursively. This is almost certainly
|
||||
// a constant value for a complex operand (> 1 MI operand).
|
||||
unsigned NewOps =
|
||||
@@ -77,11 +79,11 @@ void PseudoLoweringEmitter::evaluateExpansion(Record *Rec) {
|
||||
|
||||
// Validate that the result pattern has the corrent number and types
|
||||
// of arguments for the instruction it references.
|
||||
DagInit *Dag = Rec->getValueAsDag("ResultInst");
|
||||
const DagInit *Dag = Rec->getValueAsDag("ResultInst");
|
||||
assert(Dag && "Missing result instruction in pseudo expansion!");
|
||||
DEBUG(dbgs() << " Result: " << *Dag << "\n");
|
||||
|
||||
DefInit *OpDef = dynamic_cast<DefInit*>(Dag->getOperator());
|
||||
const DefInit *OpDef = dynamic_cast<const DefInit*>(Dag->getOperator());
|
||||
if (!OpDef)
|
||||
throw TGError(Rec->getLoc(), Rec->getName() +
|
||||
" has unexpected operator type!");
|
||||
|
||||
Reference in New Issue
Block a user