Make this code a little less magic number laden.
authorEric Christopher <echristo@apple.com>
Tue, 17 May 2011 07:47:55 +0000 (07:47 +0000)
committerEric Christopher <echristo@apple.com>
Tue, 17 May 2011 07:47:55 +0000 (07:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131456 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelDAGToDAG.cpp

index 8c61bbafe26a364441edd38becc682a569eb8b65..b3383c4f9394e93afa01126964dedc8e67b7fbaa 100644 (file)
@@ -1482,6 +1482,24 @@ SDNode *X86DAGToDAGISel::SelectAtomicLoadAdd(SDNode *Node, EVT NVT) {
   }
 }
 
+enum AtomicOpc {
+  OR
+};
+
+enum AtomicSz {
+  ConstantI8,
+  I8,
+  SextConstantI16,
+  ConstantI16,
+  I16,
+  SextConstantI32,
+  ConstantI32,
+  I32,
+  SextConstantI64,
+  ConstantI64,
+  I64
+};
+
 static const unsigned int AtomicOpcTbl[1][11] = {
   {
     X86::LOCK_OR8mi,
@@ -1521,42 +1539,42 @@ SDNode *X86DAGToDAGISel::SelectAtomicLoadOr(SDNode *Node, EVT NVT) {
   }
   
   // Which index into the table.
-  unsigned index = 0;  
+  enum AtomicOpc Op = OR;  
   unsigned Opc = 0;
   switch (NVT.getSimpleVT().SimpleTy) {
     default: return 0;
     case MVT::i8:
       if (isCN)
-        Opc = AtomicOpcTbl[index][0];
+        Opc = AtomicOpcTbl[Op][ConstantI8];
       else
-        Opc = AtomicOpcTbl[index][1];
+        Opc = AtomicOpcTbl[Op][I8];
       break;
     case MVT::i16:
       if (isCN) {
         if (immSext8(Val.getNode()))
-          Opc = AtomicOpcTbl[index][2];
+          Opc = AtomicOpcTbl[Op][SextConstantI16];
         else
-          Opc = AtomicOpcTbl[index][3];
+          Opc = AtomicOpcTbl[Op][ConstantI16];
       } else
-        Opc = AtomicOpcTbl[index][4];
+        Opc = AtomicOpcTbl[Op][I16];
       break;
     case MVT::i32:
       if (isCN) {
         if (immSext8(Val.getNode()))
-          Opc = AtomicOpcTbl[index][5];
+          Opc = AtomicOpcTbl[Op][SextConstantI32];
         else
-          Opc = AtomicOpcTbl[index][6];
+          Opc = AtomicOpcTbl[Op][ConstantI32];
       } else
-        Opc = AtomicOpcTbl[index][7];
+        Opc = AtomicOpcTbl[Op][I32];
       break;
     case MVT::i64:
       if (isCN) {
         if (immSext8(Val.getNode()))
-          Opc = AtomicOpcTbl[index][8];
+          Opc = AtomicOpcTbl[Op][SextConstantI64];
         else if (i64immSExt32(Val.getNode()))
-          Opc = AtomicOpcTbl[index][9];
+          Opc = AtomicOpcTbl[Op][ConstantI64];
       } else
-        Opc = AtomicOpcTbl[index][10];
+        Opc = AtomicOpcTbl[Op][I64];
       break;
   }