Patterns with Multiple Stores

I want to write a pattern that looks something like this:

def : Pat<(unalignedstore (v2f64 VR128:$src), addr:$dst),
          (MOVSDmr ADD64ri8(addr:$dst, imm:8), ( SHUFPDrri (VR128:$src,
          (MOVSDmr addr:$dst, FR64:$src))), imm:3)

So I want to convert an unaligned vector store to a scalar store, a shuffle
and a scalar store.

There are several question I have:

- Is the imm:3 syntax correct? Basically I want to hard-code the shuffle mask

- The first MOVSD doesn't really "feed" the SHUFPD. How do I write the
  pattern to guarantee the MOVSD happens before the SHUFPD when the scheduler
  does its thing?

- How do I hard-code the immediate add that updates the store address for the
  high element? Again, I don't think imm:8 is right.

Is it possible to express this kind of thing in tblgen or do I have to write
custom code?

                                                 -Dave

I got a little further with this:

def : Pat<(unalignedstore (v2f64 VR128:$src), addr:$dst),
          (MOVSDmr (ADD64ri8 (LEA64r addr:$dst), 8), (MOVPD2SDrr (SHUFPDrri
(v2f64 VR128:$src), (v2f64 VR128:$src), 3)), (MOVSDmr addr:$dst, FR64:
$src))>;

Now tblgen (rightly) complains about MOVSDmr having too many operands. How do
I specify the dependency MOVSD->SHUFPD->MOVSD?

I'm a little nervous about the extra MOVPD2SDrr. It exists only to get the t
typing correct. I tried forcing the output of the SHUFPD to be typed f64 but
I couldn't get anything to work. As an alternative I could write a special
MOVSDrr pattern that accepts a v2f64. I'm hoping the MOVPD2SDrr will
just be coalesced away.

The bare "3" and "8" seem to be accepted.

So the only remaining problem is how to specify the dependencies. Is there an
example in another target that does this sort of thing?

                                            -Dave

No, there is currently no way to refer to the chain result of a node
in a pattern. Patches welcome :-).

Dan

Ok, I'll go with custom code for now.

I am interested in hacking tblgen since I've been trying to do that to support
more complex patterns. I have to learn a lot more about the guts, though.

I'll post some proposed patches and maybe we can have a good discussion.

                                              -Dave