mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Print out the regclass of any virtual registers used by a machine instruction.
llvm-svn: 109608
This commit is contained in:
parent
c9fcc66f8e
commit
7ac201b2e3
@ -1236,12 +1236,18 @@ static void printDebugLoc(DebugLoc DL, const MachineFunction *MF,
|
|||||||
void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||||
// We can be a bit tidier if we know the TargetMachine and/or MachineFunction.
|
// We can be a bit tidier if we know the TargetMachine and/or MachineFunction.
|
||||||
const MachineFunction *MF = 0;
|
const MachineFunction *MF = 0;
|
||||||
|
const MachineRegisterInfo *MRI = 0;
|
||||||
if (const MachineBasicBlock *MBB = getParent()) {
|
if (const MachineBasicBlock *MBB = getParent()) {
|
||||||
MF = MBB->getParent();
|
MF = MBB->getParent();
|
||||||
if (!TM && MF)
|
if (!TM && MF)
|
||||||
TM = &MF->getTarget();
|
TM = &MF->getTarget();
|
||||||
|
if (MF)
|
||||||
|
MRI = &MF->getRegInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save a list of virtual registers.
|
||||||
|
SmallVector<unsigned, 8> VirtRegs;
|
||||||
|
|
||||||
// Print explicitly defined operands on the left of an assignment syntax.
|
// Print explicitly defined operands on the left of an assignment syntax.
|
||||||
unsigned StartOp = 0, e = getNumOperands();
|
unsigned StartOp = 0, e = getNumOperands();
|
||||||
for (; StartOp < e && getOperand(StartOp).isReg() &&
|
for (; StartOp < e && getOperand(StartOp).isReg() &&
|
||||||
@ -1250,6 +1256,9 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
|||||||
++StartOp) {
|
++StartOp) {
|
||||||
if (StartOp != 0) OS << ", ";
|
if (StartOp != 0) OS << ", ";
|
||||||
getOperand(StartOp).print(OS, TM);
|
getOperand(StartOp).print(OS, TM);
|
||||||
|
unsigned Reg = getOperand(StartOp).getReg();
|
||||||
|
if (Reg && TargetRegisterInfo::isVirtualRegister(Reg))
|
||||||
|
VirtRegs.push_back(Reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartOp != 0)
|
if (StartOp != 0)
|
||||||
@ -1264,6 +1273,10 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
|||||||
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
|
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
|
||||||
const MachineOperand &MO = getOperand(i);
|
const MachineOperand &MO = getOperand(i);
|
||||||
|
|
||||||
|
if (MO.isReg() && MO.getReg() &&
|
||||||
|
TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||||
|
VirtRegs.push_back(MO.getReg());
|
||||||
|
|
||||||
// Omit call-clobbered registers which aren't used anywhere. This makes
|
// Omit call-clobbered registers which aren't used anywhere. This makes
|
||||||
// call instructions much less noisy on targets where calls clobber lots
|
// call instructions much less noisy on targets where calls clobber lots
|
||||||
// of registers. Don't rely on MO.isDead() because we may be called before
|
// of registers. Don't rely on MO.isDead() because we may be called before
|
||||||
@ -1330,6 +1343,24 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print the regclass of any virtual registers encountered.
|
||||||
|
if (MRI && !VirtRegs.empty()) {
|
||||||
|
if (!HaveSemi) OS << ";"; HaveSemi = true;
|
||||||
|
for (unsigned i = 0; i != VirtRegs.size(); ++i) {
|
||||||
|
const TargetRegisterClass *RC = MRI->getRegClass(VirtRegs[i]);
|
||||||
|
OS << " " << RC->getName() << ":%reg" << VirtRegs[i];
|
||||||
|
for (unsigned j = i+1; j != VirtRegs.size();) {
|
||||||
|
if (MRI->getRegClass(VirtRegs[j]) != RC) {
|
||||||
|
++j;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (VirtRegs[i] != VirtRegs[j])
|
||||||
|
OS << "," << VirtRegs[j];
|
||||||
|
VirtRegs.erase(VirtRegs.begin()+j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!debugLoc.isUnknown() && MF) {
|
if (!debugLoc.isUnknown() && MF) {
|
||||||
if (!HaveSemi) OS << ";";
|
if (!HaveSemi) OS << ";";
|
||||||
OS << " dbg:";
|
OS << " dbg:";
|
||||||
|
Loading…
Reference in New Issue
Block a user