};
+/**
+ * IR instruction representing a high-level loop structure.
+ */
+class ir_loop : public ir_instruction {
+public:
+ ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL)
+ {
+ /* empty */
+ }
+
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
+ /**
+ * Get an iterator for the instructions of the loop body
+ */
+ exec_list_iterator iterator()
+ {
+ return body_instructions.iterator();
+ }
+
+ /** List of instructions that make up the body of the loop. */
+ exec_list body_instructions;
+
+ /**
+ * \name Loop counter and controls
+ */
+ /*@{*/
+ ir_rvalue *from;
+ ir_rvalue *to;
+ ir_rvalue *increment;
+ ir_variable *counter;
+ /*@}*/
+};
+
+
class ir_assignment : public ir_rvalue {
public:
ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition);
virtual void visit(ir_call *);
virtual void visit(ir_return *);
virtual void visit(ir_if *);
+ virtual void visit(ir_loop *);
/*@}*/
/**
(void) ir;
value = NULL;
}
+
+
+void
+ir_constant_visitor::visit(ir_loop *ir)
+{
+ (void) ir;
+ value = NULL;
+}
visit_exec_list(&ir->then_instructions, this);
visit_exec_list(&ir->else_instructions, this);
}
+
+
+void
+ir_constant_folding_visitor::visit(ir_loop *ir)
+{
+ (void) ir;
+}
virtual void visit(ir_call *);
virtual void visit(ir_return *);
virtual void visit(ir_if *);
+ virtual void visit(ir_loop *);
/*@}*/
};
}
printf("))\n");
}
+
+
+void
+ir_print_visitor::visit(ir_loop *ir)
+{
+ printf("(loop (");
+ if (ir->counter != NULL)
+ ir->counter->accept(this);
+ printf(") (");
+ if (ir->from != NULL)
+ ir->from->accept(this);
+ printf(") (");
+ if (ir->to != NULL)
+ ir->to->accept(this);
+ printf(") (");
+ if (ir->increment != NULL)
+ ir->increment->accept(this);
+ printf(") (");
+ foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
+ ir_instruction *const inst = (ir_instruction *) iter.get();
+
+ inst->accept(this);
+ }
+ printf("))\n");
+}
virtual void visit(ir_call *);
virtual void visit(ir_return *);
virtual void visit(ir_if *);
+ virtual void visit(ir_loop *);
/*@}*/
private:
virtual void visit(class ir_call *) = 0;
virtual void visit(class ir_return *) = 0;
virtual void visit(class ir_if *) = 0;
+ virtual void visit(class ir_loop *) = 0;
/*@}*/
};