@@ -262,153 +262,11 @@ const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
262
262
return AIXOffsets32;
263
263
}
264
264
265
- // / RemoveVRSaveCode - We have found that this function does not need any code
266
- // / to manipulate the VRSAVE register, even though it uses vector registers.
267
- // / This can happen when the only registers used are known to be live in or out
268
- // / of the function. Remove all of the VRSAVE related code from the function.
269
- // / FIXME: The removal of the code results in a compile failure at -O0 when the
270
- // / function contains a function call, as the GPR containing original VRSAVE
271
- // / contents is spilled and reloaded around the call. Without the prolog code,
272
- // / the spill instruction refers to an undefined register. This code needs
273
- // / to account for all uses of that GPR.
274
- static void RemoveVRSaveCode (MachineInstr &MI) {
275
- MachineBasicBlock *Entry = MI.getParent ();
276
- MachineFunction *MF = Entry->getParent ();
277
-
278
- // We know that the MTVRSAVE instruction immediately follows MI. Remove it.
279
- MachineBasicBlock::iterator MBBI = MI;
280
- ++MBBI;
281
- assert (MBBI != Entry->end () && MBBI->getOpcode () == PPC::MTVRSAVE);
282
- MBBI->eraseFromParent ();
283
-
284
- bool RemovedAllMTVRSAVEs = true ;
285
- // See if we can find and remove the MTVRSAVE instruction from all of the
286
- // epilog blocks.
287
- for (MachineFunction::iterator I = MF->begin (), E = MF->end (); I != E; ++I) {
288
- // If last instruction is a return instruction, add an epilogue
289
- if (I->isReturnBlock ()) {
290
- bool FoundIt = false ;
291
- for (MBBI = I->end (); MBBI != I->begin (); ) {
292
- --MBBI;
293
- if (MBBI->getOpcode () == PPC::MTVRSAVE) {
294
- MBBI->eraseFromParent (); // remove it.
295
- FoundIt = true ;
296
- break ;
297
- }
298
- }
299
- RemovedAllMTVRSAVEs &= FoundIt;
300
- }
301
- }
302
-
303
- // If we found and removed all MTVRSAVE instructions, remove the read of
304
- // VRSAVE as well.
305
- if (RemovedAllMTVRSAVEs) {
306
- MBBI = MI;
307
- assert (MBBI != Entry->begin () && " UPDATE_VRSAVE is first instr in block?" );
308
- --MBBI;
309
- assert (MBBI->getOpcode () == PPC::MFVRSAVE && " VRSAVE instrs wandered?" );
310
- MBBI->eraseFromParent ();
311
- }
312
-
313
- // Finally, nuke the UPDATE_VRSAVE.
314
- MI.eraseFromParent ();
315
- }
316
-
317
- // HandleVRSaveUpdate - MI is the UPDATE_VRSAVE instruction introduced by the
318
- // instruction selector. Based on the vector registers that have been used,
319
- // transform this into the appropriate ORI instruction.
320
- static void HandleVRSaveUpdate (MachineInstr &MI, const TargetInstrInfo &TII) {
321
- MachineFunction *MF = MI.getParent ()->getParent ();
322
- const TargetRegisterInfo *TRI = MF->getSubtarget ().getRegisterInfo ();
323
- DebugLoc dl = MI.getDebugLoc ();
324
-
325
- const MachineRegisterInfo &MRI = MF->getRegInfo ();
326
- unsigned UsedRegMask = 0 ;
327
- for (unsigned i = 0 ; i != 32 ; ++i)
328
- if (MRI.isPhysRegModified (VRRegNo[i]))
329
- UsedRegMask |= 1 << (31 -i);
330
-
331
- // Live in and live out values already must be in the mask, so don't bother
332
- // marking them.
333
- for (std::pair<unsigned , unsigned > LI : MF->getRegInfo ().liveins ()) {
334
- unsigned RegNo = TRI->getEncodingValue (LI.first );
335
- if (VRRegNo[RegNo] == LI.first ) // If this really is a vector reg.
336
- UsedRegMask &= ~(1 << (31 -RegNo)); // Doesn't need to be marked.
337
- }
338
-
339
- // Live out registers appear as use operands on return instructions.
340
- for (MachineFunction::const_iterator BI = MF->begin (), BE = MF->end ();
341
- UsedRegMask != 0 && BI != BE; ++BI) {
342
- const MachineBasicBlock &MBB = *BI;
343
- if (!MBB.isReturnBlock ())
344
- continue ;
345
- const MachineInstr &Ret = MBB.back ();
346
- for (unsigned I = 0 , E = Ret.getNumOperands (); I != E; ++I) {
347
- const MachineOperand &MO = Ret.getOperand (I);
348
- if (!MO.isReg () || !PPC::VRRCRegClass.contains (MO.getReg ()))
349
- continue ;
350
- unsigned RegNo = TRI->getEncodingValue (MO.getReg ());
351
- UsedRegMask &= ~(1 << (31 -RegNo));
352
- }
353
- }
354
-
355
- // If no registers are used, turn this into a copy.
356
- if (UsedRegMask == 0 ) {
357
- // Remove all VRSAVE code.
358
- RemoveVRSaveCode (MI);
359
- return ;
360
- }
361
-
362
- Register SrcReg = MI.getOperand (1 ).getReg ();
363
- Register DstReg = MI.getOperand (0 ).getReg ();
364
-
365
- if ((UsedRegMask & 0xFFFF ) == UsedRegMask) {
366
- if (DstReg != SrcReg)
367
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORI), DstReg)
368
- .addReg (SrcReg)
369
- .addImm (UsedRegMask);
370
- else
371
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORI), DstReg)
372
- .addReg (SrcReg, RegState::Kill)
373
- .addImm (UsedRegMask);
374
- } else if ((UsedRegMask & 0xFFFF0000 ) == UsedRegMask) {
375
- if (DstReg != SrcReg)
376
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORIS), DstReg)
377
- .addReg (SrcReg)
378
- .addImm (UsedRegMask >> 16 );
379
- else
380
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORIS), DstReg)
381
- .addReg (SrcReg, RegState::Kill)
382
- .addImm (UsedRegMask >> 16 );
383
- } else {
384
- if (DstReg != SrcReg)
385
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORIS), DstReg)
386
- .addReg (SrcReg)
387
- .addImm (UsedRegMask >> 16 );
388
- else
389
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORIS), DstReg)
390
- .addReg (SrcReg, RegState::Kill)
391
- .addImm (UsedRegMask >> 16 );
392
-
393
- BuildMI (*MI.getParent (), MI, dl, TII.get (PPC::ORI), DstReg)
394
- .addReg (DstReg, RegState::Kill)
395
- .addImm (UsedRegMask & 0xFFFF );
396
- }
397
-
398
- // Remove the old UPDATE_VRSAVE instruction.
399
- MI.eraseFromParent ();
400
- }
401
-
402
265
static bool spillsCR (const MachineFunction &MF) {
403
266
const PPCFunctionInfo *FuncInfo = MF.getInfo <PPCFunctionInfo>();
404
267
return FuncInfo->isCRSpilled ();
405
268
}
406
269
407
- static bool spillsVRSAVE (const MachineFunction &MF) {
408
- const PPCFunctionInfo *FuncInfo = MF.getInfo <PPCFunctionInfo>();
409
- return FuncInfo->isVRSAVESpilled ();
410
- }
411
-
412
270
static bool hasSpills (const MachineFunction &MF) {
413
271
const PPCFunctionInfo *FuncInfo = MF.getInfo <PPCFunctionInfo>();
414
272
return FuncInfo->hasSpills ();
@@ -474,7 +332,7 @@ PPCFrameLowering::determineFrameLayout(const MachineFunction &MF,
474
332
!FI->mustSaveTOC () && // No need to save TOC.
475
333
!RegInfo->hasBasePointer (MF); // No special alignment.
476
334
477
- // Note: for PPC32 SVR4ABI (Non-DarwinABI) , we can still generate stackless
335
+ // Note: for PPC32 SVR4ABI, we can still generate stackless
478
336
// code if all local vars are reg-allocated.
479
337
bool FitsInRedZone = FrameSize <= Subtarget.getRedZoneSize ();
480
338
@@ -775,21 +633,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF,
775
633
bool isELFv2ABI = Subtarget.isELFv2ABI ();
776
634
assert ((isSVR4ABI || isAIXABI) && " Unsupported PPC ABI." );
777
635
778
- // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
779
- // process it.
780
- if (!isSVR4ABI)
781
- for (unsigned i = 0 ; MBBI != MBB.end (); ++i, ++MBBI) {
782
- if (MBBI->getOpcode () == PPC::UPDATE_VRSAVE) {
783
- if (isAIXABI)
784
- report_fatal_error (" UPDATE_VRSAVE is unexpected on AIX." );
785
- HandleVRSaveUpdate (*MBBI, TII);
786
- break ;
787
- }
788
- }
789
-
790
- // Move MBBI back to the beginning of the prologue block.
791
- MBBI = MBB.begin ();
792
-
793
636
// Work out frame sizes.
794
637
unsigned FrameSize = determineFrameLayoutAndUpdate (MF);
795
638
int NegFrameSize = -FrameSize;
@@ -2035,7 +1878,6 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
2035
1878
bool HasGPSaveArea = false ;
2036
1879
bool HasG8SaveArea = false ;
2037
1880
bool HasFPSaveArea = false ;
2038
- bool HasVRSAVESaveArea = false ;
2039
1881
bool HasVRSaveArea = false ;
2040
1882
2041
1883
SmallVector<CalleeSavedInfo, 18 > GPRegs;
@@ -2075,8 +1917,6 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
2075
1917
} else if (PPC::CRBITRCRegClass.contains (Reg) ||
2076
1918
PPC::CRRCRegClass.contains (Reg)) {
2077
1919
; // do nothing, as we already know whether CRs are spilled
2078
- } else if (PPC::VRSAVERCRegClass.contains (Reg)) {
2079
- HasVRSAVESaveArea = true ;
2080
1920
} else if (PPC::VRRCRegClass.contains (Reg) ||
2081
1921
PPC::SPERCRegClass.contains (Reg)) {
2082
1922
// Altivec and SPE are mutually exclusive, but have the same stack
@@ -2199,23 +2039,6 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
2199
2039
LowerBound -= 4 ; // The CR save area is always 4 bytes long.
2200
2040
}
2201
2041
2202
- if (HasVRSAVESaveArea) {
2203
- // FIXME SVR4: Is it actually possible to have multiple elements in CSI
2204
- // which have the VRSAVE register class?
2205
- // Adjust the frame index of the VRSAVE spill slot.
2206
- for (unsigned i = 0 , e = CSI.size (); i != e; ++i) {
2207
- unsigned Reg = CSI[i].getReg ();
2208
-
2209
- if (PPC::VRSAVERCRegClass.contains (Reg)) {
2210
- int FI = CSI[i].getFrameIdx ();
2211
-
2212
- MFI.setObjectOffset (FI, LowerBound + MFI.getObjectOffset (FI));
2213
- }
2214
- }
2215
-
2216
- LowerBound -= 4 ; // The VRSAVE save area is always 4 bytes long.
2217
- }
2218
-
2219
2042
// Both Altivec and SPE have the same alignment and padding requirements
2220
2043
// within the stack frame.
2221
2044
if (HasVRSaveArea) {
@@ -2255,8 +2078,8 @@ PPCFrameLowering::addScavengingSpillSlot(MachineFunction &MF,
2255
2078
// needed alignment padding.
2256
2079
unsigned StackSize = determineFrameLayout (MF, true );
2257
2080
MachineFrameInfo &MFI = MF.getFrameInfo ();
2258
- if (MFI.hasVarSizedObjects () || spillsCR (MF) || spillsVRSAVE (MF) ||
2259
- hasNonRISpills (MF) || (hasSpills (MF) && !isInt<16 >(StackSize))) {
2081
+ if (MFI.hasVarSizedObjects () || spillsCR (MF) || hasNonRISpills (MF) ||
2082
+ (hasSpills (MF) && !isInt<16 >(StackSize))) {
2260
2083
const TargetRegisterClass &GPRC = PPC::GPRCRegClass;
2261
2084
const TargetRegisterClass &G8RC = PPC::G8RCRegClass;
2262
2085
const TargetRegisterClass &RC = Subtarget.isPPC64 () ? G8RC : GPRC;
@@ -2270,7 +2093,7 @@ PPCFrameLowering::addScavengingSpillSlot(MachineFunction &MF,
2270
2093
MFI.hasVarSizedObjects () && MFI.getMaxAlign () > getStackAlign ();
2271
2094
2272
2095
// These kinds of spills might need two registers.
2273
- if (spillsCR (MF) || spillsVRSAVE (MF) || HasAlVars)
2096
+ if (spillsCR (MF) || HasAlVars)
2274
2097
RS->addScavengingFrameIndex (
2275
2098
MFI.CreateStackObject (Size, Alignment, false ));
2276
2099
}
@@ -2347,9 +2170,6 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
2347
2170
2348
2171
for (unsigned i = 0 , e = CSI.size (); i != e; ++i) {
2349
2172
unsigned Reg = CSI[i].getReg ();
2350
- // VRSAVE can appear here if, for example, @llvm.eh.unwind.init() is used.
2351
- if (Reg == PPC::VRSAVE)
2352
- continue ;
2353
2173
2354
2174
// CR2 through CR4 are the nonvolatile CR fields.
2355
2175
bool IsCRField = PPC::CR2 <= Reg && Reg <= PPC::CR4;
@@ -2514,10 +2334,6 @@ bool PPCFrameLowering::restoreCalleeSavedRegisters(
2514
2334
for (unsigned i = 0 , e = CSI.size (); i != e; ++i) {
2515
2335
unsigned Reg = CSI[i].getReg ();
2516
2336
2517
- // VRSAVE can appear here if, for example, @llvm.eh.unwind.init() is used.
2518
- if (Reg == PPC::VRSAVE)
2519
- continue ;
2520
-
2521
2337
if ((Reg == PPC::X2 || Reg == PPC::R2) && MustSaveTOC)
2522
2338
continue ;
2523
2339
0 commit comments