From 35b35c5c320a71e4611fe2101452da685f8eeda0 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 30 Aug 2007 05:52:20 +0000 Subject: [PATCH] Add a variant of foldMemoryOperand to fold any load / store, not just load / store from / to stack slots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41597 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 12 +++++++----- include/llvm/Target/MRegisterInfo.h | 9 +++++++++ lib/Target/ARM/ARMRegisterInfo.h | 5 +++++ lib/Target/Alpha/AlphaRegisterInfo.h | 5 +++++ lib/Target/Mips/MipsRegisterInfo.h | 5 +++++ lib/Target/PowerPC/PPCRegisterInfo.h | 5 +++++ lib/Target/Sparc/SparcRegisterInfo.h | 6 ++++++ 7 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 59d482e955e..bf78475a01f 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -242,11 +242,13 @@ namespace llvm { bool isReMaterializable(const LiveInterval &li, const VNInfo *ValNo, MachineInstr *MI); - /// tryFoldMemoryOperand - Attempts to fold a spill / restore from slot - /// to reg into ith operand of specified MI. If it is successul, MI is - /// updated with the newly created MI and returns true. - bool tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, unsigned index, - unsigned i, int slot, unsigned reg); + /// tryFoldMemoryOperand - Attempts to fold either a spill / restore from + /// slot / to reg or any rematerialized load into ith operand of specified + /// MI. If it is successul, MI is updated with the newly created MI and + /// returns true. + bool tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, + unsigned index, unsigned i, bool isSS, + MachineInstr *DefMI, int slot, unsigned reg); static LiveInterval createInterval(unsigned Reg); diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h index d88bcf0c7c2..a4846d8afa8 100644 --- a/include/llvm/Target/MRegisterInfo.h +++ b/include/llvm/Target/MRegisterInfo.h @@ -521,6 +521,15 @@ public: return 0; } + /// foldMemoryOperand - Same as the previous version except it allows folding + /// of any load and store from / to any address, not just from a specific + /// stack slot. + virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, + unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + /// targetHandlesStackFrameRounding - Returns true if the target is responsible /// for rounding up the stack frame (probably at emitPrologue time). virtual bool targetHandlesStackFrameRounding() const { diff --git a/lib/Target/ARM/ARMRegisterInfo.h b/lib/Target/ARM/ARMRegisterInfo.h index a425bb6f903..614eaec5b7c 100644 --- a/lib/Target/ARM/ARMRegisterInfo.h +++ b/lib/Target/ARM/ARMRegisterInfo.h @@ -66,6 +66,11 @@ public: MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, int FrameIndex) const; + MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const; const TargetRegisterClass* const* diff --git a/lib/Target/Alpha/AlphaRegisterInfo.h b/lib/Target/Alpha/AlphaRegisterInfo.h index 2872e595bb0..354c3a12f3a 100644 --- a/lib/Target/Alpha/AlphaRegisterInfo.h +++ b/lib/Target/Alpha/AlphaRegisterInfo.h @@ -41,6 +41,11 @@ struct AlphaRegisterInfo : public AlphaGenRegisterInfo { MachineInstr* foldMemoryOperand(MachineInstr *MI, unsigned OpNum, int FrameIndex) const; + MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; diff --git a/lib/Target/Mips/MipsRegisterInfo.h b/lib/Target/Mips/MipsRegisterInfo.h index cc8215c8649..2727910972d 100644 --- a/lib/Target/Mips/MipsRegisterInfo.h +++ b/lib/Target/Mips/MipsRegisterInfo.h @@ -48,6 +48,11 @@ struct MipsRegisterInfo : public MipsGenRegisterInfo { MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, int FrameIndex) const; + MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; diff --git a/lib/Target/PowerPC/PPCRegisterInfo.h b/lib/Target/PowerPC/PPCRegisterInfo.h index 0a1446eb780..19bec1ca7f8 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.h +++ b/lib/Target/PowerPC/PPCRegisterInfo.h @@ -57,6 +57,11 @@ public: virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, int FrameIndex) const; + virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const; const TargetRegisterClass* const* diff --git a/lib/Target/Sparc/SparcRegisterInfo.h b/lib/Target/Sparc/SparcRegisterInfo.h index 451964b2f75..bcb09d475e1 100644 --- a/lib/Target/Sparc/SparcRegisterInfo.h +++ b/lib/Target/Sparc/SparcRegisterInfo.h @@ -51,6 +51,12 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo { unsigned OpNum, int FrameIndex) const; + virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, + unsigned OpNum, + MachineInstr* LoadMI) const { + return 0; + } + const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const; const TargetRegisterClass* const* getCalleeSavedRegClasses( -- 2.34.1