diff options
Diffstat (limited to 'include/llvm/CodeGen/MachineMemOperand.h')
| -rw-r--r-- | include/llvm/CodeGen/MachineMemOperand.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/include/llvm/CodeGen/MachineMemOperand.h b/include/llvm/CodeGen/MachineMemOperand.h index a9de0db05d72..c5b204a79f04 100644 --- a/include/llvm/CodeGen/MachineMemOperand.h +++ b/include/llvm/CodeGen/MachineMemOperand.h @@ -45,18 +45,46 @@ struct MachinePointerInfo { /// Offset - This is an offset from the base Value*. int64_t Offset; - explicit MachinePointerInfo(const Value *v = nullptr, int64_t offset = 0) - : V(v), Offset(offset) {} + uint8_t StackID; - explicit MachinePointerInfo(const PseudoSourceValue *v, - int64_t offset = 0) - : V(v), Offset(offset) {} + unsigned AddrSpace = 0; + + explicit MachinePointerInfo(const Value *v, int64_t offset = 0, + uint8_t ID = 0) + : V(v), Offset(offset), StackID(ID) { + AddrSpace = v ? v->getType()->getPointerAddressSpace() : 0; + } + + explicit MachinePointerInfo(const PseudoSourceValue *v, int64_t offset = 0, + uint8_t ID = 0) + : V(v), Offset(offset), StackID(ID) { + AddrSpace = v ? v->getAddressSpace() : 0; + } + + explicit MachinePointerInfo(unsigned AddressSpace = 0) + : V((const Value *)nullptr), Offset(0), StackID(0), + AddrSpace(AddressSpace) {} + + explicit MachinePointerInfo( + PointerUnion<const Value *, const PseudoSourceValue *> v, + int64_t offset = 0, + uint8_t ID = 0) + : V(v), Offset(offset), StackID(ID) { + if (V) { + if (const auto *ValPtr = V.dyn_cast<const Value*>()) + AddrSpace = ValPtr->getType()->getPointerAddressSpace(); + else + AddrSpace = V.get<const PseudoSourceValue*>()->getAddressSpace(); + } + } MachinePointerInfo getWithOffset(int64_t O) const { - if (V.isNull()) return MachinePointerInfo(); + if (V.isNull()) + return MachinePointerInfo(AddrSpace); if (V.is<const Value*>()) - return MachinePointerInfo(V.get<const Value*>(), Offset+O); - return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset+O); + return MachinePointerInfo(V.get<const Value*>(), Offset+O, StackID); + return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset+O, + StackID); } /// Return true if memory region [V, V+Offset+Size) is known to be @@ -82,7 +110,11 @@ struct MachinePointerInfo { static MachinePointerInfo getGOT(MachineFunction &MF); /// Stack pointer relative access. - static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset); + static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, + uint8_t ID = 0); + + /// Stack memory without other information. + static MachinePointerInfo getUnknownStack(MachineFunction &MF); }; |
