Skip to content
Permalink
Browse files

Custom lower store to custom store node

  • Loading branch information...
reSHARMA committed Jul 31, 2019
1 parent 95ecd05 commit e72fe7880f5eb459093a3d21eda5c3d162e26df1
Showing with 42 additions and 0 deletions.
  1. +42 −0 RISCVISelLowering.cpp
@@ -115,6 +115,14 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,

setOperationAction(ISD::GlobalAddress, MVT::i64, Custom);

// We need not lower for all return type, remove i32 and i64
// store node never returns i32/i64? TODO: Test with a build
setOperationAction(ISD::STORE, MVT::i32, Custom);
setOperationAction(ISD::STORE, MVT::Other, Custom);
setOperationAction(ISD::STORE, MVT::i64, Custom);

setOperationAction(ISD::UNDEF, MVT::i64, Custom);

ISD::CondCode FPCCToExtend[] = {
ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETO, ISD::SETUEQ,
ISD::SETUGT, ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE,
@@ -336,6 +344,40 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
return lowerFRAMEADDR(Op, DAG);
case ISD::RETURNADDR:
return lowerRETURNADDR(Op, DAG);
case ISD::STORE: {
StoreSDNode *SD = cast<StoreSDNode>(Op);
SDValue AddrPair = SD->getBasePtr();
SDVTList VTList = DAG.getVTList(MVT::Other);
SDValue Value = SD->getValue(), Chain = SD->getChain();
SDLoc DL(SD);
if (AddrPair.getOpcode() == ISD::BUILD_PAIR) {
SDValue Hi =
DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, AddrPair,
DAG.getConstant(0, DL, MVT::i32));
SDValue Lo =
DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32, AddrPair,
DAG.getConstant(1, DL, MVT::i32));
SDValue Ops[] = {Value, Hi, Lo, Chain};
SDValue newStore = SDValue(
DAG.getMachineNode(RISCV::CUS_STORE, DL, VTList, Ops), 0);
return newStore;
}
if (AddrPair.getSimpleValueType() == MVT::i64) {
SDValue doubleAddr = AddrPair.getValue(0);
SDValue Zero = DAG.getConstant(0, DL, MVT::i32);
SDValue One = DAG.getConstant(1, DL, MVT::i32);
SDValue Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32,
doubleAddr, Zero);
SDValue Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, MVT::i32,
doubleAddr, One);
SDValue Ops[] = {Value, Hi, Lo, Chain};
SDValue newStore = SDValue(
DAG.getMachineNode(RISCV::CUS_STORE, DL, VTList, Ops), 0);
return newStore;
}
return Op;
break;
}
}
}

0 comments on commit e72fe78

Please sign in to comment.
You can’t perform that action at this time.