[llvm] r244687 - PseudoSourceValue: Introduce a 'PSVKind' enumerator.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 03:35:01 PDT 2015


I can't find this review on the list either. To be clear, I don't see any issue with this patch. It's just that it claims to have been reviewed and it looks like it hasn't (off-list reviews don't count).
________________________________________
From: llvm-commits [llvm-commits-bounces at lists.llvm.org] on behalf of Alex Lorenz via llvm-commits [llvm-commits at lists.llvm.org]
Sent: 11 August 2015 23:32
To: llvm-commits at lists.llvm.org
Subject: [llvm] r244687 - PseudoSourceValue: Introduce a 'PSVKind' enumerator.

Author: arphaman
Date: Tue Aug 11 17:32:00 2015
New Revision: 244687

URL: http://llvm.org/viewvc/llvm-project?rev=244687&view=rev
Log:
PseudoSourceValue: Introduce a 'PSVKind' enumerator.

This commit introduces a new enumerator named 'PSVKind' in the
'PseudoSourceValue' class. This enumerator is now used to distinguish between
the various kinds of pseudo source values.

This change is done in preparation for the changes to the pseudo source value
object management and to the PseudoSourceValue's class hierarchy - the next two
PseudoSourceValue commits will get rid of the global variable that manages the
pseudo source values and the mips specific MipsCallEntry subclass.

Reviewers: Akira Hatanaka

Modified:
    llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h
    llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp
    llvm/trunk/lib/Target/Mips/MipsMachineFunction.cpp

Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=244687&r1=244686&r2=244687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Tue Aug 11 17:32:00 2015
@@ -28,7 +28,12 @@ raw_ostream &operator<<(raw_ostream &OS,
 /// a memory access references the functions stack frame (e.g., a spill slot),
 /// below the stack frame (e.g., argument space), or constant pool.
 class PseudoSourceValue {
+public:
+  enum PSVKind { Stack, GOT, JumpTable, ConstantPool, FixedStack, MipsPSV };
+
 private:
+  PSVKind Kind;
+
   friend class MachineMemOperand; // For printCustom().

   /// Implement printing for PseudoSourceValue. This is called from
@@ -36,13 +41,17 @@ private:
   virtual void printCustom(raw_ostream &O) const;

 public:
-  /// Whether this is a FixedStackPseudoSourceValue.
-  bool IsFixed;
-
-  explicit PseudoSourceValue(bool IsFixed = false);
+  explicit PseudoSourceValue(PSVKind Kind);

   virtual ~PseudoSourceValue();

+  PSVKind kind() const { return Kind; }
+
+  bool isStack() const { return Kind == Stack; }
+  bool isGOT() const { return Kind == GOT; }
+  bool isConstantPool() const { return Kind == ConstantPool; }
+  bool isJumpTable() const { return Kind == JumpTable; }
+
   /// Test whether the memory pointed to by this PseudoSourceValue has a
   /// constant value.
   virtual bool isConstant(const MachineFrameInfo *) const;
@@ -84,10 +93,10 @@ class FixedStackPseudoSourceValue : publ

 public:
   explicit FixedStackPseudoSourceValue(int FI)
-      : PseudoSourceValue(true), FI(FI) {}
+      : PseudoSourceValue(FixedStack), FI(FI) {}

   static inline bool classof(const PseudoSourceValue *V) {
-    return V->IsFixed == true;
+    return V->kind() == FixedStack;
   }

   bool isConstant(const MachineFrameInfo *MFI) const override;

Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=244687&r1=244686&r2=244687&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original)
+++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Tue Aug 11 17:32:00 2015
@@ -25,11 +25,14 @@ using namespace llvm;
 namespace {
 struct PSVGlobalsTy {
   // PseudoSourceValues are immutable so don't need locking.
-  const PseudoSourceValue PSVs[4];
+  const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
   sys::Mutex Lock; // Guards FSValues, but not the values inside it.
   std::map<int, const PseudoSourceValue *> FSValues;

-  PSVGlobalsTy() : PSVs() {}
+  PSVGlobalsTy()
+      : StackPSV(PseudoSourceValue::Stack), GOTPSV(PseudoSourceValue::GOT),
+        JumpTablePSV(PseudoSourceValue::JumpTable),
+        ConstantPoolPSV(PseudoSourceValue::ConstantPool) {}
   ~PSVGlobalsTy() {
     for (std::map<int, const PseudoSourceValue *>::iterator
              I = FSValues.begin(),
@@ -45,27 +48,27 @@ static ManagedStatic<PSVGlobalsTy> PSVGl
 } // anonymous namespace

 const PseudoSourceValue *PseudoSourceValue::getStack() {
-  return &PSVGlobals->PSVs[0];
+  return &PSVGlobals->StackPSV;
 }
 const PseudoSourceValue *PseudoSourceValue::getGOT() {
-  return &PSVGlobals->PSVs[1];
+  return &PSVGlobals->GOTPSV;
 }
 const PseudoSourceValue *PseudoSourceValue::getJumpTable() {
-  return &PSVGlobals->PSVs[2];
+  return &PSVGlobals->JumpTablePSV;
 }
 const PseudoSourceValue *PseudoSourceValue::getConstantPool() {
-  return &PSVGlobals->PSVs[3];
+  return &PSVGlobals->ConstantPoolPSV;
 }

-static const char *const PSVNames[] = {"Stack", "GOT", "JumpTable",
-                                       "ConstantPool"};
+static const char *const PSVNames[] = {
+    "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack", "MipsCallEntry"};

-PseudoSourceValue::PseudoSourceValue(bool IsFixed) : IsFixed(IsFixed) {}
+PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {}

 PseudoSourceValue::~PseudoSourceValue() {}

 void PseudoSourceValue::printCustom(raw_ostream &O) const {
-  O << PSVNames[this - PSVGlobals->PSVs];
+  O << PSVNames[Kind];
 }

 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
@@ -78,22 +81,21 @@ const PseudoSourceValue *PseudoSourceVal
 }

 bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
-  if (this == getStack())
+  if (isStack())
     return false;
-  if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
+  if (isGOT() || isConstantPool() || isJumpTable())
     return true;
   llvm_unreachable("Unknown PseudoSourceValue!");
 }

-bool PseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const {
-  if (this == getStack() || this == getGOT() || this == getConstantPool() ||
-      this == getJumpTable())
+bool PseudoSourceValue::isAliased(const MachineFrameInfo *) const {
+  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
     return false;
   llvm_unreachable("Unknown PseudoSourceValue!");
 }

-bool PseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const {
-  if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
+bool PseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
+  if (isGOT() || isConstantPool() || isJumpTable())
     return false;
   return true;
 }

Modified: llvm/trunk/lib/Target/Mips/MipsMachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsMachineFunction.cpp?rev=244687&r1=244686&r2=244687&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsMachineFunction.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsMachineFunction.cpp Tue Aug 11 17:32:00 2015
@@ -25,14 +25,15 @@ FixGlobalBaseReg("mips-fix-global-base-r
                  cl::desc("Always use $gp as the global base register."));

 // class MipsCallEntry.
-MipsCallEntry::MipsCallEntry(StringRef N) {
+MipsCallEntry::MipsCallEntry(StringRef N) : PseudoSourceValue(MipsPSV) {
 #ifndef NDEBUG
   Name = N;
   Val = nullptr;
 #endif
 }

-MipsCallEntry::MipsCallEntry(const GlobalValue *V) {
+MipsCallEntry::MipsCallEntry(const GlobalValue *V)
+    : PseudoSourceValue(MipsPSV) {
 #ifndef NDEBUG
   Val = V;
 #endif


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list