diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-04 20:44:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-04 20:44:17 +0000 |
commit | 8e9a9774eb12b5242f74b8ac5b20e0a938ec9c53 (patch) | |
tree | 51b6211a3248d440a2d78f491a4ae9d68d80783d /support/tools/TableGen | |
parent | 7c1af88b8e5cf381635eeeddbcbd30e28e17e41c (diff) | |
download | external_llvm-8e9a9774eb12b5242f74b8ac5b20e0a938ec9c53.zip external_llvm-8e9a9774eb12b5242f74b8ac5b20e0a938ec9c53.tar.gz external_llvm-8e9a9774eb12b5242f74b8ac5b20e0a938ec9c53.tar.bz2 |
add support for DagInit initializers, which represent DAG patterns
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support/tools/TableGen')
-rw-r--r-- | support/tools/TableGen/Record.cpp | 11 | ||||
-rw-r--r-- | support/tools/TableGen/Record.h | 24 |
2 files changed, 34 insertions, 1 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 616c790..d47b50c 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -434,6 +434,17 @@ Init *FieldInit::resolveReferences(Record &R) { } +void DagInit::print(std::ostream &OS) const { + OS << "(" << NodeTypeDef->getName(); + if (Args.size()) { + OS << " " << *Args[0]; + for (unsigned i = 1, e = Args.size(); i != e; ++i) + OS << ", " << *Args[i]; + } + OS << ")"; +} + + //===----------------------------------------------------------------------===// // Other implementations //===----------------------------------------------------------------------===// diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index cb42f03..8b37dba 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -34,6 +34,7 @@ class StringInit; class CodeInit; class ListInit; class DefInit; +class DagInit; class TypedInit; class VarInit; class FieldInit; @@ -66,6 +67,7 @@ public: // These methods should only be called from subclasses of Init virtual Init *convertValue( CodeInit *CI) { return 0; } virtual Init *convertValue(VarBitInit *VB) { return 0; } virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } virtual Init *convertValue( TypedInit *TI) { return 0; } virtual Init *convertValue( VarInit *VI) { return convertValue((TypedInit*)VI); @@ -221,7 +223,7 @@ struct CodeRecTy : public RecTy { /// struct DagRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } - //Init *convertValue( DagInit *CI) { return (Init*)CI; } + Init *convertValue( DagInit *CI) { return (Init*)CI; } Init *convertValue(TypedInit *TI); void print(std::ostream &OS) const { OS << "dag"; } @@ -582,6 +584,26 @@ public: } }; +/// DagInit - (def a, b) - Represent a DAG tree value. DAG inits are required +/// to have Records for their first value, after that, any legal Init is +/// possible. +/// +class DagInit : public Init { + Record *NodeTypeDef; + std::vector<Init*> Args; +public: + DagInit(Record *D, std::vector<Init*> &a) : NodeTypeDef(D) { + Args.swap(a); // DESTRUCTIVELY take the arguments + } + + virtual Init *convertInitializerTo(RecTy *Ty) { + return Ty->convertValue(this); + } + + Record *getNodeType() const { return NodeTypeDef; } + + virtual void print(std::ostream &OS) const; +}; //===----------------------------------------------------------------------===// // High-Level Classes |