[PATCH] D57122: Add copyWithSizeAndOffset to MMOs for splitting
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 23 14:49:57 PST 2019
arsenm created this revision.
arsenm added reviewers: dsanders, volkan, aemerson, paquette, aditya_nandakumar.
Herald added a subscriber: wdng.
https://reviews.llvm.org/D57122
Files:
include/llvm/CodeGen/MachineMemOperand.h
lib/CodeGen/GlobalISel/LegalizerHelper.cpp
lib/CodeGen/MachineOperand.cpp
Index: lib/CodeGen/MachineOperand.cpp
===================================================================
--- lib/CodeGen/MachineOperand.cpp
+++ lib/CodeGen/MachineOperand.cpp
@@ -1004,6 +1004,14 @@
assert(getFailureOrdering() == FailureOrdering && "Value truncated");
}
+MachineMemOperand *
+MachineMemOperand::copyWithSizeAndOffset(MachineFunction &MF, unsigned Size,
+ unsigned Offset) const {
+ return MF.getMachineMemOperand(getPointerInfo().getWithOffset(Offset),
+ getFlags(), Size,
+ MinAlign(getAlignment(), Offset));
+}
+
/// Profile - Gather unique data for the object.
///
void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
Index: lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -493,16 +493,13 @@
for (int i = 0; i < NumParts; ++i) {
unsigned DstReg = MRI.createGenericVirtualRegister(NarrowTy);
unsigned SrcReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO = MMO.copyWithSizeAndOffset(
+ MIRBuilder.getMF(), NarrowSize / 8, Offset);
MIRBuilder.materializeGEP(SrcReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildLoad(DstReg, SrcReg, *SplitMMO);
@@ -565,16 +562,13 @@
for (int i = 0; i < NumParts; ++i) {
unsigned DstReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO =
+ MMO.copyWithSizeAndOffset(MIRBuilder.getMF(), NarrowSize / 8, Offset);
MIRBuilder.materializeGEP(DstReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildStore(SrcRegs[i], DstReg, *SplitMMO);
}
Index: include/llvm/CodeGen/MachineMemOperand.h
===================================================================
--- include/llvm/CodeGen/MachineMemOperand.h
+++ include/llvm/CodeGen/MachineMemOperand.h
@@ -286,6 +286,10 @@
void setValue(const PseudoSourceValue *NewSV) { PtrInfo.V = NewSV; }
void setOffset(int64_t NewOffset) { PtrInfo.Offset = NewOffset; }
+ /// Create new MachineMemOperand that represents a \p Size byte subset located
+ /// at \p Offset.
+ MachineMemOperand *copyWithSizeAndOffset(MachineFunction &MF, unsigned Size,
+ unsigned Offset) const;
/// Profile - Gather unique data for the object.
///
void Profile(FoldingSetNodeID &ID) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57122.183187.patch
Type: text/x-patch
Size: 3598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190123/9c6da928/attachment.bin>
More information about the llvm-commits
mailing list