[PATCH 1/2] TableGen: Generate a function for getting operand indices based on their defined names

Tom Stellard tom at stellard.net
Thu Jun 20 12:45:46 PDT 2013


On Thu, Jun 20, 2013 at 11:10:15AM -0700, Sean Silva wrote:
> On Thu, Jun 20, 2013 at 10:58 AM, Tom Stellard <tom at stellard.net> wrote:
> 
> > Hi Sean,
> >
> > Attached is an updated patch which addresses your comments.
> >
> > On Wed, Jun 19, 2013 at 12:52:03PM -0700, Sean Silva wrote:
> > > +.. code-block:: llvm
> > >
> > > This should be a `c++` code block, since this is c++ code (this
> > determines
> > > how it is syntax-highlighted).
> > >
> > > +  int DIndex = SP::getNamedOperandIdx(SP::XNORrr, SP::OpName::d);     //
> > > => -1
> > >
> > > Does it even make sense to return -1 for "not found"?
> > >
> >
> > Do you think we should be returning some other value for "not found"?
> >
> 
> Sorry, let me rephrase. Does -1 ever get returned, or is it a "can't
> happen"? My intuition is that generally if you are calling this function
> you need a valid result, right?
>

-1 can be returned.  For example, in the AMDGPU ISA, most floating-point
instructions have a "clamp" bit which can be set to clamp the output of an
instruction between 0.0f and 1.0f before writing the result to a
register.  We have an optimization which tries to fold "clamp"
computations into instructions by setting this bit, but since not all
instructions have the clamp bit, we use the getNamedOperandIdx function
to see if an instruction has this bit before we try to do the folding.

-Tom



More information about the llvm-commits mailing list