summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/FileLexer.l1
-rw-r--r--support/tools/TableGen/FileParser.y4
-rw-r--r--support/tools/TableGen/Record.cpp7
-rw-r--r--support/tools/TableGen/Record.h17
-rw-r--r--utils/TableGen/FileLexer.l1
-rw-r--r--utils/TableGen/FileParser.y4
-rw-r--r--utils/TableGen/Record.cpp7
-rw-r--r--utils/TableGen/Record.h17
8 files changed, 56 insertions, 2 deletions
diff --git a/support/tools/TableGen/FileLexer.l b/support/tools/TableGen/FileLexer.l
index ad4bd77703..8ab400610d 100644
--- a/support/tools/TableGen/FileLexer.l
+++ b/support/tools/TableGen/FileLexer.l
@@ -154,6 +154,7 @@ bits { return BITS; }
string { return STRING; }
list { return LIST; }
code { return CODE; }
+dag { return DAG; }
class { return CLASS; }
def { return DEF; }
diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y
index 4025d4e231..0c5b240d30 100644
--- a/support/tools/TableGen/FileParser.y
+++ b/support/tools/TableGen/FileParser.y
@@ -168,7 +168,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
std::vector<SubClassRefTy> *SubClassList;
};
-%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN
+%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD SET IN
%token <IntVal> INTVAL
%token <StrVal> ID STRVAL CODEFRAGMENT
@@ -209,6 +209,8 @@ Type : STRING { // string type
$$ = new ListRecTy($3);
} | CODE { // code type
$$ = new CodeRecTy();
+ } | DAG { // dag type
+ $$ = new DagRecTy();
} | ClassID { // Record Type
$$ = new RecordRecTy($1);
};
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index 781fecf820..968f367bd7 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -146,6 +146,13 @@ Init *ListRecTy::convertValue(TypedInit *TI) {
return 0;
}
+Init *DagRecTy::convertValue(TypedInit *TI) {
+ if (TI->getType()->typeIsConvertibleTo(this))
+ return TI;
+ return 0;
+}
+
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h
index f933d4ff52..4573af0ee7 100644
--- a/support/tools/TableGen/Record.h
+++ b/support/tools/TableGen/Record.h
@@ -21,6 +21,7 @@ class IntRecTy;
class StringRecTy;
class ListRecTy;
class CodeRecTy;
+class DagRecTy;
class RecordRecTy;
// Init subclasses...
@@ -82,6 +83,7 @@ public: // These methods should only be called by subclasses of RecTy.
virtual bool baseClassOf(const StringRecTy *RHS) const { return false; }
virtual bool baseClassOf(const ListRecTy *RHS) const { return false; }
virtual bool baseClassOf(const CodeRecTy *RHS) const { return false; }
+ virtual bool baseClassOf(const DagRecTy *RHS) const { return false; }
virtual bool baseClassOf(const RecordRecTy *RHS) const { return false; }
};
@@ -214,6 +216,21 @@ struct CodeRecTy : public RecTy {
virtual bool baseClassOf(const CodeRecTy *RHS) const { return true; }
};
+/// DagRecTy - 'dag' - Represent a dag fragment
+///
+struct DagRecTy : public RecTy {
+ Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
+ //Init *convertValue( DagInit *CI) { return (Init*)CI; }
+ Init *convertValue(TypedInit *TI);
+
+ void print(std::ostream &OS) const { OS << "dag"; }
+
+ bool typeIsConvertibleTo(const RecTy *RHS) const {
+ return RHS->baseClassOf(this);
+ }
+ virtual bool baseClassOf(const DagRecTy *RHS) const { return true; }
+};
+
/// RecordRecTy - '<classname>' - Represent an instance of a class, such as:
/// (R32 X = EAX).
diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l
index ad4bd77703..8ab400610d 100644
--- a/utils/TableGen/FileLexer.l
+++ b/utils/TableGen/FileLexer.l
@@ -154,6 +154,7 @@ bits { return BITS; }
string { return STRING; }
list { return LIST; }
code { return CODE; }
+dag { return DAG; }
class { return CLASS; }
def { return DEF; }
diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y
index 4025d4e231..0c5b240d30 100644
--- a/utils/TableGen/FileParser.y
+++ b/utils/TableGen/FileParser.y
@@ -168,7 +168,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
std::vector<SubClassRefTy> *SubClassList;
};
-%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN
+%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD SET IN
%token <IntVal> INTVAL
%token <StrVal> ID STRVAL CODEFRAGMENT
@@ -209,6 +209,8 @@ Type : STRING { // string type
$$ = new ListRecTy($3);
} | CODE { // code type
$$ = new CodeRecTy();
+ } | DAG { // dag type
+ $$ = new DagRecTy();
} | ClassID { // Record Type
$$ = new RecordRecTy($1);
};
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 781fecf820..968f367bd7 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -146,6 +146,13 @@ Init *ListRecTy::convertValue(TypedInit *TI) {
return 0;
}
+Init *DagRecTy::convertValue(TypedInit *TI) {
+ if (TI->getType()->typeIsConvertibleTo(this))
+ return TI;
+ return 0;
+}
+
+
void RecordRecTy::print(std::ostream &OS) const {
OS << Rec->getName();
}
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index f933d4ff52..4573af0ee7 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -21,6 +21,7 @@ class IntRecTy;
class StringRecTy;
class ListRecTy;
class CodeRecTy;
+class DagRecTy;
class RecordRecTy;
// Init subclasses...
@@ -82,6 +83,7 @@ public: // These methods should only be called by subclasses of RecTy.
virtual bool baseClassOf(const StringRecTy *RHS) const { return false; }
virtual bool baseClassOf(const ListRecTy *RHS) const { return false; }
virtual bool baseClassOf(const CodeRecTy *RHS) const { return false; }
+ virtual bool baseClassOf(const DagRecTy *RHS) const { return false; }
virtual bool baseClassOf(const RecordRecTy *RHS) const { return false; }
};
@@ -214,6 +216,21 @@ struct CodeRecTy : public RecTy {
virtual bool baseClassOf(const CodeRecTy *RHS) const { return true; }
};
+/// DagRecTy - 'dag' - Represent a dag fragment
+///
+struct DagRecTy : public RecTy {
+ Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
+ //Init *convertValue( DagInit *CI) { return (Init*)CI; }
+ Init *convertValue(TypedInit *TI);
+
+ void print(std::ostream &OS) const { OS << "dag"; }
+
+ bool typeIsConvertibleTo(const RecTy *RHS) const {
+ return RHS->baseClassOf(this);
+ }
+ virtual bool baseClassOf(const DagRecTy *RHS) const { return true; }
+};
+
/// RecordRecTy - '<classname>' - Represent an instance of a class, such as:
/// (R32 X = EAX).