@@ -188,6 +188,10 @@ XtensaTargetLowering::XtensaTargetLowering(const TargetMachine &tm,
188
188
setOperationAction (ISD::SRA_PARTS, MVT::i32 , Custom);
189
189
setOperationAction (ISD::SRL_PARTS, MVT::i32 , Custom);
190
190
191
+ // Funnel shifts
192
+ setOperationAction (ISD::FSHR, MVT::i32 , Custom);
193
+ setOperationAction (ISD::FSHL, MVT::i32 , Custom);
194
+
191
195
// Bit Manipulation
192
196
setOperationAction (ISD::BSWAP, MVT::i32 , Expand);
193
197
setOperationAction (ISD::BSWAP, MVT::i64 , Expand);
@@ -1674,6 +1678,23 @@ SDValue XtensaTargetLowering::LowerShiftRightParts(SDValue Op,
1674
1678
return DAG.getMergeValues (Ops, DL);
1675
1679
}
1676
1680
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
+
1677
1698
SDValue XtensaTargetLowering::LowerATOMIC_FENCE (SDValue Op,
1678
1699
SelectionDAG &DAG) const {
1679
1700
SDLoc DL (Op);
@@ -1728,6 +1749,9 @@ SDValue XtensaTargetLowering::LowerOperation(SDValue Op,
1728
1749
return LowerShiftRightParts (Op, DAG, true );
1729
1750
case ISD::SRL_PARTS:
1730
1751
return LowerShiftRightParts (Op, DAG, false );
1752
+ case ISD::FSHL:
1753
+ case ISD::FSHR:
1754
+ return LowerFunnelShift (Op, DAG);
1731
1755
default :
1732
1756
llvm_unreachable (" Unexpected node to lower" );
1733
1757
}
0 commit comments