@@ -489,6 +489,33 @@ class TargetRegisterClass;
489489 DAG.getNode (MipsISD::GPRel, DL, DAG.getVTList (Ty), GPRel));
490490 }
491491
492+ // This method creates the following nodes, which are necessary for
493+ // loading a dllimported symbol:
494+ //
495+ // (lw (add (shl(%high(sym), 16), %low(sym)))
496+ template <class NodeTy >
497+ SDValue getDllimportSymbol (NodeTy *N, const SDLoc &DL, EVT Ty,
498+ SelectionDAG &DAG) const {
499+ SDValue Hi =
500+ getTargetNode (N, Ty, DAG, MipsII::MO_ABS_HI | MipsII::MO_DLLIMPORT);
501+ SDValue Lo =
502+ getTargetNode (N, Ty, DAG, MipsII::MO_ABS_LO | MipsII::MO_DLLIMPORT);
503+ return DAG.getNode (ISD::ADD, DL, Ty, DAG.getNode (MipsISD::Lo, DL, Ty, Lo),
504+ DAG.getNode (MipsISD::Hi, DL, Ty, Hi));
505+ }
506+
507+ // This method creates the following nodes, which are necessary for
508+ // loading a dllimported global variable:
509+ //
510+ // (lw (lw (add (shl(%high(sym), 16), %low(sym))))
511+ template <class NodeTy >
512+ SDValue getDllimportVariable (NodeTy *N, const SDLoc &DL, EVT Ty,
513+ SelectionDAG &DAG, SDValue Chain,
514+ const MachinePointerInfo &PtrInfo) const {
515+ return DAG.getLoad (Ty, DL, Chain, getDllimportSymbol (N, DL, Ty, DAG),
516+ PtrInfo);
517+ }
518+
492519 // / This function fills Ops, which is the list of operands that will later
493520 // / be used when a function call node is created. It also generates
494521 // / copyToReg nodes to set up argument registers.
0 commit comments