Skip to content

Commit

Permalink
Custom lower store to custom store node
Browse files Browse the repository at this point in the history
  • Loading branch information
reSHARMA committed Jul 31, 2019
1 parent 95ecd05 commit e72fe78
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions RISCVISelLowering.cpp
Expand Up @@ -115,6 +115,14 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,


setOperationAction(ISD::GlobalAddress, MVT::i64, Custom); 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::CondCode FPCCToExtend[] = {
ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETO, ISD::SETUEQ, ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETO, ISD::SETUEQ,
ISD::SETUGT, ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE, ISD::SETUGT, ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE,
Expand Down Expand Up @@ -336,6 +344,40 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
return lowerFRAMEADDR(Op, DAG); return lowerFRAMEADDR(Op, DAG);
case ISD::RETURNADDR: case ISD::RETURNADDR:
return lowerRETURNADDR(Op, DAG); 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;
}
} }
} }


Expand Down

0 comments on commit e72fe78

Please sign in to comment.