Clean the sub-reg index composition maps at emission.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 11 Sep 2012 16:34:05 +0000 (16:34 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 11 Sep 2012 16:34:05 +0000 (16:34 +0000)
Preserve the Composites map in the CodeGenSubRegIndex class so it can be
used to determine which sub-register indices can actually be composed.

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

utils/TableGen/CodeGenRegisters.cpp
utils/TableGen/CodeGenRegisters.h
utils/TableGen/RegisterInfoEmitter.cpp

index b2e9e38bc190c34e1a4b499f191c1758fc99817e..78ea9ede76c588723a737653761b37ec444c016a 100644 (file)
@@ -75,16 +75,6 @@ void CodeGenSubRegIndex::updateComponents(CodeGenRegBank &RegBank) {
   }
 }
 
-void CodeGenSubRegIndex::cleanComposites() {
-  // Clean out redundant mappings of the form this+X -> X.
-  for (CompMap::iterator i = Composed.begin(), e = Composed.end(); i != e;) {
-    CompMap::iterator j = i;
-    ++i;
-    if (j->first == j->second)
-      Composed.erase(j);
-  }
-}
-
 //===----------------------------------------------------------------------===//
 //                              CodeGenRegister
 //===----------------------------------------------------------------------===//
@@ -1164,11 +1154,6 @@ void CodeGenRegBank::computeComposites() {
       }
     }
   }
-
-  // We don't care about the difference between (Idx1, Idx2) -> Idx2 and invalid
-  // compositions, so remove any mappings of that form.
-  for (unsigned i = 0, e = SubRegIndices.size(); i != e; ++i)
-    SubRegIndices[i]->cleanComposites();
 }
 
 namespace {
index 827063e47017664dada7b675ac363a10a1dbaf44..72b6196038fd3c50cf4d6f3c2647ca81bb0f9430 100644 (file)
@@ -80,9 +80,6 @@ namespace llvm {
     // Update the composite maps of components specified in 'ComposedOf'.
     void updateComponents(CodeGenRegBank&);
 
-    // Clean out redundant composite mappings.
-    void cleanComposites();
-
     // Return the map of composites.
     const CompMap &getComposites() const { return Composed; }
 
index 3773c1ba92a9948005bc5ad4c1df94ac9f43af3f..80d4a6fede5718510b8763b3ecd6613a9c91d487 100644 (file)
@@ -1055,8 +1055,8 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
     for (unsigned i = 0, e = SubRegIndices.size(); i != e; ++i) {
       bool Open = false;
       for (unsigned j = 0; j != e; ++j) {
-        if (CodeGenSubRegIndex *Comp =
-            SubRegIndices[i]->compose(SubRegIndices[j])) {
+        CodeGenSubRegIndex *Comp = SubRegIndices[i]->compose(SubRegIndices[j]);
+        if (Comp && Comp != SubRegIndices[j]) {
           if (!Open) {
             OS << "  case " << SubRegIndices[i]->getQualifiedName()
               << ": switch(IdxB) {\n    default: return IdxB;\n";