@@ -65,10 +65,11 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
6565
6666 setOperationAction (ISD::BR_CC, MVT::i64 , Custom);
6767 setOperationAction (ISD::BR_JT, MVT::Other, Expand);
68- setOperationAction (ISD::BRIND, MVT::Other, Expand);
6968 setOperationAction (ISD::BRCOND, MVT::Other, Expand);
7069
71- setOperationAction ({ISD::GlobalAddress, ISD::ConstantPool}, MVT::i64 , Custom);
70+ setOperationAction ({ISD::GlobalAddress, ISD::ConstantPool, ISD::JumpTable,
71+ ISD::BlockAddress},
72+ MVT::i64 , Custom);
7273
7374 setOperationAction (ISD::DYNAMIC_STACKALLOC, MVT::i64 , Custom);
7475 setOperationAction (ISD::STACKSAVE, MVT::Other, Expand);
@@ -312,10 +313,14 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
312313 report_fatal_error (" unimplemented opcode: " + Twine (Op.getOpcode ()));
313314 case ISD::BR_CC:
314315 return LowerBR_CC (Op, DAG);
316+ case ISD::JumpTable:
317+ return LowerJumpTable (Op, DAG);
315318 case ISD::GlobalAddress:
316319 return LowerGlobalAddress (Op, DAG);
317320 case ISD::ConstantPool:
318321 return LowerConstantPool (Op, DAG);
322+ case ISD::BlockAddress:
323+ return LowerBlockAddress (Op, DAG);
319324 case ISD::SELECT_CC:
320325 return LowerSELECT_CC (Op, DAG);
321326 case ISD::SDIV:
@@ -726,6 +731,11 @@ SDValue BPFTargetLowering::LowerATOMIC_LOAD_STORE(SDValue Op,
726731 return Op;
727732}
728733
734+ SDValue BPFTargetLowering::LowerJumpTable (SDValue Op, SelectionDAG &DAG) const {
735+ JumpTableSDNode *N = cast<JumpTableSDNode>(Op);
736+ return getAddr (N, DAG);
737+ }
738+
729739const char *BPFTargetLowering::getTargetNodeName (unsigned Opcode) const {
730740 switch ((BPFISD::NodeType)Opcode) {
731741 case BPFISD::FIRST_NUMBER:
@@ -757,6 +767,17 @@ static SDValue getTargetNode(ConstantPoolSDNode *N, const SDLoc &DL, EVT Ty,
757767 N->getOffset (), Flags);
758768}
759769
770+ static SDValue getTargetNode (BlockAddressSDNode *N, const SDLoc &DL, EVT Ty,
771+ SelectionDAG &DAG, unsigned Flags) {
772+ return DAG.getTargetBlockAddress (N->getBlockAddress (), Ty, N->getOffset (),
773+ Flags);
774+ }
775+
776+ static SDValue getTargetNode (JumpTableSDNode *N, const SDLoc &DL, EVT Ty,
777+ SelectionDAG &DAG, unsigned Flags) {
778+ return DAG.getTargetJumpTable (N->getIndex (), Ty, Flags);
779+ }
780+
760781template <class NodeTy >
761782SDValue BPFTargetLowering::getAddr (NodeTy *N, SelectionDAG &DAG,
762783 unsigned Flags) const {
@@ -783,6 +804,12 @@ SDValue BPFTargetLowering::LowerConstantPool(SDValue Op,
783804 return getAddr (N, DAG);
784805}
785806
807+ SDValue BPFTargetLowering::LowerBlockAddress (SDValue Op,
808+ SelectionDAG &DAG) const {
809+ BlockAddressSDNode *N = cast<BlockAddressSDNode>(Op);
810+ return getAddr (N, DAG);
811+ }
812+
786813unsigned
787814BPFTargetLowering::EmitSubregExt (MachineInstr &MI, MachineBasicBlock *BB,
788815 unsigned Reg, bool isSigned) const {
0 commit comments