llvm.org GIT mirror llvm / e8e2e80
refactor the Value*/offset pair from MachineMemOperand out to a new MachinePointerInfo struct, no functionality change. This also adds an assert to MachineMemOperand::MachineMemOperand that verifies that the Value* is either null or is an IR pointer type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114389 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 22 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
2323 class FoldingSetNodeID;
2424 class raw_ostream;
2525
26 /// MachinePointerInfo - This class contains a discriminated union of
27 /// information about pointers in memory operands, relating them back to LLVM IR
28 /// or to virtual locations (such as frame indices) that are exposed during
29 /// codegen.
30 struct MachinePointerInfo {
31 const Value *V;
32 int64_t Offset;
33 MachinePointerInfo(const Value *v, int64_t offset) : V(v), Offset(offset) {}
34 };
35
36
2637 //===----------------------------------------------------------------------===//
2738 /// MachineMemOperand - A description of a memory reference used in the backend.
2839 /// Instead of holding a StoreInst or LoadInst, this class holds the address
3243 /// that aren't explicit in the regular LLVM IR.
3344 ///
3445 class MachineMemOperand {
35 int64_t Offset;
46 MachinePointerInfo PtrInfo;
3647 uint64_t Size;
37 const Value *V;
38 unsigned int Flags;
48 unsigned Flags;
3949
4050 public:
4151 /// Flags values. These may be or'd together.
6474 /// other PseudoSourceValue member functions which return objects which stand
6575 /// for frame/stack pointer relative references and other special references
6676 /// which are not representable in the high-level IR.
67 const Value *getValue() const { return V; }
77 const Value *getValue() const { return PtrInfo.V; }
6878
6979 /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
7080 unsigned int getFlags() const { return Flags & ((1 << MOMaxBits) - 1); }
7282 /// getOffset - For normal values, this is a byte offset added to the base
7383 /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
7484 /// number.
75 int64_t getOffset() const { return Offset; }
85 int64_t getOffset() const { return PtrInfo.Offset; }
7686
7787 /// getSize - Return the size in bytes of the memory reference.
7888 uint64_t getSize() const { return Size; }
98108 /// setValue - Change the SourceValue for this MachineMemOperand. This
99109 /// should only be used when an object is being relocated and all references
100110 /// to it are being updated.
101 void setValue(const Value *NewSV) { V = NewSV; }
111 void setValue(const Value *NewSV) { PtrInfo.V = NewSV; }
112 void setOffset(int64_t NewOffset) { PtrInfo.Offset = NewOffset; }
102113
103114 /// Profile - Gather unique data for the object.
104115 ///
336336
337337 MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f,
338338 int64_t o, uint64_t s, unsigned int a)
339 : Offset(o), Size(s), V(v),
339 : PtrInfo(v, o), Size(s),
340340 Flags((f & ((1 << MOMaxBits) - 1)) | ((Log2_32(a) + 1) << MOMaxBits)) {
341 assert((v == 0 || isa(v->getType())) && "invalid pointer value");
341342 assert(getBaseAlignment() == a && "Alignment is not a power of 2!");
342343 assert((isLoad() || isStore()) && "Not a load/store!");
343344 }
345346 /// Profile - Gather unique data for the object.
346347 ///
347348 void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
348 ID.AddInteger(Offset);
349 ID.AddInteger(getOffset());
349350 ID.AddInteger(Size);
350 ID.AddPointer(V);
351 ID.AddPointer(getValue());
351352 ID.AddInteger(Flags);
352353 }
353354
363364 ((Log2_32(MMO->getBaseAlignment()) + 1) << MOMaxBits);
364365 // Also update the base and offset, because the new alignment may
365366 // not be applicable with the old ones.
366 V = MMO->getValue();
367 Offset = MMO->getOffset();
367 PtrInfo = MMO->PtrInfo;
368368 }
369369 }
370370