[llvm] [RISCV] Support the large code model. (PR #70308)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 23:52:35 PDT 2024
================
@@ -7300,6 +7301,38 @@ static SDValue getTargetNode(JumpTableSDNode *N, const SDLoc &DL, EVT Ty,
return DAG.getTargetJumpTable(N->getIndex(), Ty, Flags);
}
+static SDValue getLargeGlobalAddress(GlobalAddressSDNode *N, SDLoc DL, EVT Ty,
+ SelectionDAG &DAG) {
+ RISCVConstantPoolValue *CPV = RISCVConstantPoolValue::Create(N->getGlobal());
+ SDValue CPAddr = DAG.getTargetConstantPool(CPV, Ty, Align(8));
+ SDValue LC = DAG.getNode(RISCVISD::LLA, DL, Ty, CPAddr);
+ return DAG.getLoad(
+ Ty, DL, DAG.getEntryNode(), LC,
+ MachinePointerInfo::getConstantPool(DAG.getMachineFunction()));
+}
+
+static SDValue getLargeExternalSymbol(ExternalSymbolSDNode *N, SDLoc DL, EVT Ty,
+ SelectionDAG &DAG) {
+ RISCVConstantPoolValue *CPV =
+ RISCVConstantPoolValue::Create(*DAG.getContext(), N->getSymbol());
+ SDValue CPAddr = DAG.getTargetConstantPool(CPV, Ty, Align(8));
+ SDValue LC = DAG.getNode(RISCVISD::LLA, DL, Ty, CPAddr);
+ return DAG.getLoad(
+ Ty, DL, DAG.getEntryNode(), LC,
+ MachinePointerInfo::getConstantPool(DAG.getMachineFunction()));
+}
+
+template <class NodeTy>
+static SDValue getLargeAddr(NodeTy *N, SDLoc DL, EVT Ty, SelectionDAG &DAG) {
+ if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(N)) {
+ return getLargeGlobalAddress(G, DL, Ty, DAG);
+ } else {
----------------
topperc wrote:
No `else` after `return`
https://github.com/llvm/llvm-project/pull/70308
More information about the llvm-commits
mailing list