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();
}
// 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;
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();
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());
}
// 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;
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));