add some helpful accessors.
authorChris Lattner <sabre@nondot.org>
Tue, 21 Sep 2010 05:39:30 +0000 (05:39 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 21 Sep 2010 05:39:30 +0000 (05:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114400 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineMemOperand.h
include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/MachineInstr.cpp

index 0804f46ae92cd32574f0011dfb529d120a5919a3..532ed7cbcbecb0f3260a33d7b25477060f0d0986 100644 (file)
@@ -39,6 +39,15 @@ struct MachinePointerInfo {
   
   explicit MachinePointerInfo(const Value *v, int64_t offset = 0)
     : V(v), Offset(offset) {}
+  
+  MachinePointerInfo getWithOffset(int64_t O) const {
+    if (V == 0) return MachinePointerInfo(0, 0);
+    return MachinePointerInfo(V, Offset+O);
+  }
+  
+  /// getAddrSpace - Return the LLVM IR address space number that this pointer
+  /// points into.
+  unsigned getAddrSpace() const;
 };
   
   
index 4cf6f367edfbedffcc47f4bdae31cb07b4897867..af4c2d1c58277bd71a59f5ea2d3b483c43c5d6b5 100644 (file)
@@ -909,6 +909,10 @@ public:
   /// reference performed by operation.
   MachineMemOperand *getMemOperand() const { return MMO; }
 
+  const MachinePointerInfo &getPointerInfo() const {
+    return MMO->getPointerInfo();
+  }
+  
   /// refineAlignment - Update this MemSDNode's MachineMemOperand information
   /// to reflect the alignment of NewMMO, if it has a greater alignment.
   /// This must only be used when the new alignment applies to all users of
index a953597c7e4a652a4d3d77bc5b2b7b9b3f6ec93e..acab289953d43133f83718545e917e664d7a8e59 100644 (file)
@@ -335,6 +335,14 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
 // MachineMemOperand Implementation
 //===----------------------------------------------------------------------===//
 
+/// getAddrSpace - Return the LLVM IR address space number that this pointer
+/// points into.
+unsigned MachinePointerInfo::getAddrSpace() const {
+  if (V == 0) return 0;
+  return cast<PointerType>(V->getType())->getAddressSpace();
+}
+
+
 MachineMemOperand::MachineMemOperand(MachinePointerInfo ptrinfo, unsigned f,
                                      uint64_t s, unsigned int a)
   : PtrInfo(ptrinfo), Size(s),