diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-16 14:33:01 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-16 14:33:01 +0000 |
| commit | 5b03970c7b193ba332f8cc11420a1bb1a4cfff64 (patch) | |
| tree | 79b378ea5fab5b7ecaaf14cb669ea2a346e56b4f /llvm/lib | |
| parent | 5761e33ce4879330ad5c464b696b5a0a80069ee4 (diff) | |
| download | bcm5719-llvm-5b03970c7b193ba332f8cc11420a1bb1a4cfff64.tar.gz bcm5719-llvm-5b03970c7b193ba332f8cc11420a1bb1a4cfff64.zip | |
Another predicate routine
llvm-svn: 76057
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp | 30 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.h | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp index 46db94e4c31..914d333c34c 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -52,6 +52,12 @@ SystemZInstrInfo::SystemZInstrInfo(SystemZTargetMachine &tm) RegSpillOffsets[SpillOffsTab[i][0]] = SpillOffsTab[i][1]; } +/// isGVStub - Return true if the GV requires an extra load to get the +/// real address. +static inline bool isGVStub(GlobalValue *GV, SystemZTargetMachine &TM) { + return TM.getSubtarget<SystemZSubtarget>().GVRequiresExtraLoad(GV, TM, false); +} + void SystemZInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIdx, @@ -246,6 +252,30 @@ unsigned SystemZInstrInfo::isStoreToStackSlot(const MachineInstr *MI, return 0; } +bool SystemZInstrInfo::isInvariantLoad(const MachineInstr *MI) const { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + // Loads from constant pools are trivially invariant. + if (MO.isCPI()) + return true; + + if (MO.isGlobal()) + return isGVStub(MO.getGlobal(), TM); + + // If this is a load from an invariant stack slot, the load is a constant. + if (MO.isFI()) { + const MachineFrameInfo &MFI = + *MI->getParent()->getParent()->getFrameInfo(); + int Idx = MO.getIndex(); + return MFI.isFixedObjectIndex(Idx) && MFI.isImmutableObjectIndex(Idx); + } + } + + // All other instances of these instructions are presumed to have other + // issues. + return false; +} + bool SystemZInstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.h b/llvm/lib/Target/SystemZ/SystemZInstrInfo.h index 2bcdb2e55c4..0ef3ca93bea 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.h +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.h @@ -70,6 +70,7 @@ public: unsigned &SrcSubIdx, unsigned &DstSubIdx) const; unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; + bool isInvariantLoad(const MachineInstr *MI) const; virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |

