diff options
-rw-r--r-- | utils/TableGen/SetTheory.cpp | 12 | ||||
-rw-r--r-- | utils/TableGen/SetTheory.h | 3 | ||||
-rw-r--r-- | utils/TableGen/TableGen.cpp | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index e168b549bc..ade1825576 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -140,10 +140,6 @@ struct DecimateOp : public SetIntBinOp { // (sequence "Format", From, To) Generate a sequence of records by name. struct SequenceOp : public SetTheory::Operator { - RecordKeeper &Records; - - SequenceOp(RecordKeeper&R) : Records(R) {} - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 3) throw "Bad args to (sequence \"Format\", From, To): " + @@ -164,6 +160,9 @@ struct SequenceOp : public SetTheory::Operator { else throw "From must be an integer: " + Expr->getAsString(); + RecordKeeper &Records = + dynamic_cast<DefInit&>(*Expr->getOperator()).getDef()->getRecords(); + int Step = From <= To ? 1 : -1; for (To += Step; From != To; From += Step) { std::string Name; @@ -193,7 +192,7 @@ struct FieldExpander : public SetTheory::Expander { }; } // end anonymous namespace -SetTheory::SetTheory(RecordKeeper *Records) { +SetTheory::SetTheory() { addOperator("add", new AddOp); addOperator("sub", new SubOp); addOperator("and", new AndOp); @@ -202,8 +201,7 @@ SetTheory::SetTheory(RecordKeeper *Records) { addOperator("rotl", new RotOp(false)); addOperator("rotr", new RotOp(true)); addOperator("decimate", new DecimateOp); - if (Records) - addOperator("sequence", new SequenceOp(*Records)); + addOperator("sequence", new SequenceOp); } void SetTheory::addOperator(StringRef Name, Operator *Op) { diff --git a/utils/TableGen/SetTheory.h b/utils/TableGen/SetTheory.h index 2202f22396..e37a76ee68 100644 --- a/utils/TableGen/SetTheory.h +++ b/utils/TableGen/SetTheory.h @@ -96,8 +96,7 @@ private: public: /// Create a SetTheory instance with only the standard operators. - /// A 'sequence' operator will only be added if a RecordKeeper is given. - SetTheory(RecordKeeper *Records = 0); + SetTheory(); /// addExpander - Add an expander for Records with the named super class. void addExpander(StringRef ClassName, Expander*); diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 925b134ca4..4e4da366ae 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -380,7 +380,7 @@ int main(int argc, char **argv) { } case PrintSets: { - SetTheory Sets(&Records); + SetTheory Sets; Sets.addFieldExpander("Set", "Elements"); std::vector<Record*> Recs = Records.getAllDerivedDefinitions("Set"); for (unsigned i = 0, e = Recs.size(); i != e; ++i) { |