git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132636
91177308-0d34-0410-b5e6-
96231b3b80d8
// (sequence "Format", From, To) Generate a sequence of records by name.
struct SequenceOp : public SetTheory::Operator {
// (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): " +
void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) {
if (Expr->arg_size() != 3)
throw "Bad args to (sequence \"Format\", From, To): " +
else
throw "From must be an integer: " + Expr->getAsString();
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;
int Step = From <= To ? 1 : -1;
for (To += Step; From != To; From += Step) {
std::string Name;
};
} // end anonymous namespace
};
} // end anonymous namespace
-SetTheory::SetTheory(RecordKeeper *Records) {
+SetTheory::SetTheory() {
addOperator("add", new AddOp);
addOperator("sub", new SubOp);
addOperator("and", new AndOp);
addOperator("add", new AddOp);
addOperator("sub", new SubOp);
addOperator("and", new AndOp);
addOperator("rotl", new RotOp(false));
addOperator("rotr", new RotOp(true));
addOperator("decimate", new DecimateOp);
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) {
}
void SetTheory::addOperator(StringRef Name, Operator *Op) {
public:
/// Create a SetTheory instance with only the standard operators.
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);
/// addExpander - Add an expander for Records with the named super class.
void addExpander(StringRef ClassName, Expander*);
/// addExpander - Add an expander for Records with the named super class.
void addExpander(StringRef ClassName, Expander*);
- SetTheory Sets(&Records);
Sets.addFieldExpander("Set", "Elements");
std::vector<Record*> Recs = Records.getAllDerivedDefinitions("Set");
for (unsigned i = 0, e = Recs.size(); i != e; ++i) {
Sets.addFieldExpander("Set", "Elements");
std::vector<Record*> Recs = Records.getAllDerivedDefinitions("Set");
for (unsigned i = 0, e = Recs.size(); i != e; ++i) {