llvm.org GIT mirror llvm / 2df3f58
Hoist hasLoadFromStackSlot and hasStoreToStackSlot. These the methods are target-independent since they simply scan the memory operands. They can live in TargetInstrInfoImpl. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137063 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 9 years ago
4 changed file(s) with 42 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
692692 unsigned &SrcOpIdx2) const;
693693 virtual bool canFoldMemoryOperand(const MachineInstr *MI,
694694 const SmallVectorImpl &Ops) const;
695 virtual bool hasLoadFromStackSlot(const MachineInstr *MI,
696 const MachineMemOperand *&MMO,
697 int &FrameIndex) const;
698 virtual bool hasStoreToStackSlot(const MachineInstr *MI,
699 const MachineMemOperand *&MMO,
700 int &FrameIndex) const;
695701 virtual bool PredicateInstruction(MachineInstr *MI,
696702 const SmallVectorImpl &Pred) const;
697703 virtual void reMaterialize(MachineBasicBlock &MBB,
157157 }
158158 }
159159 return MadeChange;
160 }
161
162 bool TargetInstrInfoImpl::hasLoadFromStackSlot(const MachineInstr *MI,
163 const MachineMemOperand *&MMO,
164 int &FrameIndex) const {
165 for (MachineInstr::mmo_iterator o = MI->memoperands_begin(),
166 oe = MI->memoperands_end();
167 o != oe;
168 ++o) {
169 if ((*o)->isLoad() && (*o)->getValue())
170 if (const FixedStackPseudoSourceValue *Value =
171 dyn_cast((*o)->getValue())) {
172 FrameIndex = Value->getFrameIndex();
173 MMO = *o;
174 return true;
175 }
176 }
177 return false;
178 }
179
180 bool TargetInstrInfoImpl::hasStoreToStackSlot(const MachineInstr *MI,
181 const MachineMemOperand *&MMO,
182 int &FrameIndex) const {
183 for (MachineInstr::mmo_iterator o = MI->memoperands_begin(),
184 oe = MI->memoperands_end();
185 o != oe;
186 ++o) {
187 if ((*o)->isStore() && (*o)->getValue())
188 if (const FixedStackPseudoSourceValue *Value =
189 dyn_cast((*o)->getValue())) {
190 FrameIndex = Value->getFrameIndex();
191 MMO = *o;
192 return true;
193 }
194 }
195 return false;
160196 }
161197
162198 void TargetInstrInfoImpl::reMaterialize(MachineBasicBlock &MBB,
855855 return 0;
856856 }
857857
858 bool X86InstrInfo::hasLoadFromStackSlot(const MachineInstr *MI,
859 const MachineMemOperand *&MMO,
860 int &FrameIndex) const {
861 for (MachineInstr::mmo_iterator o = MI->memoperands_begin(),
862 oe = MI->memoperands_end();
863 o != oe;
864 ++o) {
865 if ((*o)->isLoad() && (*o)->getValue())
866 if (const FixedStackPseudoSourceValue *Value =
867 dyn_cast((*o)->getValue())) {
868 FrameIndex = Value->getFrameIndex();
869 MMO = *o;
870 return true;
871 }
872 }
873 return false;
874 }
875
876858 unsigned X86InstrInfo::isStoreToStackSlot(const MachineInstr *MI,
877859 int &FrameIndex) const {
878860 if (isFrameStoreOpcode(MI->getOpcode()))
893875 return hasStoreToStackSlot(MI, Dummy, FrameIndex);
894876 }
895877 return 0;
896 }
897
898 bool X86InstrInfo::hasStoreToStackSlot(const MachineInstr *MI,
899 const MachineMemOperand *&MMO,
900 int &FrameIndex) const {
901 for (MachineInstr::mmo_iterator o = MI->memoperands_begin(),
902 oe = MI->memoperands_end();
903 o != oe;
904 ++o) {
905 if ((*o)->isStore() && (*o)->getValue())
906 if (const FixedStackPseudoSourceValue *Value =
907 dyn_cast((*o)->getValue())) {
908 FrameIndex = Value->getFrameIndex();
909 MMO = *o;
910 return true;
911 }
912 }
913 return false;
914878 }
915879
916880 /// regIsPICBase - Return true if register is PIC base (i.e.g defined by
165165 unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI,
166166 int &FrameIndex) const;
167167
168 /// hasLoadFromStackSlot - If the specified machine instruction has
169 /// a load from a stack slot, return true along with the FrameIndex
170 /// of the loaded stack slot and the machine mem operand containing
171 /// the reference. If not, return false. Unlike
172 /// isLoadFromStackSlot, this returns true for any instructions that
173 /// loads from the stack. This is a hint only and may not catch all
174 /// cases.
175 bool hasLoadFromStackSlot(const MachineInstr *MI,
176 const MachineMemOperand *&MMO,
177 int &FrameIndex) const;
178
179168 unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const;
180169 /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
181170 /// stack locations as well. This uses a heuristic so it isn't
182171 /// reliable for correctness.
183172 unsigned isStoreToStackSlotPostFE(const MachineInstr *MI,
184173 int &FrameIndex) const;
185
186 /// hasStoreToStackSlot - If the specified machine instruction has a
187 /// store to a stack slot, return true along with the FrameIndex of
188 /// the loaded stack slot and the machine mem operand containing the
189 /// reference. If not, return false. Unlike isStoreToStackSlot,
190 /// this returns true for any instructions that loads from the
191 /// stack. This is a hint only and may not catch all cases.
192 bool hasStoreToStackSlot(const MachineInstr *MI,
193 const MachineMemOperand *&MMO,
194 int &FrameIndex) const;
195174
196175 bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
197176 AliasAnalysis *AA) const;