summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-01-23 19:08:40 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-01-23 19:08:40 +0000
commit275ffa467955f84954ca3b7c4d55e22fcded6aec (patch)
tree5e74e0222ff9fcaf424a0d6b1dc77f41f6897811
parent5ecdb94487bb3afb98e1ec853aefd5820418651c (diff)
downloadbcm5719-llvm-275ffa467955f84954ca3b7c4d55e22fcded6aec.tar.gz
bcm5719-llvm-275ffa467955f84954ca3b7c4d55e22fcded6aec.zip
[Hexagon] Implement hasLoadFromStackSlot and hasStoreToStackSlot
If the instruction is a bundle, check the instructions inside of it. Patch by Suyog Sarda. llvm-svn: 323240
-rw-r--r--llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp36
-rw-r--r--llvm/lib/Target/Hexagon/HexagonInstrInfo.h14
2 files changed, 50 insertions, 0 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
index b82a0157e81..f313f2fc867 100644
--- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
@@ -332,6 +332,42 @@ unsigned HexagonInstrInfo::isStoreToStackSlot(const MachineInstr &MI,
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
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h
index 7c095d9c277..39b69d1ab2c 100644
--- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h
+++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h
@@ -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
OpenPOWER on IntegriCloud