|
14 | 14 | #include "SparcInstrInfo.h"
|
15 | 15 | #include "SparcMachineFunctionInfo.h"
|
16 | 16 | #include "SparcSubtarget.h"
|
| 17 | +#include "llvm/CodeGen/CFIInstBuilder.h" |
17 | 18 | #include "llvm/CodeGen/MachineFrameInfo.h"
|
18 | 19 | #include "llvm/CodeGen/MachineFunction.h"
|
19 | 20 | #include "llvm/CodeGen/MachineInstrBuilder.h"
|
@@ -88,14 +89,7 @@ void SparcFrameLowering::emitPrologue(MachineFunction &MF,
|
88 | 89 | assert(&MF.front() == &MBB && "Shrink-wrapping not yet supported");
|
89 | 90 | MachineFrameInfo &MFI = MF.getFrameInfo();
|
90 | 91 | const SparcSubtarget &Subtarget = MF.getSubtarget<SparcSubtarget>();
|
91 |
| - const SparcInstrInfo &TII = |
92 |
| - *static_cast<const SparcInstrInfo *>(Subtarget.getInstrInfo()); |
93 |
| - const SparcRegisterInfo &RegInfo = |
94 |
| - *static_cast<const SparcRegisterInfo *>(Subtarget.getRegisterInfo()); |
95 | 92 | MachineBasicBlock::iterator MBBI = MBB.begin();
|
96 |
| - // Debug location must be unknown since the first debug location is used |
97 |
| - // to determine the end of the prologue. |
98 |
| - DebugLoc dl; |
99 | 93 |
|
100 | 94 | // Get the number of bytes to allocate from the FrameInfo
|
101 | 95 | int NumBytes = (int) MFI.getStackSize();
|
@@ -141,26 +135,12 @@ void SparcFrameLowering::emitPrologue(MachineFunction &MF,
|
141 | 135 |
|
142 | 136 | emitSPAdjustment(MF, MBB, MBBI, -NumBytes, SAVErr, SAVEri);
|
143 | 137 |
|
144 |
| - unsigned regFP = RegInfo.getDwarfRegNum(SP::I6, true); |
145 |
| - |
146 |
| - // Emit ".cfi_def_cfa_register 30". |
147 |
| - unsigned CFIIndex = |
148 |
| - MF.addFrameInst(MCCFIInstruction::createDefCfaRegister(nullptr, regFP)); |
149 |
| - BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) |
150 |
| - .addCFIIndex(CFIIndex); |
151 |
| - |
152 |
| - // Emit ".cfi_window_save". |
153 |
| - CFIIndex = MF.addFrameInst(MCCFIInstruction::createWindowSave(nullptr)); |
154 |
| - BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) |
155 |
| - .addCFIIndex(CFIIndex); |
156 |
| - |
157 |
| - unsigned regInRA = RegInfo.getDwarfRegNum(SP::I7, true); |
158 |
| - unsigned regOutRA = RegInfo.getDwarfRegNum(SP::O7, true); |
159 |
| - // Emit ".cfi_register 15, 31". |
160 |
| - CFIIndex = MF.addFrameInst( |
161 |
| - MCCFIInstruction::createRegister(nullptr, regOutRA, regInRA)); |
162 |
| - BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) |
163 |
| - .addCFIIndex(CFIIndex); |
| 138 | + if (MF.needsFrameMoves()) { |
| 139 | + CFIInstBuilder CFIBuilder(MBB, MBBI, MachineInstr::NoFlags); |
| 140 | + CFIBuilder.buildDefCFARegister(SP::I6); |
| 141 | + CFIBuilder.buildWindowSave(); |
| 142 | + CFIBuilder.buildRegister(SP::O7, SP::I7); |
| 143 | + } |
164 | 144 | }
|
165 | 145 |
|
166 | 146 | MachineBasicBlock::iterator SparcFrameLowering::
|
|
0 commit comments