diff options
-rw-r--r-- | support/tools/TableGen/Record.cpp | 30 | ||||
-rw-r--r-- | support/tools/TableGen/Record.h | 23 | ||||
-rw-r--r-- | utils/TableGen/Record.cpp | 30 | ||||
-rw-r--r-- | utils/TableGen/Record.h | 23 |
4 files changed, 72 insertions, 34 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 64711bf..8f6d430 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -24,7 +24,7 @@ Init *BitRecTy::convertValue(IntInit *II) { return new BitInit(Val != 0); } -Init *BitRecTy::convertValue(VarInit *VI) { +Init *BitRecTy::convertValue(TypedInit *VI) { if (dynamic_cast<BitRecTy*>(VI->getType())) return VI; // Accept variable if it is already of bit type! return 0; @@ -65,7 +65,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) { return 0; } -Init *BitsRecTy::convertValue(VarInit *VI) { +Init *BitsRecTy::convertValue(TypedInit *VI) { if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType())) if (BRT->Size == Size) { BitsInit *Ret = new BitsInit(Size); @@ -82,9 +82,23 @@ Init *BitsRecTy::convertValue(VarInit *VI) { return 0; } +#if 0 Init *BitsRecTy::convertValue(FieldInit *VI) { + if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType())) + if (BRT->Size == Size) { + BitsInit *Ret = new BitsInit(Size); + for (unsigned i = 0; i != Size; ++i) + Ret->setBit(i, new VarBitInit(VI, i)); + return Ret; + } + if (Size == 1 && dynamic_cast<BitRecTy*>(VI->getType())) { + BitsInit *Ret = new BitsInit(1); + Ret->setBit(0, VI); + return Ret; + } return 0; } +#endif Init *IntRecTy::convertValue(BitsInit *BI) { @@ -98,15 +112,15 @@ Init *IntRecTy::convertValue(BitsInit *BI) { return new IntInit(Result); } -Init *IntRecTy::convertValue(VarInit *VI) { - if (dynamic_cast<IntRecTy*>(VI->getType())) - return VI; // Accept variable if already of the right type! +Init *IntRecTy::convertValue(TypedInit *TI) { + if (dynamic_cast<IntRecTy*>(TI->getType())) + return TI; // Accept variable if already of the right type! return 0; } -Init *StringRecTy::convertValue(VarInit *VI) { - if (dynamic_cast<StringRecTy*>(VI->getType())) - return VI; // Accept variable if already of the right type! +Init *StringRecTy::convertValue(TypedInit *TI) { + if (dynamic_cast<StringRecTy*>(TI->getType())) + 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 0c8ed33..e736f80 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -17,10 +17,11 @@ class BitsInit; class IntInit; class StringInit; class ListInit; -class VarInit; -class VarBitInit; class DefInit; +class TypedInit; +class VarInit; class FieldInit; +class VarBitInit; class Record; //===----------------------------------------------------------------------===// @@ -36,10 +37,15 @@ struct RecTy { virtual Init *convertValue( IntInit *II) { return 0; } virtual Init *convertValue(StringInit *SI) { return 0; } virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( VarInit *VI) { return 0; } virtual Init *convertValue(VarBitInit *VB) { return 0; } virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( FieldInit *FI) { return 0; } + virtual Init *convertValue( TypedInit *TI) { return 0; } + virtual Init *convertValue( VarInit *VI) { + return convertValue((TypedInit*)VI); + } + virtual Init *convertValue( FieldInit *FI) { + return convertValue((TypedInit*)FI); + } virtual void print(std::ostream &OS) const = 0; void dump() const; @@ -58,7 +64,7 @@ struct BitRecTy : public RecTy { Init *convertValue(BitInit *BI) { return (Init*)BI; } Init *convertValue(BitsInit *BI); Init *convertValue(IntInit *II); - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *VI); Init *convertValue(VarBitInit *VB) { return (Init*)VB; } void print(std::ostream &OS) const { OS << "bit"; } @@ -78,8 +84,7 @@ public: Init *convertValue(BitInit *UI); Init *convertValue(BitsInit *BI); Init *convertValue(IntInit *II); - Init *convertValue(VarInit *VI); - Init *convertValue(FieldInit *VI); + Init *convertValue(TypedInit *VI); void print(std::ostream &OS) const { OS << "bits<" << Size << ">"; } }; @@ -91,7 +96,7 @@ struct IntRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(IntInit *II) { return (Init*)II; } Init *convertValue(BitsInit *BI); - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *TI); void print(std::ostream &OS) const { OS << "int"; } }; @@ -101,7 +106,7 @@ struct IntRecTy : public RecTy { struct StringRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(StringInit *SI) { return (Init*)SI; } - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *VI); void print(std::ostream &OS) const { OS << "string"; } }; diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 64711bf..8f6d430 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -24,7 +24,7 @@ Init *BitRecTy::convertValue(IntInit *II) { return new BitInit(Val != 0); } -Init *BitRecTy::convertValue(VarInit *VI) { +Init *BitRecTy::convertValue(TypedInit *VI) { if (dynamic_cast<BitRecTy*>(VI->getType())) return VI; // Accept variable if it is already of bit type! return 0; @@ -65,7 +65,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) { return 0; } -Init *BitsRecTy::convertValue(VarInit *VI) { +Init *BitsRecTy::convertValue(TypedInit *VI) { if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType())) if (BRT->Size == Size) { BitsInit *Ret = new BitsInit(Size); @@ -82,9 +82,23 @@ Init *BitsRecTy::convertValue(VarInit *VI) { return 0; } +#if 0 Init *BitsRecTy::convertValue(FieldInit *VI) { + if (BitsRecTy *BRT = dynamic_cast<BitsRecTy*>(VI->getType())) + if (BRT->Size == Size) { + BitsInit *Ret = new BitsInit(Size); + for (unsigned i = 0; i != Size; ++i) + Ret->setBit(i, new VarBitInit(VI, i)); + return Ret; + } + if (Size == 1 && dynamic_cast<BitRecTy*>(VI->getType())) { + BitsInit *Ret = new BitsInit(1); + Ret->setBit(0, VI); + return Ret; + } return 0; } +#endif Init *IntRecTy::convertValue(BitsInit *BI) { @@ -98,15 +112,15 @@ Init *IntRecTy::convertValue(BitsInit *BI) { return new IntInit(Result); } -Init *IntRecTy::convertValue(VarInit *VI) { - if (dynamic_cast<IntRecTy*>(VI->getType())) - return VI; // Accept variable if already of the right type! +Init *IntRecTy::convertValue(TypedInit *TI) { + if (dynamic_cast<IntRecTy*>(TI->getType())) + return TI; // Accept variable if already of the right type! return 0; } -Init *StringRecTy::convertValue(VarInit *VI) { - if (dynamic_cast<StringRecTy*>(VI->getType())) - return VI; // Accept variable if already of the right type! +Init *StringRecTy::convertValue(TypedInit *TI) { + if (dynamic_cast<StringRecTy*>(TI->getType())) + 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 0c8ed33..e736f80 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -17,10 +17,11 @@ class BitsInit; class IntInit; class StringInit; class ListInit; -class VarInit; -class VarBitInit; class DefInit; +class TypedInit; +class VarInit; class FieldInit; +class VarBitInit; class Record; //===----------------------------------------------------------------------===// @@ -36,10 +37,15 @@ struct RecTy { virtual Init *convertValue( IntInit *II) { return 0; } virtual Init *convertValue(StringInit *SI) { return 0; } virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( VarInit *VI) { return 0; } virtual Init *convertValue(VarBitInit *VB) { return 0; } virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( FieldInit *FI) { return 0; } + virtual Init *convertValue( TypedInit *TI) { return 0; } + virtual Init *convertValue( VarInit *VI) { + return convertValue((TypedInit*)VI); + } + virtual Init *convertValue( FieldInit *FI) { + return convertValue((TypedInit*)FI); + } virtual void print(std::ostream &OS) const = 0; void dump() const; @@ -58,7 +64,7 @@ struct BitRecTy : public RecTy { Init *convertValue(BitInit *BI) { return (Init*)BI; } Init *convertValue(BitsInit *BI); Init *convertValue(IntInit *II); - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *VI); Init *convertValue(VarBitInit *VB) { return (Init*)VB; } void print(std::ostream &OS) const { OS << "bit"; } @@ -78,8 +84,7 @@ public: Init *convertValue(BitInit *UI); Init *convertValue(BitsInit *BI); Init *convertValue(IntInit *II); - Init *convertValue(VarInit *VI); - Init *convertValue(FieldInit *VI); + Init *convertValue(TypedInit *VI); void print(std::ostream &OS) const { OS << "bits<" << Size << ">"; } }; @@ -91,7 +96,7 @@ struct IntRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(IntInit *II) { return (Init*)II; } Init *convertValue(BitsInit *BI); - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *TI); void print(std::ostream &OS) const { OS << "int"; } }; @@ -101,7 +106,7 @@ struct IntRecTy : public RecTy { struct StringRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(StringInit *SI) { return (Init*)SI; } - Init *convertValue(VarInit *VI); + Init *convertValue(TypedInit *VI); void print(std::ostream &OS) const { OS << "string"; } }; |