[llvm-commits] CVS: llvm/utils/TableGen/Record.h Record.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Aug 4 15:45:09 PDT 2003
Changes in directory llvm/utils/TableGen:
Record.h updated: 1.29 -> 1.30
Record.cpp updated: 1.24 -> 1.25
---
Log message:
add support for DagInit initializers, which represent DAG patterns
---
Diffs of the changes:
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.29 llvm/utils/TableGen/Record.h:1.30
--- llvm/utils/TableGen/Record.h:1.29 Sun Aug 3 23:53:50 2003
+++ llvm/utils/TableGen/Record.h Mon Aug 4 15:44:17 2003
@@ -34,6 +34,7 @@
class CodeInit;
class ListInit;
class DefInit;
+class DagInit;
class TypedInit;
class VarInit;
class FieldInit;
@@ -66,6 +67,7 @@
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 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 @@
}
};
+/// 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
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.24 llvm/utils/TableGen/Record.cpp:1.25
--- llvm/utils/TableGen/Record.cpp:1.24 Sun Aug 3 23:53:50 2003
+++ llvm/utils/TableGen/Record.cpp Mon Aug 4 15:44:17 2003
@@ -434,6 +434,17 @@
}
+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
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list