diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-30 00:58:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-30 00:58:19 +0000 |
commit | 4e9fb1f52ebbef5c6fd715e199d09b7381696bb5 (patch) | |
tree | ec9098b76fd78f3a90f250f281538288178c6d9f /llvm | |
parent | 858a4a6595efa4e76e64831af030ff6cc4a9f057 (diff) | |
download | bcm5719-llvm-4e9fb1f52ebbef5c6fd715e199d09b7381696bb5.tar.gz bcm5719-llvm-4e9fb1f52ebbef5c6fd715e199d09b7381696bb5.zip |
Use MRegisterInfo, if available, to print symbolic register names
llvm-svn: 4438
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 1fde26a1b06..961e568f69f 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -7,6 +7,7 @@ #include "llvm/Value.h" #include "llvm/Target/MachineInstrInfo.h" // FIXME: shouldn't need this! #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/MRegisterInfo.h" using std::cerr; // Global variable holding an array of descriptors for machine instructions. @@ -191,14 +192,20 @@ OutputValue(std::ostream &os, const Value* val) return os << (void*) val << ")"; // print address only } -static inline std::ostream& -OutputReg(std::ostream &os, unsigned int regNum) -{ - return os << "%mreg(" << regNum << ")"; +static inline void OutputReg(std::ostream &os, unsigned RegNo, + const MRegisterInfo *MRI = 0) { + if (MRI) { + if (RegNo < MRegisterInfo::FirstVirtualRegister) + os << "%" << MRI->get(RegNo).Name; + else + os << "%reg" << RegNo; + } else + os << "%mreg(" << RegNo << ")"; } static void print(const MachineOperand &MO, std::ostream &OS, const TargetMachine &TM) { + const MRegisterInfo *MRI = TM.getRegisterInfo(); bool CloseParen = true; if (MO.opHiBits32()) OS << "%lm("; @@ -220,18 +227,18 @@ static void print(const MachineOperand &MO, std::ostream &OS, OS << "=="; } if (MO.hasAllocatedReg()) - OutputReg(OS, MO.getAllocatedRegNum()); + OutputReg(OS, MO.getAllocatedRegNum(), MRI); break; case MachineOperand::MO_CCRegister: OS << "%ccreg"; OutputValue(OS, MO.getVRegValue()); if (MO.hasAllocatedReg()) { OS << "=="; - OutputReg(OS, MO.getAllocatedRegNum()); + OutputReg(OS, MO.getAllocatedRegNum(), MRI); } break; case MachineOperand::MO_MachineRegister: - OutputReg(OS, MO.getMachineRegNum()); + OutputReg(OS, MO.getMachineRegNum(), MRI); break; case MachineOperand::MO_SignExtendedImmed: OS << (long)MO.getImmedValue(); |