Added canFoldMemoryOperand for PPC.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 5 Dec 2007 18:41:29 +0000 (18:41 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 5 Dec 2007 18:41:29 +0000 (18:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44623 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h

index dec49bd16a7a6482b45c0f6e301967402747489f..634681cdb4ed1228ba1676a06d81811bc7777c97 100644 (file)
@@ -613,6 +613,26 @@ MachineInstr *PPCRegisterInfo::foldMemoryOperand(MachineInstr *MI,
   return NewMI;
 }
 
+bool PPCRegisterInfo::canFoldMemoryOperand(MachineInstr *MI,
+                                         SmallVectorImpl<unsigned> &Ops) const {
+  if (Ops.size() != 1) return NULL;
+
+  // Make sure this is a reg-reg copy.  Note that we can't handle MCRF, because
+  // it takes more than one instruction to store it.
+  unsigned Opc = MI->getOpcode();
+
+  if ((Opc == PPC::OR &&
+       MI->getOperand(1).getReg() == MI->getOperand(2).getReg()))
+    return true;
+  else if ((Opc == PPC::OR8 &&
+              MI->getOperand(1).getReg() == MI->getOperand(2).getReg()))
+    return true;
+  else if (Opc == PPC::FMRD || Opc == PPC::FMRS)
+    return true;
+
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 // Stack Frame Processing methods
 //===----------------------------------------------------------------------===//
index 687af569717dc90a76b95923f585e5ee3605bd5e..2106c6e667bb2961cbb6a6ff7e3697c08901f34d 100644 (file)
@@ -75,6 +75,9 @@ public:
     return 0;
   }
 
+  virtual bool canFoldMemoryOperand(MachineInstr *MI,
+                                    SmallVectorImpl<unsigned> &Ops) const;
+
   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
 
   const TargetRegisterClass* const*