This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE2] Add the SVE2.1 BF16 instructions
ClosedPublic

Authored by david-arm on Nov 3 2022, 2:29 AM.

Details

Summary

This patch adds the new FEAT_B16B16 feature as well as the
assembly/disassembly for all of the B16B16 instructions:

bfadd: BFloat16 floating-point add vectors
bfsub: BFloat16 floating-point subtract vectors
bfmul: BFloat16 floating-point multiply vectors
bfclamp: BFloat16 floating-point clamp to minimum/maximum number
bfmax: BFloat16 floating-point maximum
bfmaxnm: BFloat16 floating-point maximum number
bfmin: BFloat16 floating-point minimum
bfminnm: BFloat16 floating-point minimum number
bfmla: BFloat16 floating-point fused multiply-add vectors
bfmls: BFloat16 floating-point fused multiply-subtract 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 3 2022, 2:29 AM
Herald added a project: Restricted Project. · View Herald Transcript
david-arm requested review of this revision.Nov 3 2022, 2:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 2:29 AM
c-rhodes added inline comments.
llvm/lib/Target/AArch64/AArch64.td
166

unrelated to this patch but I noticed this is missing (FEAT_SVE2p1) like the other feature descriptions

169

BFloat16 to BFloat16

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
3701

SVE2.1 or SME2.1 non-widening BFloat16 to BFloat16 instructions?

llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
22
llvm/lib/Target/AArch64/SVEInstrFormats.td
2195

single def so this should be a class

2195

sve2p1 like the class below?

2257

single def so this should be a class

llvm/test/MC/AArch64/SVE2p1/bfadd-diagnostics.s
7

movprfx is only necessary for the last test

14

only merging predication can be specified? This test is no different from the above, I'd either remove it or change it so the predicate register is valid but with zeroing prediction.

23

m

28–35

not sure what's going on here, it's the unpredicated form that can't be preceded by movprfx?

llvm/test/MC/AArch64/SVE2p1/bfmax-diagnostics.s
7

same comments as bfadd-diagnostics.s apply here

llvm/test/MC/AArch64/SVE2p1/bfmaxnm-diagnostics.s
7

same comments as bfadd-diagnostics.s apply here

llvm/test/MC/AArch64/SVE2p1/bfmin-diagnostics.s
7

same comments as bfadd-diagnostics.s apply here

llvm/test/MC/AArch64/SVE2p1/bfminnm-diagnostics.s
7

same comments as bfadd-diagnostics.s apply here

paulwalker-arm added inline comments.Nov 4 2022, 6:04 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
3707–3708

Do you mind grouping these by class and adding a space between those groups?

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

Can this just be bits<2> opc? given it's really a 2-bit opcode and then push this on to the uses of sve_fp_fma_by_indexed_elem rather than hiding the fact within sve_fp_fma_by_indexed_elem.

2195

Whilst true, ultimately we're going to require code gen patterns so we'll need this to be a multiclass later on anyway.

Matt added a subscriber: Matt.Nov 5 2022, 8:34 PM
david-arm updated this revision to Diff 473592.Nov 7 2022, 1:17 AM
david-arm marked 18 inline comments as done.
  • Rebased on top of D137410 to pick up the SME2p1 feature.
  • Corrected some tests that were a bit confused with regards to movprfx.
  • Tidied up some of the classes and instruction layouts.
llvm/lib/Target/AArch64/SVEInstrFormats.td
2257

Given Paul's comments above I've just left this as a multiclass if that's ok?

c-rhodes accepted this revision.Nov 7 2022, 5:25 AM
c-rhodes added inline comments.
llvm/lib/Target/AArch64/SVEInstrFormats.td
2257

Given Paul's comments above I've just left this as a multiclass if that's ok?

sure that's fine

This revision is now accepted and ready to land.Nov 7 2022, 5:25 AM
This revision was landed with ongoing or failed builds.Nov 7 2022, 7:30 AM
This revision was automatically updated to reflect the committed changes.