@@ -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);
@@ -305,6 +305,8 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
305
305
return LowerBR_CC (Op, DAG);
306
306
case ISD::GlobalAddress:
307
307
return LowerGlobalAddress (Op, DAG);
308
+ case ISD::ConstantPool:
309
+ return LowerConstantPool (Op, DAG);
308
310
case ISD::SELECT_CC:
309
311
return LowerSELECT_CC (Op, DAG);
310
312
case ISD::DYNAMIC_STACKALLOC:
@@ -670,18 +672,41 @@ const char *BPFTargetLowering::getTargetNodeName(unsigned Opcode) const {
670
672
return nullptr ;
671
673
}
672
674
675
+ static SDValue getTargetNode (GlobalAddressSDNode *N, const SDLoc &DL, EVT Ty,
676
+ SelectionDAG &DAG, unsigned Flags) {
677
+ return DAG.getTargetGlobalAddress (N->getGlobal (), DL, Ty, 0 , Flags);
678
+ }
679
+
680
+ static SDValue getTargetNode (ConstantPoolSDNode *N, const SDLoc &DL, EVT Ty,
681
+ SelectionDAG &DAG, unsigned Flags) {
682
+ return DAG.getTargetConstantPool (N->getConstVal (), Ty, N->getAlign (),
683
+ N->getOffset (), Flags);
684
+ }
685
+
686
+ template <class NodeTy >
687
+ SDValue BPFTargetLowering::getAddr (NodeTy *N, SelectionDAG &DAG,
688
+ unsigned Flags) const {
689
+ SDLoc DL (N);
690
+
691
+ SDValue GA = getTargetNode (N, DL, MVT::i64 , DAG, Flags);
692
+
693
+ return DAG.getNode (BPFISD::Wrapper, DL, MVT::i64 , GA);
694
+ }
695
+
673
696
SDValue BPFTargetLowering::LowerGlobalAddress (SDValue Op,
674
697
SelectionDAG &DAG) const {
675
- auto *N = cast<GlobalAddressSDNode>(Op);
698
+ GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
676
699
if (N->getOffset () != 0 )
677
700
report_fatal_error (" invalid offset for global address: " +
678
701
Twine (N->getOffset ()));
702
+ return getAddr (N, DAG);
703
+ }
679
704
680
- SDLoc DL (Op);
681
- const GlobalValue *GV = N-> getGlobal ();
682
- SDValue GA = DAG. getTargetGlobalAddress (GV, DL, MVT:: i64 );
705
+ SDValue BPFTargetLowering::LowerConstantPool (SDValue Op,
706
+ SelectionDAG &DAG) const {
707
+ ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op );
683
708
684
- return DAG. getNode (BPFISD::Wrapper, DL, MVT:: i64 , GA );
709
+ return getAddr (N, DAG );
685
710
}
686
711
687
712
unsigned
0 commit comments