[llvm-commits] [llvm] r48221 - /llvm/trunk/lib/CodeGen/LowerSubregs.cpp
Evan Cheng
evan.cheng at apple.com
Tue Mar 11 00:55:13 PDT 2008
Author: evancheng
Date: Tue Mar 11 02:55:13 2008
New Revision: 48221
URL: http://llvm.org/viewvc/llvm-project?rev=48221&view=rev
Log:
Use TargetRegisterInfo::getPhysicalRegisterRegClass. Remove duplicated code.
Modified:
llvm/trunk/lib/CodeGen/LowerSubregs.cpp
Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=48221&r1=48220&r2=48221&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original)
+++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Tue Mar 11 02:55:13 2008
@@ -44,21 +44,6 @@
return new LowerSubregsInstructionPass();
}
-// Returns the Register Class of a physical register.
-static const TargetRegisterClass *getPhysicalRegisterRegClass(
- const TargetRegisterInfo &TRI,
- unsigned reg) {
- assert(TargetRegisterInfo::isPhysicalRegister(reg) &&
- "reg must be a physical register");
- // Pick the register class of the right type that contains this physreg.
- for (TargetRegisterInfo::regclass_iterator I = TRI.regclass_begin(),
- E = TRI.regclass_end(); I != E; ++I)
- if ((*I)->contains(reg))
- return *I;
- assert(false && "Couldn't find the register class");
- return 0;
-}
-
bool LowerSubregsInstructionPass::LowerExtract(MachineInstr *MI) {
MachineBasicBlock *MBB = MI->getParent();
MachineFunction &MF = *MBB->getParent();
@@ -82,11 +67,11 @@
if (SrcReg != DstReg) {
const TargetRegisterClass *TRC = 0;
if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
- TRC = getPhysicalRegisterRegClass(TRI, DstReg);
+ TRC = TRI.getPhysicalRegisterRegClass(DstReg);
} else {
TRC = MF.getRegInfo().getRegClass(DstReg);
}
- assert(TRC == getPhysicalRegisterRegClass(TRI, SrcReg) &&
+ assert(TRC == TRI.getPhysicalRegisterRegClass(SrcReg) &&
"Extract subreg and Dst must be of same register class");
TII.copyRegToReg(*MBB, MI, DstReg, SrcReg, TRC, TRC);
@@ -155,7 +140,7 @@
// Insert sub-register copy
const TargetRegisterClass *TRC1 = 0;
if (TargetRegisterInfo::isPhysicalRegister(InsReg)) {
- TRC1 = getPhysicalRegisterRegClass(TRI, InsReg);
+ TRC1 = TRI.getPhysicalRegisterRegClass(InsReg);
} else {
TRC1 = MF.getRegInfo().getRegClass(InsReg);
}
@@ -179,11 +164,11 @@
// Insert super-register copy
const TargetRegisterClass *TRC0 = 0;
if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
- TRC0 = getPhysicalRegisterRegClass(TRI, DstReg);
+ TRC0 = TRI.getPhysicalRegisterRegClass(DstReg);
} else {
TRC0 = MF.getRegInfo().getRegClass(DstReg);
}
- assert(TRC0 == getPhysicalRegisterRegClass(TRI, SrcReg) &&
+ assert(TRC0 == TRI.getPhysicalRegisterRegClass(SrcReg) &&
"Insert superreg and Dst must be of same register class");
TII.copyRegToReg(*MBB, MI, DstReg, SrcReg, TRC0, TRC0);
@@ -204,7 +189,7 @@
// Insert sub-register copy
const TargetRegisterClass *TRC1 = 0;
if (TargetRegisterInfo::isPhysicalRegister(InsReg)) {
- TRC1 = getPhysicalRegisterRegClass(TRI, InsReg);
+ TRC1 = TRI.getPhysicalRegisterRegClass(InsReg);
} else {
TRC1 = MF.getRegInfo().getRegClass(InsReg);
}
More information about the llvm-commits
mailing list