Fix bug: TableGen/IntBitInit.td
authorChris Lattner <sabre@nondot.org>
Sun, 3 Aug 2003 18:29:51 +0000 (18:29 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 3 Aug 2003 18:29:51 +0000 (18:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7526 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/Record.cpp
support/tools/TableGen/Record.h
utils/TableGen/Record.cpp
utils/TableGen/Record.h

index 204929e0244c04d4e67df5acb171bdf01dc641d7..cf8aa40e226979b5499b61d69b7a1859eac54dfa 100644 (file)
@@ -93,6 +93,10 @@ Init *BitsRecTy::convertValue(TypedInit *VI) {
   return 0;
 }
 
+Init *IntRecTy::convertValue(BitInit *BI) {
+  return new IntInit(BI->getValue());
+}
+
 Init *IntRecTy::convertValue(BitsInit *BI) {
   int Result = 0;
   for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) 
@@ -105,7 +109,7 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
 }
 
 Init *IntRecTy::convertValue(TypedInit *TI) {
-  if (dynamic_cast<IntRecTy*>(TI->getType()))
+  if (TI->getType()->typeIsConvertibleTo(this))
     return TI;  // Accept variable if already of the right type!
   return 0;
 }
index 4c4ad5a6b8cfff380974a5e33bdb3c543c5b0992..d841a2af055777af03d9e7097eeca9ecdfa7f92f 100644 (file)
@@ -145,6 +145,7 @@ public:
 struct IntRecTy : public RecTy {
   Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
   Init *convertValue(IntInit *II) { return (Init*)II; }
+  Init *convertValue(BitInit *BI);
   Init *convertValue(BitsInit *BI);
   Init *convertValue(TypedInit *TI);
 
index 204929e0244c04d4e67df5acb171bdf01dc641d7..cf8aa40e226979b5499b61d69b7a1859eac54dfa 100644 (file)
@@ -93,6 +93,10 @@ Init *BitsRecTy::convertValue(TypedInit *VI) {
   return 0;
 }
 
+Init *IntRecTy::convertValue(BitInit *BI) {
+  return new IntInit(BI->getValue());
+}
+
 Init *IntRecTy::convertValue(BitsInit *BI) {
   int Result = 0;
   for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) 
@@ -105,7 +109,7 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
 }
 
 Init *IntRecTy::convertValue(TypedInit *TI) {
-  if (dynamic_cast<IntRecTy*>(TI->getType()))
+  if (TI->getType()->typeIsConvertibleTo(this))
     return TI;  // Accept variable if already of the right type!
   return 0;
 }
index 4c4ad5a6b8cfff380974a5e33bdb3c543c5b0992..d841a2af055777af03d9e7097eeca9ecdfa7f92f 100644 (file)
@@ -145,6 +145,7 @@ public:
 struct IntRecTy : public RecTy {
   Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
   Init *convertValue(IntInit *II) { return (Init*)II; }
+  Init *convertValue(BitInit *BI);
   Init *convertValue(BitsInit *BI);
   Init *convertValue(TypedInit *TI);