@@ -5245,11 +5245,24 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5245
5245
5246
5246
unsigned Opcode = MI->getOpcode();
5247
5247
bool IsReplaceInstr = false;
5248
+ int NewOpcode = -1;
5249
+
5250
+ auto SetNewOpcode = [&](int NewOpc) {
5251
+ if (!IsReplaceInstr) {
5252
+ NewOpcode = NewOpc;
5253
+ IsReplaceInstr = true;
5254
+ }
5255
+ };
5256
+
5248
5257
switch (Opcode) {
5249
5258
case PPC::OR:
5259
+ SetNewOpcode(PPC::OR8);
5260
+ [[fallthrough]];
5261
+ case PPC::ISEL:
5262
+ SetNewOpcode(PPC::ISEL8);
5263
+ [[fallthrough]];
5250
5264
case PPC::OR8:
5251
5265
case PPC::PHI:
5252
- case PPC::ISEL:
5253
5266
if (BinOpDepth < MAX_BINOP_DEPTH) {
5254
5267
unsigned OperandEnd = 3, OperandStride = 1;
5255
5268
if (Opcode == PPC::PHI) {
@@ -5263,9 +5276,7 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5263
5276
replaceInstrAfterElimExt32To64(SrcReg, MRI, BinOpDepth + 1, LV);
5264
5277
}
5265
5278
5266
- if (Opcode == PPC::OR || Opcode == PPC::ISEL)
5267
- IsReplaceInstr = true;
5268
- else
5279
+ if (!IsReplaceInstr)
5269
5280
return;
5270
5281
}
5271
5282
break;
@@ -5287,37 +5298,60 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5287
5298
}
5288
5299
return;
5289
5300
case PPC::ORI:
5301
+ SetNewOpcode(PPC::ORI8);
5302
+ [[fallthrough]];
5290
5303
case PPC::XORI:
5291
- case PPC::ORI8:
5292
- case PPC::XORI8:
5304
+ SetNewOpcode( PPC::XORI8);
5305
+ [[fallthrough]];
5293
5306
case PPC::ORIS:
5307
+ SetNewOpcode(PPC::ORIS8);
5308
+ [[fallthrough]];
5294
5309
case PPC::XORIS:
5310
+ SetNewOpcode(PPC::XORIS8);
5311
+ [[fallthrough]];
5312
+ case PPC::ORI8:
5313
+ case PPC::XORI8:
5295
5314
case PPC::ORIS8:
5296
5315
case PPC::XORIS8: {
5297
5316
Register SrcReg = MI->getOperand(1).getReg();
5298
5317
replaceInstrAfterElimExt32To64(SrcReg, MRI, BinOpDepth, LV);
5299
5318
5300
- if (Opcode == PPC::ORI || Opcode == PPC::XORI || Opcode == PPC::ORIS ||
5301
- Opcode == PPC::ORIS || Opcode == PPC::XORIS)
5302
- IsReplaceInstr = true;
5303
- else
5319
+ if (!IsReplaceInstr)
5304
5320
return;
5305
5321
break;
5306
5322
}
5307
5323
case PPC::AND:
5324
+ SetNewOpcode(PPC::AND8);
5325
+ [[fallthrough]];
5308
5326
case PPC::AND8: {
5309
5327
if (BinOpDepth < MAX_BINOP_DEPTH) {
5310
5328
Register SrcReg1 = MI->getOperand(1).getReg();
5311
5329
replaceInstrAfterElimExt32To64(SrcReg1, MRI, BinOpDepth, LV);
5312
5330
Register SrcReg2 = MI->getOperand(2).getReg();
5313
5331
replaceInstrAfterElimExt32To64(SrcReg2, MRI, BinOpDepth, LV);
5314
- if (Opcode == PPC::AND)
5315
- IsReplaceInstr = true;
5316
- else
5332
+ if (!IsReplaceInstr)
5317
5333
return;
5318
5334
}
5319
5335
break;
5320
5336
}
5337
+ case PPC::RLWINM:
5338
+ SetNewOpcode(PPC::RLWINM8);
5339
+ break;
5340
+ case PPC::RLWINM_rec:
5341
+ SetNewOpcode(PPC::RLWINM8_rec);
5342
+ break;
5343
+ case PPC::RLWNM:
5344
+ SetNewOpcode(PPC ::RLWNM8);
5345
+ break;
5346
+ case PPC::RLWNM_rec:
5347
+ SetNewOpcode(PPC::RLWNM8_rec);
5348
+ break;
5349
+ case PPC::ANDC_rec:
5350
+ SetNewOpcode(PPC::ANDC8_rec);
5351
+ break;
5352
+ case PPC::ANDIS_rec:
5353
+ SetNewOpcode(PPC::ANDIS8_rec);
5354
+ break;
5321
5355
default:
5322
5356
break;
5323
5357
}
@@ -5332,18 +5366,11 @@ void PPCInstrInfo::replaceInstrAfterElimExt32To64(const Register &Reg,
5332
5366
assert(RC != &PPC::G8RCRegClass && RC != &PPC::G8RC_and_G8RC_NOX0RegClass &&
5333
5367
"Must be 32-bit Register!");
5334
5368
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.
5339
- unsigned NewOpcode = Opcode + 1;
5340
-
5341
- if (Opcode == PPC::ANDC_rec)
5342
- NewOpcode = PPC::ANDC8_rec;
5343
- if (Opcode == PPC::ANDI_rec)
5344
- NewOpcode = PPC::ANDI8_rec;
5345
- if (Opcode == PPC::ANDIS_rec)
5346
- NewOpcode = PPC::ANDIS8_rec;
5369
+ if (!IsReplaceInstr)
5370
+ NewOpcode = PPC::get64BitInstrFromSignedExt32BitInstr(Opcode);
5371
+
5372
+ assert(NewOpcode != -1 &&
5373
+ "Must have a 64-bit opcode to map the 32-bit opcode!");
5347
5374
5348
5375
const TargetRegisterInfo *TRI = MRI->getTargetRegisterInfo();
5349
5376
const MCInstrDesc &MCID = TII->get(NewOpcode);
0 commit comments