[llvm] r363137 - [XCore] LowerLOAD/LowerSTORE - Use allowsMemoryAccess wrapper. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 03:46:51 PDT 2019
Author: rksimon
Date: Wed Jun 12 03:46:50 2019
New Revision: 363137
URL: http://llvm.org/viewvc/llvm-project?rev=363137&view=rev
Log:
[XCore] LowerLOAD/LowerSTORE - Use allowsMemoryAccess wrapper. NFCI.
Noticed in D63075 - there was a allowsMisalignedMemoryAccesses call to check for unaligned loads and a check for aligned legal type loads - which is exactly what allowsMemoryAccess does.
Modified:
llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=363137&r1=363136&r2=363137&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Wed Jun 12 03:46:50 2019
@@ -406,23 +406,16 @@ static bool isWordAligned(SDValue Value,
return Known.countMinTrailingZeros() >= 2;
}
-SDValue XCoreTargetLowering::
-LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
+SDValue XCoreTargetLowering::LowerLOAD(SDValue Op, SelectionDAG &DAG) const {
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ LLVMContext &Context = *DAG.getContext();
LoadSDNode *LD = cast<LoadSDNode>(Op);
assert(LD->getExtensionType() == ISD::NON_EXTLOAD &&
"Unexpected extension type");
assert(LD->getMemoryVT() == MVT::i32 && "Unexpected load EVT");
- if (allowsMisalignedMemoryAccesses(LD->getMemoryVT(),
- LD->getAddressSpace(),
- LD->getAlignment()))
- return SDValue();
- auto &TD = DAG.getDataLayout();
- unsigned ABIAlignment = TD.getABITypeAlignment(
- LD->getMemoryVT().getTypeForEVT(*DAG.getContext()));
- // Leave aligned load alone.
- if (LD->getAlignment() >= ABIAlignment)
+ if (allowsMemoryAccess(Context, DAG.getDataLayout(), LD->getMemoryVT(),
+ *LD->getMemOperand()))
return SDValue();
SDValue Chain = LD->getChain();
@@ -469,7 +462,7 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG)
}
// Lower to a call to __misaligned_load(BasePtr).
- Type *IntPtrTy = TD.getIntPtrType(*DAG.getContext());
+ Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(Context);
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
@@ -489,23 +482,16 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG)
return DAG.getMergeValues(Ops, DL);
}
-SDValue XCoreTargetLowering::
-LowerSTORE(SDValue Op, SelectionDAG &DAG) const
-{
+SDValue XCoreTargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
+ LLVMContext &Context = *DAG.getContext();
StoreSDNode *ST = cast<StoreSDNode>(Op);
assert(!ST->isTruncatingStore() && "Unexpected store type");
assert(ST->getMemoryVT() == MVT::i32 && "Unexpected store EVT");
- if (allowsMisalignedMemoryAccesses(ST->getMemoryVT(),
- ST->getAddressSpace(),
- ST->getAlignment())) {
- return SDValue();
- }
- unsigned ABIAlignment = DAG.getDataLayout().getABITypeAlignment(
- ST->getMemoryVT().getTypeForEVT(*DAG.getContext()));
- // Leave aligned store alone.
- if (ST->getAlignment() >= ABIAlignment) {
+
+ if (allowsMemoryAccess(Context, DAG.getDataLayout(), ST->getMemoryVT(),
+ *ST->getMemOperand()))
return SDValue();
- }
+
SDValue Chain = ST->getChain();
SDValue BasePtr = ST->getBasePtr();
SDValue Value = ST->getValue();
@@ -514,7 +500,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG
if (ST->getAlignment() == 2) {
SDValue Low = Value;
SDValue High = DAG.getNode(ISD::SRL, dl, MVT::i32, Value,
- DAG.getConstant(16, dl, MVT::i32));
+ DAG.getConstant(16, dl, MVT::i32));
SDValue StoreLow = DAG.getTruncStore(
Chain, dl, Low, BasePtr, ST->getPointerInfo(), MVT::i16,
/* Alignment = */ 2, ST->getMemOperand()->getFlags());
@@ -527,7 +513,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG
}
// Lower to a call to __misaligned_store(BasePtr, Value).
- Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
+ Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(Context);
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
@@ -540,7 +526,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG
TargetLowering::CallLoweringInfo CLI(DAG);
CLI.setDebugLoc(dl).setChain(Chain).setCallee(
- CallingConv::C, Type::getVoidTy(*DAG.getContext()),
+ CallingConv::C, Type::getVoidTy(Context),
DAG.getExternalSymbol("__misaligned_store",
getPointerTy(DAG.getDataLayout())),
std::move(Args));
More information about the llvm-commits
mailing list