@@ -188,6 +188,10 @@ XtensaTargetLowering::XtensaTargetLowering(const TargetMachine &tm,
188188 setOperationAction (ISD::SRA_PARTS, MVT::i32 , Custom);
189189 setOperationAction (ISD::SRL_PARTS, MVT::i32 , Custom);
190190
191+ // Funnel shifts
192+ setOperationAction (ISD::FSHR, MVT::i32 , Custom);
193+ setOperationAction (ISD::FSHL, MVT::i32 , Custom);
194+
191195 // Bit Manipulation
192196 setOperationAction (ISD::BSWAP, MVT::i32 , Expand);
193197 setOperationAction (ISD::BSWAP, MVT::i64 , Expand);
@@ -1674,6 +1678,23 @@ SDValue XtensaTargetLowering::LowerShiftRightParts(SDValue Op,
16741678 return DAG.getMergeValues (Ops, DL);
16751679}
16761680
1681+ SDValue XtensaTargetLowering::LowerFunnelShift (SDValue Op,
1682+ SelectionDAG &DAG) const {
1683+ SDLoc DL (Op);
1684+ SDValue Op0 = Op.getOperand (0 );
1685+ SDValue Op1 = Op.getOperand (1 );
1686+ SDValue Shamt = Op.getOperand (2 );
1687+ MVT VT = Op.getSimpleValueType ();
1688+
1689+ bool IsFSHR = Op.getOpcode () == ISD::FSHR;
1690+ assert ((VT == MVT::i32 ) && " Unexpected funnel shift type!" );
1691+
1692+ SDValue SetSAR = DAG.getNode (IsFSHR ? XtensaISD::SSR : XtensaISD::SSL, DL,
1693+ MVT::Glue, Shamt);
1694+ return DAG.getNode (XtensaISD::SRC, DL, VT, IsFSHR ? Op0 : Op1,
1695+ IsFSHR ? Op1 : Op0, SetSAR);
1696+ }
1697+
16771698SDValue XtensaTargetLowering::LowerATOMIC_FENCE (SDValue Op,
16781699 SelectionDAG &DAG) const {
16791700 SDLoc DL (Op);
@@ -1728,6 +1749,9 @@ SDValue XtensaTargetLowering::LowerOperation(SDValue Op,
17281749 return LowerShiftRightParts (Op, DAG, true );
17291750 case ISD::SRL_PARTS:
17301751 return LowerShiftRightParts (Op, DAG, false );
1752+ case ISD::FSHL:
1753+ case ISD::FSHR:
1754+ return LowerFunnelShift (Op, DAG);
17311755 default :
17321756 llvm_unreachable (" Unexpected node to lower" );
17331757 }
0 commit comments