From 08ca97291fe309c24a29beba2f2d770aa75c7653 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 3 Aug 2003 18:29:51 +0000 Subject: [PATCH] Fix bug: TableGen/IntBitInit.td git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7526 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/Record.cpp | 6 +++++- support/tools/TableGen/Record.h | 1 + utils/TableGen/Record.cpp | 6 +++++- utils/TableGen/Record.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 204929e0244..cf8aa40e226 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -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(TI->getType())) + if (TI->getType()->typeIsConvertibleTo(this)) return TI; // Accept variable if already of the right type! return 0; } diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 4c4ad5a6b8c..d841a2af055 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -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); diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 204929e0244..cf8aa40e226 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -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(TI->getType())) + if (TI->getType()->typeIsConvertibleTo(this)) return TI; // Accept variable if already of the right type! return 0; } diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 4c4ad5a6b8c..d841a2af055 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -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);