[llvm-branch-commits] [llvm] 546ba87 - [RISCV][llvm] Refactor unpackFromMemLoc to use convertLocVTToValVT. NFC (#175969)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 15 10:50:26 PST 2026
Author: Brandon Wu
Date: 2026-01-16T02:50:01+08:00
New Revision: 546ba870f789669f14ccbc63a2a2b0e3593c911c
URL: https://github.com/llvm/llvm-project/commit/546ba870f789669f14ccbc63a2a2b0e3593c911c
DIFF: https://github.com/llvm/llvm-project/commit/546ba870f789669f14ccbc63a2a2b0e3593c911c.diff
LOG: [RISCV][llvm] Refactor unpackFromMemLoc to use convertLocVTToValVT. NFC (#175969)
Simplify unpackFromMemLoc to use convertLocVTToValVT for handling
LocInfo conversions, making it consistent with unpackFromRegLoc.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index a6babaf329043..f982ccdf17bad 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -23710,36 +23710,23 @@ static SDValue convertValVTToLocVT(SelectionDAG &DAG, SDValue Val,
// The caller is responsible for loading the full value if the argument is
// passed with CCValAssign::Indirect.
static SDValue unpackFromMemLoc(SelectionDAG &DAG, SDValue Chain,
- const CCValAssign &VA, const SDLoc &DL) {
+ const CCValAssign &VA, const SDLoc &DL,
+ const RISCVTargetLowering &TLI) {
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo &MFI = MF.getFrameInfo();
EVT LocVT = VA.getLocVT();
- EVT ValVT = VA.getValVT();
EVT PtrVT = MVT::getIntegerVT(DAG.getDataLayout().getPointerSizeInBits(0));
- if (VA.getLocInfo() == CCValAssign::Indirect) {
- // When the value is a scalable vector, we save the pointer which points to
- // the scalable vector value in the stack. The ValVT will be the pointer
- // type, instead of the scalable vector type.
- ValVT = LocVT;
- }
- int FI = MFI.CreateFixedObject(ValVT.getStoreSize(), VA.getLocMemOffset(),
+ int FI = MFI.CreateFixedObject(LocVT.getStoreSize(), VA.getLocMemOffset(),
/*IsImmutable=*/true);
SDValue FIN = DAG.getFrameIndex(FI, PtrVT);
- SDValue Val;
+ SDValue Val = DAG.getLoad(
+ LocVT, DL, Chain, FIN,
+ MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI));
- ISD::LoadExtType ExtType = ISD::NON_EXTLOAD;
- switch (VA.getLocInfo()) {
- default:
- llvm_unreachable("Unexpected CCValAssign::LocInfo");
- case CCValAssign::Full:
- case CCValAssign::Indirect:
- case CCValAssign::BCvt:
- break;
- }
- Val = DAG.getExtLoad(
- ExtType, DL, LocVT, Chain, FIN,
- MachinePointerInfo::getFixedStack(DAG.getMachineFunction(), FI), ValVT);
- return Val;
+ if (VA.getLocInfo() == CCValAssign::Indirect)
+ return Val;
+
+ return convertLocVTToValVT(DAG, Val, VA, DL, TLI.getSubtarget());
}
static SDValue unpackF64OnRV32DSoftABI(SelectionDAG &DAG, SDValue Chain,
@@ -23887,7 +23874,7 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
} else if (VA.isRegLoc())
ArgValue = unpackFromRegLoc(DAG, Chain, VA, DL, Ins[InsIdx], *this);
else
- ArgValue = unpackFromMemLoc(DAG, Chain, VA, DL);
+ ArgValue = unpackFromMemLoc(DAG, Chain, VA, DL, *this);
if (VA.getLocInfo() == CCValAssign::Indirect) {
// If the original argument was split and passed by reference (e.g. i128
More information about the llvm-branch-commits
mailing list