support bsr, and more .td simplification

llvm-svn: 22543
diff --git a/llvm/lib/Target/Alpha/AlphaJITInfo.cpp b/llvm/lib/Target/Alpha/AlphaJITInfo.cpp
index 3fae43c..0f7e4f3 100644
--- a/llvm/lib/Target/Alpha/AlphaJITInfo.cpp
+++ b/llvm/lib/Target/Alpha/AlphaJITInfo.cpp
@@ -245,6 +245,7 @@
   for (unsigned i = 0; i != NumRelocs; ++i, ++MR) {
     unsigned *RelocPos = (unsigned*)Function + MR->getMachineCodeOffset()/4;
     long idx = 0;
+    bool doCommon = true;
     switch ((Alpha::RelocationType)MR->getRelocationType()) {
     default: assert(0 && "Unknown relocation type!");
     case Alpha::reloc_literal:
@@ -289,9 +290,18 @@
         assert(0 && "Cannot handle gpdist yet");
       }
       break;
+    case Alpha::reloc_bsr: {
+      idx = (((unsigned char*)MR->getResultPointer() - 
+             (unsigned char*)RelocPos) >> 2) + 1; //skip first 2 inst of fun
+      *RelocPos |= (idx & ((1 << 21)-1));
+      doCommon = false;
+      break;
     }
-    short x = (short)idx;
-    assert(x == idx);
-    *(short*)RelocPos = x;
+    }
+    if (doCommon) {
+      short x = (short)idx;
+      assert(x == idx);
+      *(short*)RelocPos = x;
+    }
   }
 }