aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/Record.cpp16
-rw-r--r--support/tools/TableGen/Record.h8
-rw-r--r--utils/TableGen/Record.cpp16
-rw-r--r--utils/TableGen/Record.h8
4 files changed, 38 insertions, 10 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index 72c5a230e5..a54f8e238b 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -116,6 +116,14 @@ Init *ListRecTy::convertValue(ListInit *LI) {
return LI;
}
+Init *ListRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with our class.
+ if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
+ if (LRT->getElementClass() == getElementClass())
+ return TI;
+ return 0;
+}
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
@@ -127,12 +135,12 @@ Init *RecordRecTy::convertValue(DefInit *DI) {
return DI;
}
-Init *RecordRecTy::convertValue(TypedInit *VI) {
- // Ensure that VI is compatible with Rec.
- if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(VI->getType()))
+Init *RecordRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(TI->getType()))
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
- return VI;
+ return TI;
return 0;
}
diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h
index 356d131ae9..d94bb34504 100644
--- a/support/tools/TableGen/Record.h
+++ b/support/tools/TableGen/Record.h
@@ -108,7 +108,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(TypedInit *VI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "string"; }
};
@@ -119,8 +119,14 @@ class ListRecTy : public RecTy {
Record *Class;
public:
ListRecTy(Record *C) : Class(C) {}
+
+ /// getElementClass - Return the class that the list contains.
+ ///
+ Record *getElementClass() const { return Class; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(ListInit *LI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const;
};
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 72c5a230e5..a54f8e238b 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -116,6 +116,14 @@ Init *ListRecTy::convertValue(ListInit *LI) {
return LI;
}
+Init *ListRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with our class.
+ if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
+ if (LRT->getElementClass() == getElementClass())
+ return TI;
+ return 0;
+}
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
@@ -127,12 +135,12 @@ Init *RecordRecTy::convertValue(DefInit *DI) {
return DI;
}
-Init *RecordRecTy::convertValue(TypedInit *VI) {
- // Ensure that VI is compatible with Rec.
- if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(VI->getType()))
+Init *RecordRecTy::convertValue(TypedInit *TI) {
+ // Ensure that TI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(TI->getType()))
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
- return VI;
+ return TI;
return 0;
}
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index 356d131ae9..d94bb34504 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -108,7 +108,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(TypedInit *VI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const { OS << "string"; }
};
@@ -119,8 +119,14 @@ class ListRecTy : public RecTy {
Record *Class;
public:
ListRecTy(Record *C) : Class(C) {}
+
+ /// getElementClass - Return the class that the list contains.
+ ///
+ Record *getElementClass() const { return Class; }
+
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
Init *convertValue(ListInit *LI);
+ Init *convertValue(TypedInit *TI);
void print(std::ostream &OS) const;
};