[llvm] [SPARC] Use hardware byteswapper when we have V9 (PR #191720)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 21:57:02 PDT 2026
================
@@ -3001,6 +3004,37 @@ static SDValue LowerF128Load(SDValue Op, SelectionDAG &DAG)
return DAG.getMergeValues(Ops, dl);
}
+SDValue SparcTargetLowering::LowerBSWAP(SDValue Op, SelectionDAG &DAG) const {
+ // We don't have an in-register bswap, so expand bswap(x) into
+ // load(store-swapped(x)). The reason the swap is done during the store is
+ // that on some implementations (mainly older ones) ASI-tagged memory
+ // operations are not pipelined, and generally stores finish faster than
+ // loads.
+
+ MachineFunction &MF = DAG.getMachineFunction();
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+ auto PtrVT = getPointerTy(DAG.getDataLayout());
+ SDValue Chain = DAG.getEntryNode();
+ bool IsLittleEndian = DAG.getDataLayout().isLittleEndian();
+ SDLoc DL(Op);
+
+ SDValue BSwapOp = Op.getOperand(0);
+ EVT BSwapVT = BSwapOp.getValueType();
+
+ // Create a stack object to serve as temporary storage.
+ int BSwapFI = MFI.CreateStackObject(BSwapVT.getStoreSize(), Align(8), false);
+ SDValue BSwapPtr = DAG.getFrameIndex(BSwapFI, PtrVT);
----------------
koachan wrote:
This is just for a temporary space where the swapped result will be stored.
I suppose something like TmpFI/Ptr would work better here?
https://github.com/llvm/llvm-project/pull/191720
More information about the llvm-commits
mailing list