/** Loop containing this break instruction. */
ir_loop *loop;
};
+
+/**
+ * IR instruction representing discard statements.
+ */
+class ir_discard : public ir_jump {
+public:
+ ir_discard()
+ {
+ this->condition = NULL;
+ }
+
+ ir_discard(ir_rvalue *cond)
+ {
+ this->condition = cond;
+ }
+
+ virtual ir_instruction *clone(struct hash_table *ht) const;
+
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
+ virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+
+ ir_rvalue *condition;
+};
/*@}*/
return new(ctx) ir_return(new_value);
}
+ir_instruction *
+ir_discard::clone(struct hash_table *ht) const
+{
+ void *ctx = talloc_parent(this);
+ ir_rvalue *new_condition = NULL;
+
+ if (this->condition != NULL)
+ new_condition = (ir_rvalue *) this->condition->clone(ht);
+
+ return new(ctx) ir_discard(new_condition);
+}
+
ir_instruction *
ir_loop_jump::clone(struct hash_table *ht) const
{
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(ir_return *);
+ virtual void visit(ir_discard *);
virtual void visit(ir_if *);
virtual void visit(ir_loop *);
virtual void visit(ir_loop_jump *);
}
+void
+ir_constant_visitor::visit(ir_discard *ir)
+{
+ (void) ir;
+ value = NULL;
+}
+
+
void
ir_constant_visitor::visit(ir_if *ir)
{
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(ir_return *);
+ virtual void visit(ir_discard *);
virtual void visit(ir_if *);
virtual void visit(ir_loop *);
virtual void visit(ir_loop_jump *);
}
+void
+ir_constant_folding_visitor::visit(ir_discard *ir)
+{
+ (void) ir;
+}
+
+
void
ir_constant_folding_visitor::visit(ir_if *ir)
{
return visit_continue;
}
+ir_visitor_status
+ir_hierarchical_visitor::visit_enter(ir_discard *ir)
+{
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
+ return visit_continue;
+}
+
+ir_visitor_status
+ir_hierarchical_visitor::visit_leave(ir_discard *ir)
+{
+ (void) ir;
+ return visit_continue;
+}
+
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_if *ir)
{
virtual ir_visitor_status visit_leave(class ir_call *);
virtual ir_visitor_status visit_enter(class ir_return *);
virtual ir_visitor_status visit_leave(class ir_return *);
+ virtual ir_visitor_status visit_enter(class ir_discard *);
+ virtual ir_visitor_status visit_leave(class ir_discard *);
virtual ir_visitor_status visit_enter(class ir_if *);
virtual ir_visitor_status visit_leave(class ir_if *);
/*@}*/
}
+ir_visitor_status
+ir_discard::accept(ir_hierarchical_visitor *v)
+{
+ ir_visitor_status s = v->visit_enter(this);
+ if (s != visit_continue)
+ return (s == visit_continue_with_parent) ? visit_continue : s;
+
+ if (this->condition != NULL) {
+ s = this->condition->accept(v);
+ if (s != visit_continue)
+ return (s == visit_continue_with_parent) ? visit_continue : s;
+ }
+
+ return v->visit_leave(this);
+}
+
+
ir_visitor_status
ir_if::accept(ir_hierarchical_visitor *v)
{
}
+void
+ir_print_visitor::visit(ir_discard *ir)
+{
+ printf("(discard ");
+
+ if (ir->condition != NULL) {
+ printf(" ");
+ ir->condition->accept(this);
+ }
+
+ printf(")");
+}
+
+
void
ir_print_visitor::visit(ir_if *ir)
{
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(ir_return *);
+ virtual void visit(ir_discard *);
virtual void visit(ir_if *);
virtual void visit(ir_loop *);
virtual void visit(ir_loop_jump *);
virtual void visit(class ir_constant *) = 0;
virtual void visit(class ir_call *) = 0;
virtual void visit(class ir_return *) = 0;
+ virtual void visit(class ir_discard *) = 0;
virtual void visit(class ir_if *) = 0;
virtual void visit(class ir_loop *) = 0;
virtual void visit(class ir_loop_jump *) = 0;
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(ir_return *);
+ virtual void visit(ir_discard *);
virtual void visit(ir_texture *);
virtual void visit(ir_if *);
/*@}*/
ir->get_value()->accept(this);
}
+void
+ir_to_mesa_visitor::visit(ir_discard *ir)
+{
+ assert(0);
+
+ ir->condition->accept(this);
+}
void
ir_to_mesa_visitor::visit(ir_if *ir)