forked from OSchip/llvm-project
[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. llvm-svn: 363137
This commit is contained in:
parent
2c16bb8034
commit
32c1e73603
|
@ -406,23 +406,16 @@ static bool isWordAligned(SDValue Value, SelectionDAG &DAG)
|
|||
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) const {
|
|||
}
|
||||
|
||||
// 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) const {
|
|||
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())) {
|
||||
|
||||
if (allowsMemoryAccess(Context, DAG.getDataLayout(), ST->getMemoryVT(),
|
||||
*ST->getMemOperand()))
|
||||
return SDValue();
|
||||
}
|
||||
unsigned ABIAlignment = DAG.getDataLayout().getABITypeAlignment(
|
||||
ST->getMemoryVT().getTypeForEVT(*DAG.getContext()));
|
||||
// Leave aligned store alone.
|
||||
if (ST->getAlignment() >= ABIAlignment) {
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
SDValue Chain = ST->getChain();
|
||||
SDValue BasePtr = ST->getBasePtr();
|
||||
SDValue Value = ST->getValue();
|
||||
|
@ -514,7 +500,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG) const
|
|||
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) const
|
|||
}
|
||||
|
||||
// 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) const
|
|||
|
||||
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));
|
||||
|
|
Loading…
Reference in New Issue