@@ -500,10 +500,15 @@ bool RISCVInstructionSelector::select(MachineInstr &MI) {
500
500
}
501
501
case TargetOpcode::G_BRJT: {
502
502
// FIXME: Move to legalization?
503
- unsigned EntrySize =
504
- MF. getJumpTableInfo () ->getEntrySize (MF.getDataLayout ());
503
+ const MachineJumpTableInfo *MJTI = MF. getJumpTableInfo ();
504
+ unsigned EntrySize = MJTI ->getEntrySize (MF.getDataLayout ());
505
505
assert ((EntrySize == 4 || (Subtarget->is64Bit () && EntrySize == 8 )) &&
506
506
" Unsupported jump-table entry size" );
507
+ assert (
508
+ (MJTI->getEntryKind () == MachineJumpTableInfo::EK_LabelDifference32 ||
509
+ MJTI->getEntryKind () == MachineJumpTableInfo::EK_Custom32 ||
510
+ MJTI->getEntryKind () == MachineJumpTableInfo::EK_BlockAddress) &&
511
+ " Unexpected jump-table entry kind" );
507
512
508
513
auto SLL =
509
514
MIB.buildInstr (RISCV::SLLI, {&RISCV::GPRRegClass}, {MI.getOperand (2 )})
@@ -523,11 +528,11 @@ bool RISCVInstructionSelector::select(MachineInstr &MI) {
523
528
.addImm (0 )
524
529
.addMemOperand (MF.getMachineMemOperand (
525
530
MachinePointerInfo::getJumpTable (MF), MachineMemOperand::MOLoad,
526
- EntrySize, Align (EntrySize )));
531
+ EntrySize, Align (MJTI-> getEntryAlignment (MF. getDataLayout ()) )));
527
532
if (!Dest.constrainAllUses (TII, TRI, RBI))
528
533
return false ;
529
534
530
- if (MF. getTarget (). isPositionIndependent () ) {
535
+ if (MJTI-> getEntryKind () == MachineJumpTableInfo::EK_LabelDifference32 ) {
531
536
Dest = MIB.buildInstr (RISCV::ADD, {&RISCV::GPRRegClass},
532
537
{Dest.getReg (0 ), MI.getOperand (0 )});
533
538
if (!Dest.constrainAllUses (TII, TRI, RBI))
0 commit comments