diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index f50b48fefed..6789884c280 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -366,13 +366,6 @@ public: /// void DeleteMachineBasicBlock(MachineBasicBlock *MBB); - /// getMachineMemOperand - Allocate a new MachineMemOperand. - /// MachineMemOperands are owned by the MachineFunction and need not be - /// explicitly deallocated. - MachineMemOperand *getMachineMemOperand(const Value *v, unsigned f, - int64_t o, uint64_t s, - unsigned base_alignment); - /// getMachineMemOperand - Allocate a new MachineMemOperand. /// MachineMemOperands are owned by the MachineFunction and need not be /// explicitly deallocated. diff --git a/include/llvm/CodeGen/MachineMemOperand.h b/include/llvm/CodeGen/MachineMemOperand.h index 0386c19d7bf..0804f46ae92 100644 --- a/include/llvm/CodeGen/MachineMemOperand.h +++ b/include/llvm/CodeGen/MachineMemOperand.h @@ -37,7 +37,8 @@ struct MachinePointerInfo { /// Offset - This is an offset from the base Value*. int64_t Offset; - MachinePointerInfo(const Value *v, int64_t offset) : V(v), Offset(offset) {} + explicit MachinePointerInfo(const Value *v, int64_t offset = 0) + : V(v), Offset(offset) {} }; @@ -74,6 +75,8 @@ public: MachineMemOperand(MachinePointerInfo PtrInfo, unsigned flags, uint64_t s, unsigned base_alignment); + const MachinePointerInfo &getPointerInfo() const { return PtrInfo; } + /// getValue - Return the base address of the memory access. This may either /// be a normal LLVM IR Value, or one of the special values used in CodeGen. /// Special values are those obtained via diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 75edd251888..dcbe0a7f426 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -189,14 +189,6 @@ MachineFunction::DeleteMachineBasicBlock(MachineBasicBlock *MBB) { BasicBlockRecycler.Deallocate(Allocator, MBB); } -MachineMemOperand * -MachineFunction::getMachineMemOperand(const Value *v, unsigned f, - int64_t o, uint64_t s, - unsigned base_alignment) { - return new (Allocator) MachineMemOperand(MachinePointerInfo(v, o), f, - s, base_alignment); -} - MachineMemOperand * MachineFunction::getMachineMemOperand(MachinePointerInfo PtrInfo, unsigned f, uint64_t s, unsigned base_alignment) { @@ -237,10 +229,9 @@ MachineFunction::extractLoadMemRefs(MachineInstr::mmo_iterator Begin, else { // Clone the MMO and unset the store flag. MachineMemOperand *JustLoad = - getMachineMemOperand((*I)->getValue(), + getMachineMemOperand((*I)->getPointerInfo(), (*I)->getFlags() & ~MachineMemOperand::MOStore, - (*I)->getOffset(), (*I)->getSize(), - (*I)->getBaseAlignment()); + (*I)->getSize(), (*I)->getBaseAlignment()); Result[Index] = JustLoad; } ++Index; @@ -269,10 +260,9 @@ MachineFunction::extractStoreMemRefs(MachineInstr::mmo_iterator Begin, else { // Clone the MMO and unset the load flag. MachineMemOperand *JustStore = - getMachineMemOperand((*I)->getValue(), + getMachineMemOperand((*I)->getPointerInfo(), (*I)->getFlags() & ~MachineMemOperand::MOLoad, - (*I)->getOffset(), (*I)->getSize(), - (*I)->getBaseAlignment()); + (*I)->getSize(), (*I)->getBaseAlignment()); Result[Index] = JustStore; } ++Index; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 77c40afe697..48de675a109 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3671,7 +3671,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue SelectionDAG::getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, - SDValue Swp, const Value* PtrVal, + SDValue Swp, const Value *PtrVal, unsigned Alignment) { if (Alignment == 0) // Ensure that codegen never sees alignment 0 Alignment = getEVTAlignment(MemVT); @@ -3689,7 +3689,7 @@ SDValue SelectionDAG::getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, Flags |= MachineMemOperand::MOVolatile; MachineMemOperand *MMO = - MF.getMachineMemOperand(PtrVal, Flags, 0, + MF.getMachineMemOperand(MachinePointerInfo(PtrVal), Flags, MemVT.getStoreSize(), Alignment); return getAtomic(Opcode, dl, MemVT, Chain, Ptr, Cmp, Swp, MMO); @@ -3742,7 +3742,7 @@ SDValue SelectionDAG::getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, Flags |= MachineMemOperand::MOVolatile; MachineMemOperand *MMO = - MF.getMachineMemOperand(PtrVal, Flags, 0, + MF.getMachineMemOperand(MachinePointerInfo(PtrVal), Flags, MemVT.getStoreSize(), Alignment); return getAtomic(Opcode, dl, MemVT, Chain, Ptr, Val, MMO); @@ -3829,7 +3829,7 @@ SelectionDAG::getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList, if (Vol) Flags |= MachineMemOperand::MOVolatile; MachineMemOperand *MMO = - MF.getMachineMemOperand(srcValue, Flags, SVOff, + MF.getMachineMemOperand(MachinePointerInfo(srcValue, SVOff), Flags, MemVT.getStoreSize(), Align); return getMemIntrinsicNode(Opcode, dl, VTList, Ops, NumOps, MemVT, MMO); @@ -3890,7 +3890,7 @@ SelectionDAG::getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, if (isNonTemporal) Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = - MF.getMachineMemOperand(SV, Flags, SVOffset, + MF.getMachineMemOperand(MachinePointerInfo(SV, SVOffset), Flags, MemVT.getStoreSize(), Alignment); return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, MemVT, MMO); } @@ -3994,7 +3994,7 @@ SDValue SelectionDAG::getStore(SDValue Chain, DebugLoc dl, SDValue Val, if (isNonTemporal) Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = - MF.getMachineMemOperand(SV, Flags, SVOffset, + MF.getMachineMemOperand(MachinePointerInfo(SV, SVOffset), Flags, Val.getValueType().getStoreSize(), Alignment); return getStore(Chain, dl, Val, Ptr, MMO); @@ -4044,7 +4044,8 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, if (isNonTemporal) Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = - MF.getMachineMemOperand(SV, Flags, SVOffset, SVT.getStoreSize(), Alignment); + MF.getMachineMemOperand(MachinePointerInfo(SV, SVOffset), Flags, + SVT.getStoreSize(), Alignment); return getTruncStore(Chain, dl, Val, Ptr, SVT, MMO); } diff --git a/lib/CodeGen/TargetInstrInfoImpl.cpp b/lib/CodeGen/TargetInstrInfoImpl.cpp index d106ead9b46..cb2292d62be 100644 --- a/lib/CodeGen/TargetInstrInfoImpl.cpp +++ b/lib/CodeGen/TargetInstrInfoImpl.cpp @@ -252,9 +252,9 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI, const MachineFrameInfo &MFI = *MF.getFrameInfo(); assert(MFI.getObjectOffset(FI) != -1); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), - Flags, /*Offset=*/0, - MFI.getObjectSize(FI), + MF.getMachineMemOperand( + MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)), + Flags, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); NewMI->addMemOperand(MF, MMO);