llvm.org GIT mirror llvm / e6913f3
[TargetLowering] expandUnalignedStore - cleanup EVT variables. NFCI. Avoid duplicated EVTs and rename Store/Load VTs to avoid -Wshadow warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359877 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 4 months ago
1 changed file(s) with 18 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
53245324 EVT VT = Val.getValueType();
53255325 int Alignment = ST->getAlignment();
53265326 auto &MF = DAG.getMachineFunction();
5327 EVT MemVT = ST->getMemoryVT();
5327 EVT StoreMemVT = ST->getMemoryVT();
53285328
53295329 SDLoc dl(ST);
5330 if (MemVT.isFloatingPoint() || MemVT.isVector()) {
5330 if (StoreMemVT.isFloatingPoint() || StoreMemVT.isVector()) {
53315331 EVT intVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits());
53325332 if (isTypeLegal(intVT)) {
53335333 if (!isOperationLegalOrCustom(ISD::STORE, intVT) &&
5334 MemVT.isVector()) {
5334 StoreMemVT.isVector()) {
53355335 // Scalarize the store and let the individual components be handled.
53365336 SDValue Result = scalarizeVectorStore(ST, DAG);
5337
53385337 return Result;
53395338 }
53405339 // Expand to a bitconvert of the value to the integer type of the
53475346 }
53485347 // Do a (aligned) store to a stack slot, then copy from the stack slot
53495348 // to the final destination using (unaligned) integer loads and stores.
5350 EVT StoredVT = ST->getMemoryVT();
5351 MVT RegVT =
5352 getRegisterType(*DAG.getContext(),
5353 EVT::getIntegerVT(*DAG.getContext(),
5354 StoredVT.getSizeInBits()));
5349 MVT RegVT = getRegisterType(
5350 *DAG.getContext(),
5351 EVT::getIntegerVT(*DAG.getContext(), StoreMemVT.getSizeInBits()));
53555352 EVT PtrVT = Ptr.getValueType();
5356 unsigned StoredBytes = StoredVT.getStoreSize();
5353 unsigned StoredBytes = StoreMemVT.getStoreSize();
53575354 unsigned RegBytes = RegVT.getSizeInBits() / 8;
53585355 unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes;
53595356
53605357 // Make sure the stack slot is also aligned for the register type.
5361 SDValue StackPtr = DAG.CreateStackTemporary(StoredVT, RegVT);
5358 SDValue StackPtr = DAG.CreateStackTemporary(StoreMemVT, RegVT);
53625359 auto FrameIndex = cast(StackPtr.getNode())->getIndex();
53635360
53645361 // Perform the original store, only redirected to the stack slot.
53655362 SDValue Store = DAG.getTruncStore(
53665363 Chain, dl, Val, StackPtr,
5367 MachinePointerInfo::getFixedStack(MF, FrameIndex, 0), StoredVT);
5364 MachinePointerInfo::getFixedStack(MF, FrameIndex, 0), StoreMemVT);
53685365
53695366 EVT StackPtrVT = StackPtr.getValueType();
53705367
53935390 // The last store may be partial. Do a truncating store. On big-endian
53945391 // machines this requires an extending load from the stack slot to ensure
53955392 // that the bits are in the right place.
5396 EVT MemVT = EVT::getIntegerVT(*DAG.getContext(),
5397 8 * (StoredBytes - Offset));
5393 EVT LoadMemVT =
5394 EVT::getIntegerVT(*DAG.getContext(), 8 * (StoredBytes - Offset));
53985395
53995396 // Load from the stack slot.
54005397 SDValue Load = DAG.getExtLoad(
54015398 ISD::EXTLOAD, dl, RegVT, Store, StackPtr,
5402 MachinePointerInfo::getFixedStack(MF, FrameIndex, Offset), MemVT);
5399 MachinePointerInfo::getFixedStack(MF, FrameIndex, Offset), LoadMemVT);
54035400
54045401 Stores.push_back(
54055402 DAG.getTruncStore(Load.getValue(1), dl, Load, Ptr,
5406 ST->getPointerInfo().getWithOffset(Offset), MemVT,
5403 ST->getPointerInfo().getWithOffset(Offset), LoadMemVT,
54075404 MinAlign(ST->getAlignment(), Offset),
54085405 ST->getMemOperand()->getFlags(), ST->getAAInfo()));
54095406 // The order of the stores doesn't matter - say it with a TokenFactor.
54115408 return Result;
54125409 }
54135410
5414 assert(ST->getMemoryVT().isInteger() &&
5415 !ST->getMemoryVT().isVector() &&
5411 assert(StoreMemVT.isInteger() && !StoreMemVT.isVector() &&
54165412 "Unaligned store of unknown type.");
54175413 // Get the half-size VT
5418 EVT NewStoredVT = ST->getMemoryVT().getHalfSizedIntegerVT(*DAG.getContext());
5414 EVT NewStoredVT = StoreMemVT.getHalfSizedIntegerVT(*DAG.getContext());
54195415 int NumBits = NewStoredVT.getSizeInBits();
54205416 int IncrementSize = NumBits / 8;
54215417
54225418 // Divide the stored value in two parts.
5423 SDValue ShiftAmount =
5424 DAG.getConstant(NumBits, dl, getShiftAmountTy(Val.getValueType(),
5425 DAG.getDataLayout()));
5419 SDValue ShiftAmount = DAG.getConstant(
5420 NumBits, dl, getShiftAmountTy(Val.getValueType(), DAG.getDataLayout()));
54265421 SDValue Lo = Val;
54275422 SDValue Hi = DAG.getNode(ISD::SRL, dl, VT, Val, ShiftAmount);
54285423
54415436 ST->getMemOperand()->getFlags(), ST->getAAInfo());
54425437
54435438 SDValue Result =
5444 DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Store1, Store2);
5439 DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Store1, Store2);
54455440 return Result;
54465441 }
54475442