Make AllocState an enum.
authorBrian Gaeke <gaeke@uiuc.edu>
Thu, 30 Oct 2003 21:21:22 +0000 (21:21 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Thu, 30 Oct 2003 21:21:22 +0000 (21:21 +0000)
Move the stringifying method for that enum into class AllocInfo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9616 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAlloc/AllocInfo.h
lib/Target/SparcV9/RegAlloc/AllocInfo.h

index d982afc8ef08e506f807f6fe01ac418d65bd930b..1f5357ab79a19cede38a5f7849d776881aec6796 100644 (file)
 struct AllocInfo {
   unsigned Instruction;
   unsigned Operand;
-  unsigned AllocState;
+  enum AllocStateTy { NotAllocated = 0, Allocated, Spilled };
+  AllocStateTy AllocState;
   int Placement;
+
   AllocInfo (unsigned Instruction_, unsigned Operand_,
-             unsigned AllocState_, int Placement_) :
+             AllocStateTy AllocState_, int Placement_) :
     Instruction (Instruction_), Operand (Operand_),
        AllocState (AllocState_), Placement (Placement_) { }
 
@@ -65,6 +67,14 @@ struct AllocInfo {
     return (X.AllocState == AllocState) && (X.Placement == Placement);
   } 
   bool operator!= (const AllocInfo &X) const { return !(*this == X); } 
+
+  /// Returns a human-readable string representation of the AllocState member.
+  ///
+  const std::string allocStateToString () const {
+    static const char *AllocStateNames[] =
+      { "NotAllocated", "Allocated", "Spilled" };
+    return std::string (AllocStateNames[AllocState]);
+  }
 };
 
 #endif // ALLOCINFO_H
index d982afc8ef08e506f807f6fe01ac418d65bd930b..1f5357ab79a19cede38a5f7849d776881aec6796 100644 (file)
 struct AllocInfo {
   unsigned Instruction;
   unsigned Operand;
-  unsigned AllocState;
+  enum AllocStateTy { NotAllocated = 0, Allocated, Spilled };
+  AllocStateTy AllocState;
   int Placement;
+
   AllocInfo (unsigned Instruction_, unsigned Operand_,
-             unsigned AllocState_, int Placement_) :
+             AllocStateTy AllocState_, int Placement_) :
     Instruction (Instruction_), Operand (Operand_),
        AllocState (AllocState_), Placement (Placement_) { }
 
@@ -65,6 +67,14 @@ struct AllocInfo {
     return (X.AllocState == AllocState) && (X.Placement == Placement);
   } 
   bool operator!= (const AllocInfo &X) const { return !(*this == X); } 
+
+  /// Returns a human-readable string representation of the AllocState member.
+  ///
+  const std::string allocStateToString () const {
+    static const char *AllocStateNames[] =
+      { "NotAllocated", "Allocated", "Spilled" };
+    return std::string (AllocStateNames[AllocState]);
+  }
 };
 
 #endif // ALLOCINFO_H