@@ -69,7 +69,7 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
69
69
setOperationAction (ISD::BRIND, MVT::Other, Expand);
70
70
setOperationAction (ISD::BRCOND, MVT::Other, Expand);
71
71
72
- setOperationAction (ISD::GlobalAddress, MVT::i64 , Custom);
72
+ setOperationAction ({ ISD::GlobalAddress, ISD::ConstantPool} , MVT::i64 , Custom);
73
73
74
74
setOperationAction (ISD::DYNAMIC_STACKALLOC, MVT::i64 , Custom);
75
75
setOperationAction (ISD::STACKSAVE, MVT::Other, Expand);
@@ -308,6 +308,8 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
308
308
return LowerBR_CC (Op, DAG);
309
309
case ISD::GlobalAddress:
310
310
return LowerGlobalAddress (Op, DAG);
311
+ case ISD::ConstantPool:
312
+ return LowerConstantPool (Op, DAG);
311
313
case ISD::SELECT_CC:
312
314
return LowerSELECT_CC (Op, DAG);
313
315
case ISD::SDIV:
@@ -691,18 +693,41 @@ const char *BPFTargetLowering::getTargetNodeName(unsigned Opcode) const {
691
693
return nullptr ;
692
694
}
693
695
696
+ static SDValue getTargetNode (GlobalAddressSDNode *N, const SDLoc &DL, EVT Ty,
697
+ SelectionDAG &DAG, unsigned Flags) {
698
+ return DAG.getTargetGlobalAddress (N->getGlobal (), DL, Ty, 0 , Flags);
699
+ }
700
+
701
+ static SDValue getTargetNode (ConstantPoolSDNode *N, const SDLoc &DL, EVT Ty,
702
+ SelectionDAG &DAG, unsigned Flags) {
703
+ return DAG.getTargetConstantPool (N->getConstVal (), Ty, N->getAlign (),
704
+ N->getOffset (), Flags);
705
+ }
706
+
707
+ template <class NodeTy >
708
+ SDValue BPFTargetLowering::getAddr (NodeTy *N, SelectionDAG &DAG,
709
+ unsigned Flags) const {
710
+ SDLoc DL (N);
711
+
712
+ SDValue GA = getTargetNode (N, DL, MVT::i64 , DAG, Flags);
713
+
714
+ return DAG.getNode (BPFISD::Wrapper, DL, MVT::i64 , GA);
715
+ }
716
+
694
717
SDValue BPFTargetLowering::LowerGlobalAddress (SDValue Op,
695
718
SelectionDAG &DAG) const {
696
- auto *N = cast<GlobalAddressSDNode>(Op);
719
+ GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
697
720
if (N->getOffset () != 0 )
698
721
report_fatal_error (" invalid offset for global address: " +
699
722
Twine (N->getOffset ()));
723
+ return getAddr (N, DAG);
724
+ }
700
725
701
- SDLoc DL (Op);
702
- const GlobalValue *GV = N-> getGlobal ();
703
- SDValue GA = DAG. getTargetGlobalAddress (GV, DL, MVT:: i64 );
726
+ SDValue BPFTargetLowering::LowerConstantPool (SDValue Op,
727
+ SelectionDAG &DAG) const {
728
+ ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op );
704
729
705
- return DAG. getNode (BPFISD::Wrapper, DL, MVT:: i64 , GA );
730
+ return getAddr (N, DAG );
706
731
}
707
732
708
733
unsigned
0 commit comments