[PATCH] D21688: CodeGen: Add AddressSpace field to PseudoSourceValue

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 08:42:23 PDT 2016


tstellarAMD created this revision.
tstellarAMD added a reviewer: arsenm.
tstellarAMD added a subscriber: llvm-commits.

AMDGPU will use this to create a GOT PseudoSourceValue in
a non-zero address space.

http://reviews.llvm.org/D21688

Files:
  include/llvm/CodeGen/PseudoSourceValue.h
  lib/CodeGen/MachineInstr.cpp
  lib/CodeGen/PseudoSourceValue.cpp

Index: lib/CodeGen/PseudoSourceValue.cpp
===================================================================
--- lib/CodeGen/PseudoSourceValue.cpp
+++ lib/CodeGen/PseudoSourceValue.cpp
@@ -24,7 +24,8 @@
     "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
     "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
 
-PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {}
+PseudoSourceValue::PseudoSourceValue(PSVKind Kind, unsigned AddressSpace)
+    : Kind(Kind), AddressSpace(AddressSpace) {}
 
 PseudoSourceValue::~PseudoSourceValue() {}
 
Index: lib/CodeGen/MachineInstr.cpp
===================================================================
--- lib/CodeGen/MachineInstr.cpp
+++ lib/CodeGen/MachineInstr.cpp
@@ -467,7 +467,11 @@
 /// getAddrSpace - Return the LLVM IR address space number that this pointer
 /// points into.
 unsigned MachinePointerInfo::getAddrSpace() const {
-  if (V.isNull() || V.is<const PseudoSourceValue*>()) return 0;
+  if (V.isNull()) return 0;
+
+  if (V.is<const PseudoSourceValue*>())
+    return V.get<const PseudoSourceValue*>()->getAddressSpace();
+
   return cast<PointerType>(V.get<const Value*>()->getType())->getAddressSpace();
 }
 
Index: include/llvm/CodeGen/PseudoSourceValue.h
===================================================================
--- include/llvm/CodeGen/PseudoSourceValue.h
+++ include/llvm/CodeGen/PseudoSourceValue.h
@@ -47,6 +47,7 @@
 
 private:
   PSVKind Kind;
+  unsigned AddressSpace;
   friend raw_ostream &llvm::operator<<(raw_ostream &OS,
                                        const PseudoSourceValue* PSV);
 
@@ -57,7 +58,7 @@
   virtual void printCustom(raw_ostream &O) const;
 
 public:
-  explicit PseudoSourceValue(PSVKind Kind);
+  explicit PseudoSourceValue(PSVKind Kind, unsigned AdressSpace = 0);
 
   virtual ~PseudoSourceValue();
 
@@ -68,6 +69,8 @@
   bool isConstantPool() const { return Kind == ConstantPool; }
   bool isJumpTable() const { return Kind == JumpTable; }
 
+  unsigned getAddressSpace() const { return AddressSpace; }
+
   /// Test whether the memory pointed to by this PseudoSourceValue has a
   /// constant value.
   virtual bool isConstant(const MachineFrameInfo *) const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21688.61800.patch
Type: text/x-patch
Size: 2202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160624/c772ff76/attachment.bin>


More information about the llvm-commits mailing list