[Mesa-dev] [PATCH 1/5] glsl: Move get_error_instruction() from ir_call to ir_constant.

Paul Berry stereotype441 at gmail.com
Wed Sep 21 12:05:40 PDT 2011


On 21 September 2011 10:21, Eric Anholt <eric at anholt.net> wrote:

> On Tue, 20 Sep 2011 18:28:15 -0700, Kenneth Graunke <kenneth at whitecape.org>
> wrote:
> > All this does is generate a bogus value with error type; the fact that
> > it was in ir_call was rather arbitrary to begin with. ir_constant is an
> > equally arbitrary place. The rationale is that a future commit will
> > change ir_calls from rvalues to statements, and all uses of this
> > function expect an rvalue.
>
> This would make a lot more sense to me as a global
> "get_error_rvalue(ctx)" instead of a method of some arbitrary class.
>

I guess there are two questions to be answered here:

1. What type of object should we use as a placeholder in the IR for errors?
2. Where should we put the factory method that creates this object?

As to question 1, we have to choose some type, and short of creating a brand
new type to represent errors (which seems wasteful and possibly bug-prone),
ir_constant is as good as any.  It's certainly better than ir_call for the
reasons Ken stated.

As to question 2, I agree that making this a static method of ir_constant
seems kind of arbitrary--ideally the caller shouldn't know or care that the
factory method creates an ir_constant.  But I'd prefer to make it a static
method of some class so that it's less likely to be stumbled upon by someone
who doesn't need it.  How about making it a static method of ir_rvalue?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110921/ec2d85d3/attachment.htm>


More information about the mesa-dev mailing list