From e26dcfe6affca105469db974d990c961e5ed3437 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 30 Dec 2007 21:08:36 +0000 Subject: [PATCH] simpilfy some register printing code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45458 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineInstr.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 7e778c6efd7..0dfb7c72b3a 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -267,26 +267,16 @@ void MachineInstr::dump() const { cerr << " " << *this; } -static void OutputReg(std::ostream &os, unsigned RegNo, - const MRegisterInfo *MRI = 0) { - if (MRegisterInfo::isPhysicalRegister(RegNo)) { - if (MRI) - os << "%" << MRI->get(RegNo).Name; - else - os << "%mreg" << RegNo; - } else { - os << "%reg" << RegNo; - } -} - static void print(const MachineOperand &MO, std::ostream &OS, const TargetMachine *TM) { - const MRegisterInfo *MRI = 0; - if (TM) MRI = TM->getRegisterInfo(); - switch (MO.getType()) { case MachineOperand::MO_Register: - OutputReg(OS, MO.getReg(), MRI); + if (MO.getReg() == 0 || MRegisterInfo::isVirtualRegister(MO.getReg())) + OS << "%reg" << MO.getReg(); + else if (TM) + OS << "%" << TM->getRegisterInfo()->get(MO.getReg()).Name; + else + OS << "%mreg" << MO.getReg(); if (MO.isDef()) OS << ""; break; case MachineOperand::MO_Immediate: