@@ -379,18 +379,15 @@ class AArch64InstructionSelector : public InstructionSelector {
379
379
return selectAddrModeWRO (Root, Width / 8 );
380
380
}
381
381
382
- ComplexRendererFns selectShiftedRegister (MachineOperand &Root) const ;
382
+ ComplexRendererFns selectShiftedRegister (MachineOperand &Root,
383
+ bool AllowROR = false ) const ;
383
384
384
385
ComplexRendererFns selectArithShiftedRegister (MachineOperand &Root) const {
385
386
return selectShiftedRegister (Root);
386
387
}
387
388
388
389
ComplexRendererFns selectLogicalShiftedRegister (MachineOperand &Root) const {
389
- // TODO: selectShiftedRegister should allow for rotates on logical shifts.
390
- // For now, make them the same. The only difference between the two is that
391
- // logical shifts are allowed to fold in rotates. Otherwise, these are
392
- // functionally the same.
393
- return selectShiftedRegister (Root);
390
+ return selectShiftedRegister (Root, true );
394
391
}
395
392
396
393
// / Given an extend instruction, determine the correct shift-extend type for
@@ -6014,7 +6011,6 @@ AArch64InstructionSelector::selectAddrModeIndexed(MachineOperand &Root,
6014
6011
// / Given a shift instruction, return the correct shift type for that
6015
6012
// / instruction.
6016
6013
static AArch64_AM::ShiftExtendType getShiftTypeForInst (MachineInstr &MI) {
6017
- // TODO: Handle AArch64_AM::ROR
6018
6014
switch (MI.getOpcode ()) {
6019
6015
default :
6020
6016
return AArch64_AM::InvalidShiftExtend;
@@ -6024,30 +6020,31 @@ static AArch64_AM::ShiftExtendType getShiftTypeForInst(MachineInstr &MI) {
6024
6020
return AArch64_AM::LSR;
6025
6021
case TargetOpcode::G_ASHR:
6026
6022
return AArch64_AM::ASR;
6023
+ case TargetOpcode::G_ROTR:
6024
+ return AArch64_AM::ROR;
6027
6025
}
6028
6026
}
6029
6027
6030
6028
// / Select a "shifted register" operand. If the value is not shifted, set the
6031
6029
// / shift operand to a default value of "lsl 0".
6032
- // /
6033
- // / TODO: Allow shifted register to be rotated in logical instructions.
6034
6030
InstructionSelector::ComplexRendererFns
6035
- AArch64InstructionSelector::selectShiftedRegister (MachineOperand &Root) const {
6031
+ AArch64InstructionSelector::selectShiftedRegister (MachineOperand &Root,
6032
+ bool AllowROR) const {
6036
6033
if (!Root.isReg ())
6037
6034
return None;
6038
6035
MachineRegisterInfo &MRI =
6039
6036
Root.getParent ()->getParent ()->getParent ()->getRegInfo ();
6040
6037
6041
6038
// Check if the operand is defined by an instruction which corresponds to
6042
6039
// a ShiftExtendType. E.g. a G_SHL, G_LSHR, etc.
6043
- //
6044
- // TODO: Handle AArch64_AM::ROR for logical instructions.
6045
6040
MachineInstr *ShiftInst = MRI.getVRegDef (Root.getReg ());
6046
6041
if (!ShiftInst)
6047
6042
return None;
6048
6043
AArch64_AM::ShiftExtendType ShType = getShiftTypeForInst (*ShiftInst);
6049
6044
if (ShType == AArch64_AM::InvalidShiftExtend)
6050
6045
return None;
6046
+ if (ShType == AArch64_AM::ROR && !AllowROR)
6047
+ return None;
6051
6048
if (!isWorthFoldingIntoExtendedReg (*ShiftInst, MRI))
6052
6049
return None;
6053
6050
0 commit comments