aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-12-02 17:53:54 +0000
committerChris Lattner <sabre@nondot.org>2002-12-02 17:53:54 +0000
commitb45b3b3cd14faaf5a3ea5226af7e1e3cd653e6cb (patch)
tree5138990e210a3320f15614cdffde1f02547d75f3 /utils/TableGen
parentdb1b766fe63d22627b80346fcbf0ee95a69f791d (diff)
downloadexternal_llvm-b45b3b3cd14faaf5a3ea5226af7e1e3cd653e6cb.zip
external_llvm-b45b3b3cd14faaf5a3ea5226af7e1e3cd653e6cb.tar.gz
external_llvm-b45b3b3cd14faaf5a3ea5226af7e1e3cd653e6cb.tar.bz2
Continued support for field intitializers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r--utils/TableGen/Record.cpp30
-rw-r--r--utils/TableGen/Record.h23
2 files changed, 36 insertions, 17 deletions
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"; }
};