This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE2] Add the SVE2.1 quadword structured load/store instructions
ClosedPublic

Authored by david-arm on Nov 7 2022, 7:35 AM.

Details

Summary

This patch adds the assembly/disassembly for the following instructions:

ld2q : Contiguous load two-quadword structures to two vectors
ld3q : Contiguous load three-quadword structures to three vectors
ld4q : Contiguous load four-quadword structures to four vectors
st2q : Contiguous store two-quadword structures from two vectors
st3q : Contiguous store three-quadword structures to three vectors
st4q : Contiguous store four-quadword structures to four vectors

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

Diff Detail

Event Timeline

david-arm created this revision.Nov 7 2022, 7:35 AM
Herald added a project: Restricted Project. · View Herald Transcript
david-arm requested review of this revision.Nov 7 2022, 7:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 7:35 AM
david-arm added inline comments.Nov 7 2022, 7:37 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
1026–1042

I've tried to reuse the existing class by passing in an extra 'q' parameter, but the sz field changes meaning for quadword ops and in fact becomes nregs.

1462

It's difficult to reuse the existing sve_mem_est_si and sve_mem_est_ss classes because the sz/nregs fields are shifted, i.e.

sve_mem_est_si:

let Inst{24-23} = sz;
let Inst{22-21} = nregs;

sve_mem_128b_est_si:

let Inst{23-22} = nregs;
let Inst{21-20} = 0b00;
paulwalker-arm added inline comments.Nov 7 2022, 9:32 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
1462

Agreed. The new instructions sit within a different part of the encoding tables anyway and so having new instructions classes is the correct play.

llvm/lib/Target/AArch64/SVEInstrFormats.td
5813

Please add a comment for the encoding group.

5867

Please add a comment for the encoding group.

5921

typo?

7131–7133

You're being overly literal regarding the name of these parameters. They were likely picked to match the original encoding groups but looking at "SVE load multiple structures (scalar plus immediate)" they now just call {22-21} opc.

It's better for the variables to always be placed in the same part of the instruction. It doesn't really matter if the names don't exactly match. In this instance I think it'll be better to replace nregs and q with a 3-bit opc. You may as well keep sz even though it means something different for the quadword variants, because it matters not. However, if you don't like keeping sz then just make opc a 5-bit opcode instead.

7163–7164

As above.

Matt added a subscriber: Matt.Nov 7 2022, 12:40 PM
david-arm added inline comments.Nov 8 2022, 5:34 AM
llvm/lib/Target/AArch64/SVEInstrFormats.td
7131–7133

The main reason I chose to write it like this is because otherwise the list of instructions in AArch64SVEInstrInfo.td just looks weird/inconsistent, i.e.

defm LD2D_IMM : sve_mem_eld_si<0b11, 0b001, ZZ_d,   "ld2d", simm4s2>;
defm LD3D_IMM : sve_mem_eld_si<0b11, 0b010, ZZZ_d,  "ld3d", simm4s3>;
defm LD4D_IMM : sve_mem_eld_si<0b11, 0b011, ZZZZ_d, "ld4d", simm4s4>;
let Predicates = [HasSVE2p1_or_HasSME2p1] in {
defm LD2Q_IMM : sve_mem_eld_si<0b01, 0b100, ZZ_q,   "ld2q", simm4s2>;
defm LD3Q_IMM : sve_mem_eld_si<0b10, 0b100, ZZZ_q,  "ld3q", simm4s3>;
defm LD4Q_IMM : sve_mem_eld_si<0b11, 0b100, ZZZZ_q, "ld4q", simm4s4>;
}

because the quadword variants don't follow the pattern of the ones above. I guess it's a choice between having a potentially confusing instruction class format, or a confusing list of instructions. I don't really mind though or feel strongly about it - happy to go with the latter!

paulwalker-arm added inline comments.Nov 8 2022, 8:20 AM
llvm/lib/Target/AArch64/SVEInstrFormats.td
7131–7133

In this instance my preference is simpler instruction classes. I don't find the above a confusing list of instructions, but then I know the bit patterns are arbitrary and so don't attach meaning to them :)

david-arm updated this revision to Diff 474014.Nov 8 2022, 8:22 AM
  • Refactored load classes.
david-arm marked 7 inline comments as done.Nov 8 2022, 8:23 AM
paulwalker-arm accepted this revision.Nov 8 2022, 8:46 AM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/SVEInstrFormats.td
7131–7133

Personally I would have kept it simple with Inst{22-20} = nregs, so that everything reads left to right, but there's nothing here I can't live with.

This revision is now accepted and ready to land.Nov 8 2022, 8:46 AM