mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
Fix verification of explicit operands.
The machine code verifier did not check for explicit operands correctly. It used MachineInstr::getNumExplicitOperands, but that method may cheat and use the declared count in the TargetInstrDesc. Now we check the explicit operands one at a time in visitMachineOperand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82652 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
959b002c4d
commit
39523e2cfb
@ -466,18 +466,11 @@ void
|
|||||||
MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI)
|
MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI)
|
||||||
{
|
{
|
||||||
const TargetInstrDesc &TI = MI->getDesc();
|
const TargetInstrDesc &TI = MI->getDesc();
|
||||||
if (MI->getNumExplicitOperands() < TI.getNumOperands()) {
|
if (MI->getNumOperands() < TI.getNumOperands()) {
|
||||||
report("Too few operands", MI);
|
report("Too few operands", MI);
|
||||||
*OS << TI.getNumOperands() << " operands expected, but "
|
*OS << TI.getNumOperands() << " operands expected, but "
|
||||||
<< MI->getNumExplicitOperands() << " given.\n";
|
<< MI->getNumExplicitOperands() << " given.\n";
|
||||||
}
|
}
|
||||||
if (!TI.isVariadic()) {
|
|
||||||
if (MI->getNumExplicitOperands() > TI.getNumOperands()) {
|
|
||||||
report("Too many operands", MI);
|
|
||||||
*OS << TI.getNumOperands() << " operands expected, but "
|
|
||||||
<< MI->getNumExplicitOperands() << " given.\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -494,6 +487,16 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum)
|
|||||||
report("Explicit definition marked as use", MO, MONum);
|
report("Explicit definition marked as use", MO, MONum);
|
||||||
else if (MO->isImplicit())
|
else if (MO->isImplicit())
|
||||||
report("Explicit definition marked as implicit", MO, MONum);
|
report("Explicit definition marked as implicit", MO, MONum);
|
||||||
|
} else if (MONum < TI.getNumOperands()) {
|
||||||
|
if (MO->isReg()) {
|
||||||
|
if (MO->isDef())
|
||||||
|
report("Explicit operand marked as def", MO, MONum);
|
||||||
|
if (MO->isImplicit())
|
||||||
|
report("Explicit operand marked as implicit", MO, MONum);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (MO->isReg() && !MO->isImplicit() && !TI.isVariadic())
|
||||||
|
report("Extra explicit operand on non-variadic instruction", MO, MONum);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (MO->getType()) {
|
switch (MO->getType()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user