Skip to content

Commit 084e770

Browse files
committed
Start thinking of stack frames
1 parent 7532925 commit 084e770

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

llvm/lib/Target/SBF/SBFFrameLowering.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@ bool SBFFrameLowering::hasFPImpl(const MachineFunction &MF) const { return true;
2121

2222
void SBFFrameLowering::emitPrologue(MachineFunction &MF,
2323
MachineBasicBlock &MBB) const {
24-
if (!MF.getSubtarget<SBFSubtarget>().getHasDynamicFrames()) {
24+
const SBFSubtarget& Subtarget = MF.getSubtarget<SBFSubtarget>();
25+
if (!Subtarget.getHasDynamicFrames()) {
2526
return;
2627
}
28+
2729
MachineBasicBlock::iterator MBBI = MBB.begin();
2830
MachineFrameInfo &MFI = MF.getFrameInfo();
2931
int NumBytes = (int)MFI.getStackSize();
30-
if ((NumBytes || MF.getSubtarget<SBFSubtarget>().getHasStaticSyscalls()) &&
31-
MBBI != MBB.end()) {
32+
33+
if (NumBytes && MBBI != MBB.end()) {
3234
DebugLoc Dl = MBBI->getDebugLoc();
3335
const SBFInstrInfo &TII =
3436
*static_cast<const SBFInstrInfo *>(MF.getSubtarget().getInstrInfo());
37+
38+
if (Subtarget.isDynamicFramesV1())
39+
NumBytes = -NumBytes;
40+
3541
BuildMI(MBB, MBBI, Dl, TII.get(SBF::ADD_ri), SBF::R10)
3642
.addReg(SBF::R10)
37-
.addImm(-NumBytes);
43+
.addImm(NumBytes);
3844
}
3945
}
4046

llvm/lib/Target/SBF/SBFRegisterInfo.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,20 @@ int SBFRegisterInfo::resolveInternalFrameIndex(
167167

168168
if (SubTarget.getHasDynamicFrames() &&
169169
SBFFuncInfo->containsFrameIndex(FI)) {
170-
return -Offset;
170+
if (SubTarget.isDynamicFramesV1())
171+
return -Offset;
172+
173+
return Offset;
171174
}
172175

173176
Offset += Imm.value_or(0);
174177

175178
if (SubTarget.getHasDynamicFrames()) {
176-
return static_cast<int>(StackSize) + Offset;
179+
Offset += static_cast<int>(StackSize);
180+
if (SubTarget.isDynamicFramesV1())
181+
return Offset;
182+
183+
return -Offset;
177184
}
178185

179186
return Offset;

llvm/lib/Target/SBF/SBFSubtarget.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class SBFSubtarget : public SBFGenSubtargetInfo {
9292
// JMP32 support depends on ALU32 being enabled
9393
bool HasJmp32;
9494

95+
bool HasDynamicFramesV3;
96+
9597
std::unique_ptr<CallLowering> CallLoweringInfo;
9698
std::unique_ptr<InstructionSelector> InstSelector;
9799
std::unique_ptr<LegalizerInfo> Legalizer;
@@ -110,7 +112,12 @@ class SBFSubtarget : public SBFGenSubtargetInfo {
110112
// subtarget options. Definition of function is auto generated by tblgen.
111113
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
112114
bool getHasAlu32() const { return HasAlu32; }
113-
bool getHasDynamicFrames() const { return HasDynamicFrames; }
115+
bool getHasDynamicFrames() const {
116+
return HasDynamicFrames || HasDynamicFramesV3;
117+
}
118+
bool isDynamicFramesV1() const {
119+
return HasDynamicFrames;
120+
}
114121
bool getUseDwarfRIS() const { return UseDwarfRIS; }
115122
bool getDisableNeg() const { return DisableNeg; }
116123
bool getReverseSubImm() const { return ReverseSubImm; }

llvm/lib/Target/SBF/SBFTargetFeatures.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def FeatureAbiV2 : SubtargetFeature<"abi-v2", "IsAbiV2",
5555
def FeatureJmp32 : SubtargetFeature<"jmp-32", "HasJmp32", "true",
5656
"Enable the JMP32 instruction class">;
5757

58+
def FeatureDynamicFramesV3 : SubtargetFeature<"dynamic-frames-v3", "HasDynamicFramesV3", "true",
59+
"Enable dynamic frames in SBPFv3">;
60+
5861
class Proc<string Name, list<SubtargetFeature> Features>
5962
: Processor<Name, NoItineraries, Features>;
6063

0 commit comments

Comments
 (0)