[llvm] r323240 - [Hexagon] Implement hasLoadFromStackSlot and hasStoreToStackSlot
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 11:08:40 PST 2018
Author: kparzysz
Date: Tue Jan 23 11:08:40 2018
New Revision: 323240
URL: http://llvm.org/viewvc/llvm-project?rev=323240&view=rev
Log:
[Hexagon] Implement hasLoadFromStackSlot and hasStoreToStackSlot
If the instruction is a bundle, check the instructions inside of it.
Patch by Suyog Sarda.
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h
Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=323240&r1=323239&r2=323240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Tue Jan 23 11:08:40 2018
@@ -332,6 +332,42 @@ unsigned HexagonInstrInfo::isStoreToStac
return 0;
}
+/// This function checks if the instruction or bundle of instructions
+/// has load from stack slot and returns frameindex and machine memory
+/// operand of that instruction if true.
+bool HexagonInstrInfo::hasLoadFromStackSlot(const MachineInstr &MI,
+ const MachineMemOperand *&MMO,
+ int &FrameIndex) const {
+ if (MI.isBundle()) {
+ const MachineBasicBlock *MBB = MI.getParent();
+ MachineBasicBlock::const_instr_iterator MII = MI.getIterator();
+ for (++MII; MII != MBB->instr_end() && MII->isInsideBundle(); ++MII)
+ if (TargetInstrInfo::hasLoadFromStackSlot(*MII, MMO, FrameIndex))
+ return true;
+ return false;
+ }
+
+ return TargetInstrInfo::hasLoadFromStackSlot(MI, MMO, FrameIndex);
+}
+
+/// This function checks if the instruction or bundle of instructions
+/// has store to stack slot and returns frameindex and machine memory
+/// operand of that instruction if true.
+bool HexagonInstrInfo::hasStoreToStackSlot(const MachineInstr &MI,
+ const MachineMemOperand *&MMO,
+ int &FrameIndex) const {
+ if (MI.isBundle()) {
+ const MachineBasicBlock *MBB = MI.getParent();
+ MachineBasicBlock::const_instr_iterator MII = MI.getIterator();
+ for (++MII; MII != MBB->instr_end() && MII->isInsideBundle(); ++MII)
+ if (TargetInstrInfo::hasStoreToStackSlot(*MII, MMO, FrameIndex))
+ return true;
+ return false;
+ }
+
+ return TargetInstrInfo::hasStoreToStackSlot(MI, MMO, FrameIndex);
+}
+
/// This function can analyze one/two way branching only and should (mostly) be
/// called by target independent side.
/// First entry is always the opcode of the branching instruction, except when
Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h?rev=323240&r1=323239&r2=323240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h Tue Jan 23 11:08:40 2018
@@ -66,6 +66,20 @@ public:
unsigned isStoreToStackSlot(const MachineInstr &MI,
int &FrameIndex) const override;
+ /// Check if the instruction or the bundle of instructions has
+ /// load from stack slots. Return the frameindex and machine memory operand
+ /// if true.
+ bool hasLoadFromStackSlot(const MachineInstr &MI,
+ const MachineMemOperand *&MMO,
+ int &FrameIndex) const override;
+
+ /// Check if the instruction or the bundle of instructions has
+ /// store to stack slots. Return the frameindex and machine memory operand
+ /// if true.
+ bool hasStoreToStackSlot(const MachineInstr &MI,
+ const MachineMemOperand *&MMO,
+ int &FrameIndex) const override;
+
/// Analyze the branching code at the end of MBB, returning
/// true if it cannot be understood (e.g. it's a switch dispatch or isn't
/// implemented for a target). Upon success, this returns false and returns
More information about the llvm-commits
mailing list