-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0025-Xtensa-Reserve-an-emergency-spill-slot-for.patch
55 lines (49 loc) · 2.24 KB
/
0025-Xtensa-Reserve-an-emergency-spill-slot-for.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 7b5a9f0abbe35627c7e72aaff0b358fcd183425b Mon Sep 17 00:00:00 2001
From: Andrei Safronov <safronov@espressif.com>
Date: Wed, 5 Apr 2023 00:58:47 +0300
Subject: [PATCH 025/158] [Xtensa] Reserve an emergency spill slot for
scavenger.
Reserve an emergency spill slot for the register scavenger
when Windowed Call ABI is used.
---
llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp | 16 ++++++++++++++++
llvm/lib/Target/Xtensa/XtensaFrameLowering.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp b/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp
index 82cc9584a31b..53b6b7e1b018 100644
--- a/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp
+++ b/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp
@@ -360,3 +360,19 @@ void XtensaFrameLowering::determineCalleeSaves(MachineFunction &MF,
int FI = MF.getFrameInfo().CreateStackObject(Size, Alignment, false);
RS->addScavengingFrameIndex(FI);
}
+
+void XtensaFrameLowering::processFunctionBeforeFrameFinalized(
+ MachineFunction &MF, RegScavenger *RS) const {
+ const XtensaSubtarget &STI = MF.getSubtarget<XtensaSubtarget>();
+
+ // In WinABI mode add register scavenging slot
+ // FIXME: It may be posssible to add spill slot by more optimal way
+ if (STI.isWinABI() && (MF.getFrameInfo().estimateStackSize(MF) > 256)) {
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+ const TargetRegisterClass &RC = Xtensa::ARRegClass;
+ const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
+ unsigned Size = TRI.getSpillSize(RC);
+ Align Alignment = TRI.getSpillAlign(RC);
+ RS->addScavengingFrameIndex(MFI.CreateStackObject(Size, Alignment, false));
+ }
+}
diff --git a/llvm/lib/Target/Xtensa/XtensaFrameLowering.h b/llvm/lib/Target/Xtensa/XtensaFrameLowering.h
index b112f069cd61..8eb44c493266 100644
--- a/llvm/lib/Target/Xtensa/XtensaFrameLowering.h
+++ b/llvm/lib/Target/Xtensa/XtensaFrameLowering.h
@@ -44,6 +44,9 @@ public:
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
RegScavenger *RS) const override;
+
+ void processFunctionBeforeFrameFinalized(MachineFunction &MF,
+ RegScavenger *RS) const override;
};
} // namespace llvm
--
2.40.1