@@ -989,6 +989,8 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
989
989
setOperationAction (ISD::FLOG2, {MVT::v2f16, MVT::v2bf16}, Expand);
990
990
}
991
991
992
+ setOperationAction (ISD::ADDRSPACECAST, {MVT::i32 , MVT::i64 }, Custom);
993
+
992
994
// No FPOW or FREM in PTX.
993
995
994
996
// Now deduce the information based on the above mentioned
@@ -2652,6 +2654,8 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
2652
2654
return SDValue ();
2653
2655
case ISD::FRAMEADDR:
2654
2656
return SDValue ();
2657
+ case ISD::ADDRSPACECAST:
2658
+ return LowerADDRSPACECAST (Op, DAG);
2655
2659
case ISD::GlobalAddress:
2656
2660
return LowerGlobalAddress (Op, DAG);
2657
2661
case ISD::INTRINSIC_W_CHAIN:
@@ -2726,7 +2730,6 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
2726
2730
case ISD::FMUL:
2727
2731
// Used only for bf16 on SM80, where we select fma for non-ftz operation
2728
2732
return PromoteBinOpIfF32FTZ (Op, DAG);
2729
-
2730
2733
default :
2731
2734
llvm_unreachable (" Custom lowering not defined for operation" );
2732
2735
}
@@ -2767,6 +2770,22 @@ unsigned NVPTXTargetLowering::getJumpTableEncoding() const {
2767
2770
return MachineJumpTableInfo::EK_Inline;
2768
2771
}
2769
2772
2773
+ SDValue NVPTXTargetLowering::LowerADDRSPACECAST (SDValue Op, SelectionDAG &DAG) const {
2774
+ SDLoc DL (Op);
2775
+ AddrSpaceCastSDNode *N = cast<AddrSpaceCastSDNode>(Op.getNode ());
2776
+
2777
+ EVT OperandVT = Op.getOperand (0 ).getValueType ();
2778
+ unsigned SrcAS = N->getSrcAddressSpace ();
2779
+ EVT ResultVT = Op.getValueType ();
2780
+ unsigned DestAS = N->getDestAddressSpace ();
2781
+
2782
+ if (SrcAS == llvm::ADDRESS_SPACE_GENERIC || DestAS == llvm::ADDRESS_SPACE_GENERIC)
2783
+ return Op;
2784
+
2785
+ SDValue ToGeneric = DAG.getAddrSpaceCast (DL, OperandVT, Op.getOperand (0 ), SrcAS, llvm::ADDRESS_SPACE_GENERIC);
2786
+ return DAG.getAddrSpaceCast (DL, ResultVT, ToGeneric, llvm::ADDRESS_SPACE_GENERIC, DestAS);
2787
+ }
2788
+
2770
2789
// This function is almost a copy of SelectionDAG::expandVAArg().
2771
2790
// The only diff is that this one produces loads from local address space.
2772
2791
SDValue NVPTXTargetLowering::LowerVAARG (SDValue Op, SelectionDAG &DAG) const {
0 commit comments