@@ -5239,10 +5239,6 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5239
5239
MachineRegisterInfo *MRI,
5240
5240
unsigned BinOpDepth,
5241
5241
LiveVariables *LV) const {
5242
- const TargetRegisterClass *RC = MRI->getRegClass (Reg);
5243
- if (RC == &PPC::G8RCRegClass || RC == &PPC::GPRC_and_GPRC_NOR0RegClass)
5244
- return ;
5245
-
5246
5242
MachineInstr *MI = MRI->getVRegDef (Reg);
5247
5243
if (!MI)
5248
5244
return ;
@@ -5255,9 +5251,6 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5255
5251
case PPC::PHI:
5256
5252
case PPC::ISEL:
5257
5253
if (BinOpDepth < MAX_BINOP_DEPTH) {
5258
- if (Opcode == PPC::OR || Opcode == PPC::ISEL)
5259
- // if (Opcode == PPC::OR)
5260
- IsRelplaceIntr = true ;
5261
5254
unsigned OperandEnd = 3 , OperandStride = 1 ;
5262
5255
if (Opcode == PPC::PHI) {
5263
5256
OperandEnd = MI->getNumOperands ();
@@ -5269,24 +5262,30 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5269
5262
Register SrcReg = MI->getOperand (I).getReg ();
5270
5263
replaceInstrAfterElimExt32To64 (SrcReg, MRI, BinOpDepth + 1 , LV);
5271
5264
}
5265
+
5266
+ if (Opcode == PPC::OR || Opcode == PPC::ISEL)
5267
+ IsRelplaceIntr = true ;
5268
+ else
5269
+ return ;
5272
5270
}
5273
5271
break ;
5274
5272
case PPC::COPY: {
5275
5273
Register SrcReg = MI->getOperand (1 ).getReg ();
5276
5274
const MachineFunction *MF = MI->getMF ();
5277
5275
if (!MF->getSubtarget <PPCSubtarget>().isSVR4ABI ()) {
5278
5276
replaceInstrAfterElimExt32To64 (SrcReg, MRI, BinOpDepth, LV);
5279
- break ;
5277
+ return ;
5280
5278
}
5281
5279
// From here on everything is SVR4ABI
5282
5280
if (MI->getParent ()->getBasicBlock () == &MF->getFunction ().getEntryBlock ())
5283
- break ;
5281
+ return ;
5284
5282
5285
5283
if (SrcReg != PPC::X3) {
5286
5284
replaceInstrAfterElimExt32To64 (SrcReg, MRI, BinOpDepth, LV);
5287
- break ;
5285
+ return ;
5288
5286
}
5289
- } break ;
5287
+ }
5288
+ return ;
5290
5289
case PPC::ORI:
5291
5290
case PPC::XORI:
5292
5291
case PPC::ORI8:
@@ -5295,22 +5294,27 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5295
5294
case PPC::XORIS:
5296
5295
case PPC::ORIS8:
5297
5296
case PPC::XORIS8: {
5297
+ Register SrcReg = MI->getOperand (1 ).getReg ();
5298
+ replaceInstrAfterElimExt32To64 (SrcReg, MRI, BinOpDepth, LV);
5299
+
5298
5300
if (Opcode == PPC::ORI || Opcode == PPC::XORI || Opcode == PPC::ORIS ||
5299
5301
Opcode == PPC::ORIS || Opcode == PPC::XORIS)
5300
5302
IsRelplaceIntr = true ;
5301
- Register SrcReg = MI-> getOperand ( 1 ). getReg ();
5302
- replaceInstrAfterElimExt32To64 (SrcReg, MRI, BinOpDepth, LV) ;
5303
+ else
5304
+ return ;
5303
5305
break ;
5304
5306
}
5305
5307
case PPC::AND:
5306
5308
case PPC::AND8: {
5307
5309
if (BinOpDepth < MAX_BINOP_DEPTH) {
5308
- if (Opcode == PPC::AND)
5309
- IsRelplaceIntr = true ;
5310
5310
Register SrcReg1 = MI->getOperand (1 ).getReg ();
5311
5311
replaceInstrAfterElimExt32To64 (SrcReg1, MRI, BinOpDepth, LV);
5312
5312
Register SrcReg2 = MI->getOperand (2 ).getReg ();
5313
5313
replaceInstrAfterElimExt32To64 (SrcReg2, MRI, BinOpDepth, LV);
5314
+ if (Opcode == PPC::AND)
5315
+ IsRelplaceIntr = true ;
5316
+ else
5317
+ return ;
5314
5318
}
5315
5319
break ;
5316
5320
}
@@ -5324,9 +5328,14 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5324
5328
!isOpZeroOfSubwordPreincLoad (Opcode)) ||
5325
5329
IsRelplaceIntr) {
5326
5330
5327
- // Fix Me: Most of the opcode of 64-bit instruction equal to the opcode of
5328
- // 32-bit version of same instruction plus one. But there are some
5329
- // exception: PPC::ANDC_rec, PPC::ANDI_rec, PPC::ANDIS_rec.
5331
+ const TargetRegisterClass *RC = MRI->getRegClass (Reg);
5332
+ assert (RC != &PPC::G8RCRegClass && RC != &PPC::G8RC_and_G8RC_NOX0RegClass &&
5333
+ " Must be 32-bit Register!" );
5334
+
5335
+ // Fix Me: Most of the pseudo-opcode of 64-bit instruction are equal to
5336
+ // the pseudo-opcode of the 32-bit version of the same instruction plus
5337
+ // one. However, there are some exceptions: PPC::ANDC_rec,
5338
+ // PPC::ANDI_rec, PPC::ANDIS_rec.
5330
5339
unsigned NewOpcode = Opcode + 1 ;
5331
5340
5332
5341
if (Opcode == PPC::ANDC_rec)
@@ -5350,8 +5359,11 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5350
5359
DebugLoc DL = MI->getDebugLoc ();
5351
5360
auto MBB = MI->getParent ();
5352
5361
5353
- // If the oprand of the instruction is Register which isPPC::GRCRegClass, we
5354
- // need to promot the Oprande to PPC::G8RCRegClass.
5362
+ // Since the pseudo-opcode of the instruction is promoted from 32-bit to
5363
+ // 64-bit, if the operand of the original instruction belongs to
5364
+ // PPC::GRCRegClass or PPC::GPRC_and_GPRC_NOR0RegClass, we need to promote
5365
+ // the operand to PPC::G8CRegClass or PPC::G8RC_and_G8RC_NOR0RegClass,
5366
+ // respectively.
5355
5367
DenseMap<unsigned , Register> PromoteRegs;
5356
5368
DenseMap<unsigned , Register> ReCalRegs;
5357
5369
for (unsigned i = 1 ; i < MI->getNumOperands (); i++) {
0 commit comments