RFC: X86InstrFormats.td Refactoring

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

RFC: X86InstrFormats.td Refactoring

dag-7
There is some redundancy at the instruction format level in the x86 .td files.  
For example, in X86InstrFormats.td:

// SSE1 Instruction Templates:
//
//   SSI   - SSE1 instructions with XS prefix.

class SSI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
pattern>
      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE1]>;

// SSE3 Instruction Templates:
//   S3SI   - SSE3 instructions with XSrefix.

class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
pattern>
      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE3]>;

The only difference here is the parameter to Requires.  There are many more
examples and this gets worse with AVX.

I'd like to propose a refactoring that looks something like this:

// SSE Instruction Templates:
//
//  SSI - SSE Instructions with XS prefix

class SSI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
pattern>
      : I<o, F, outs, ins, asm, pattern>, XS;

/./ SSE1 Instruction Templates
//
//  S1SI - SSE1 instructions with Xs prefix

class S1SI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
pattern>
      : SSI<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;

This way we can reuse the SSI class and hide encoding details for many SSE
levels and AVX.

Sound good?

                                             -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: RFC: X86InstrFormats.td Refactoring

dag-7
On Monday 30 March 2009 16:12, David Greene wrote:

> There is some redundancy at the instruction format level in the x86 .td
> files. For example, in X86InstrFormats.td:
>
> // SSE1 Instruction Templates:
> //
> //   SSI   - SSE1 instructions with XS prefix.
>
> class SSI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
> pattern>
>
>       : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE1]>;
>
> // SSE3 Instruction Templates:
> //   S3SI   - SSE3 instructions with XSrefix.
>
> class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
> pattern>
>
>       : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE3]>;
>
> The only difference here is the parameter to Requires.  There are many more
> examples and this gets worse with AVX.
>
> I'd like to propose a refactoring that looks something like this:
>
> // SSE Instruction Templates:
> //
> //  SSI - SSE Instructions with XS prefix
>
> class SSI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
> pattern>
>
>       : I<o, F, outs, ins, asm, pattern>, XS;
>
> /./ SSE1 Instruction Templates
> //
> //  S1SI - SSE1 instructions with Xs prefix
>
> class S1SI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag>
> pattern>
>
>       : SSI<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;

Actually, I meant to keep the existing class names intact to avoid global
changes.  So what I'm proposing is actually:

 class SSIb<bits<8> o, Format F, dag outs, dag ins, string asm,
   list<dag>  pattern>  : I<o, F, outs, ins, asm, pattern>, XS;

class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  list<dag> pattern>
       : SSIb<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;

                                           -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: RFC: X86InstrFormats.td Refactoring

Dan Gohman-2

On Mar 30, 2009, at 2:53 PM, David Greene wrote:

> On Monday 30 March 2009 16:12, David Greene wrote:
>> There is some redundancy at the instruction format level in the  
>> x86 .td
>> files. For example, in X86InstrFormats.td:
>>
>> // SSE1 Instruction Templates:
>> //
>> //   SSI   - SSE1 instructions with XS prefix.
>>
>> class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,  
>> list<dag>
>> pattern>
>>
>>      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE1]>;
>>
>> // SSE3 Instruction Templates:
>> //   S3SI   - SSE3 instructions with XSrefix.
>>
>> class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,  
>> list<dag>
>> pattern>
>>
>>      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE3]>;
>>
>> The only difference here is the parameter to Requires.  There are  
>> many more
>> examples and this gets worse with AVX.

[...]

> Actually, I meant to keep the existing class names intact to avoid  
> global
> changes.  So what I'm proposing is actually:
>
> class SSIb<bits<8> o, Format F, dag outs, dag ins, string asm,
>   list<dag>  pattern>  : I<o, F, outs, ins, asm, pattern>, XS;
>
> class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
>  list<dag> pattern>
>       : SSIb<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;


Is this just factoring out the ", XS" part? As presented, it looks like
this change would introduce more redundancy that it would eliminate.

Dan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: RFC: X86InstrFormats.td Refactoring

dag-7
On Tuesday 31 March 2009 13:53, Dan Gohman wrote:

> > class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
> >  list<dag> pattern>
> >
> >       : SSIb<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;
>
> Is this just factoring out the ", XS" part? As presented, it looks like
> this change would introduce more redundancy that it would eliminate.

It's factoring out XS and the other encoding bits, but the real goal is to
separate out the Requires<> predicates.  Doing this will help AVX quite a bit
as we'd like to build AVX format classes off of the existing ones.  Most of
AVX simply recodes existing SSE instructions using the VEX prefix so it makes
sense to use the infrastructure already there.  The problem is the Requires<>
parts are all inappropriate so we need to factor them out.

                                                        -Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: RFC: X86InstrFormats.td Refactoring

Dan Gohman-2

On Mar 31, 2009, at 1:01 PM, David Greene wrote:

> On Tuesday 31 March 2009 13:53, Dan Gohman wrote:
>
>>> class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
>>> list<dag> pattern>
>>>
>>>      : SSIb<o, F, outs, ins, asm, pattern>, Requires<HasSSE1>;
>>
>> Is this just factoring out the ", XS" part? As presented, it looks  
>> like
>> this change would introduce more redundancy that it would eliminate.
>
> It's factoring out XS and the other encoding bits, but the real goal  
> is to
> separate out the Requires<> predicates.  Doing this will help AVX  
> quite a bit
> as we'd like to build AVX format classes off of the existing ones.  
> Most of
> AVX simply recodes existing SSE instructions using the VEX prefix so  
> it makes
> sense to use the infrastructure already there.  The problem is the  
> Requires<>
> parts are all inappropriate so we need to factor them out.


Ok. I have no real objection to this. I look
forward to seeing how it helps in the context of
the rest of the changes :-).

Dan

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev