aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/X86/X86FrameLowering.h
diff options
context:
space:
mode:
authormingmingl <mingmingl@google.com>2025-02-04 11:11:14 -0800
committermingmingl <mingmingl@google.com>2025-02-04 11:11:14 -0800
commite91747a92d27ecf799427bf563f9f64f7c4d2447 (patch)
tree7aa5a8a9170deec293e152bdf2be804399dcd612 /llvm/lib/Target/X86/X86FrameLowering.h
parent3a8d9337d816aef41c3ca1484be8b933a71a3c46 (diff)
parent53d6e59b594639417cdbfcfa2d18cea64acb4009 (diff)
downloadllvm-users/mingmingl-llvm/spr/sdpglobalvariable.zip
llvm-users/mingmingl-llvm/spr/sdpglobalvariable.tar.gz
llvm-users/mingmingl-llvm/spr/sdpglobalvariable.tar.bz2
Merge branch 'main' into users/mingmingl-llvm/spr/sdpglobalvariableusers/mingmingl-llvm/spr/sdpglobalvariable
Diffstat (limited to 'llvm/lib/Target/X86/X86FrameLowering.h')
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.h b/llvm/lib/Target/X86/X86FrameLowering.h
index 02fe8ee..ef41b46 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.h
+++ b/llvm/lib/Target/X86/X86FrameLowering.h
@@ -134,12 +134,50 @@ public:
processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF,
RegScavenger *RS) const override;
- /// Check the instruction before/after the passed instruction. If
- /// it is an ADD/SUB/LEA instruction it is deleted argument and the
- /// stack adjustment is returned as a positive value for ADD/LEA and
- /// a negative for SUB.
- int mergeSPUpdates(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI,
- bool doMergeWithPrevious) const;
+private:
+ /// Basic Pseudocode:
+ /// if (instruction before/after the passed instruction is ADD/SUB/LEA)
+ /// Offset = instruction stack adjustment
+ /// ... positive value for ADD/LEA and negative for SUB
+ /// FoundStackAdjust(instruction, Offset)
+ /// erase(instruction)
+ /// return CalcNewOffset(Offset)
+ /// else
+ /// return CalcNewOffset(0)
+ ///
+ /// It's possible that the selected instruction is not immediately
+ /// before/after MBBI for large adjustments that have been split into multiple
+ /// instructions.
+ ///
+ /// FoundStackAdjust should have the signature:
+ /// void FoundStackAdjust(MachineBasicBlock::iterator PI, int64_t Offset)
+ /// CalcNewOffset should have the signature:
+ /// int64_t CalcNewOffset(int64_t Offset)
+ template <typename FoundT, typename CalcT>
+ int64_t mergeSPUpdates(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator &MBBI,
+ FoundT FoundStackAdjust, CalcT CalcNewOffset,
+ bool doMergeWithPrevious) const;
+
+ template <typename CalcT>
+ int64_t mergeSPUpdates(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator &MBBI, CalcT CalcNewOffset,
+ bool doMergeWithPrevious) const {
+ auto FoundStackAdjust = [](MachineBasicBlock::iterator MBBI,
+ int64_t Offset) {};
+ return mergeSPUpdates(MBB, MBBI, FoundStackAdjust, CalcNewOffset,
+ doMergeWithPrevious);
+ }
+
+public:
+ /// Equivalent to:
+ /// mergeSPUpdates(MBB, MBBI,
+ /// [AddOffset](int64_t Offset) {
+ /// return AddOffset + Offset;
+ /// },
+ /// doMergeWithPrevious);
+ int64_t mergeSPAdd(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI,
+ int64_t AddOffset, bool doMergeWithPrevious) const;
/// Emit a series of instructions to increment / decrement the stack
/// pointer by a constant value.