Add initial support for a new 'dag' type
authorChris Lattner <sabre@nondot.org>
Mon, 4 Aug 2003 04:50:57 +0000 (04:50 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 4 Aug 2003 04:50:57 +0000 (04:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7559 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/FileLexer.l
support/tools/TableGen/FileParser.y
support/tools/TableGen/Record.cpp
support/tools/TableGen/Record.h
utils/TableGen/FileLexer.l
utils/TableGen/FileParser.y
utils/TableGen/Record.cpp
utils/TableGen/Record.h

index ad4bd77703ae11038ff5ece2015180841d6dfad3..8ab400610d02152804f9d868da15330219b85413 100644 (file)
@@ -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; }
index 4025d4e2315dea5f6686c0b0fff22cc121dbec2e..0c5b240d3079293c0ebff80b5c8de4fefebf15d3 100644 (file)
@@ -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);
   };
index 781fecf82048334de151924e3133a8ef1246ef5a..968f367bd7a832f14b85db8aa92e0cbca4aec501 100644 (file)
@@ -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();
 }
index f933d4ff52693785a9e13cdb94c5f14b342b3b77..4573af0ee7f4c453003b27d2f8e2da0d441eb24c 100644 (file)
@@ -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).
index ad4bd77703ae11038ff5ece2015180841d6dfad3..8ab400610d02152804f9d868da15330219b85413 100644 (file)
@@ -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; }
index 4025d4e2315dea5f6686c0b0fff22cc121dbec2e..0c5b240d3079293c0ebff80b5c8de4fefebf15d3 100644 (file)
@@ -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);
   };
index 781fecf82048334de151924e3133a8ef1246ef5a..968f367bd7a832f14b85db8aa92e0cbca4aec501 100644 (file)
@@ -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();
 }
index f933d4ff52693785a9e13cdb94c5f14b342b3b77..4573af0ee7f4c453003b27d2f8e2da0d441eb24c 100644 (file)
@@ -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).