This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Implement __jcvt intrinsic from Armv8.3-A
ClosedPublic

Authored by ktkachov on Jul 10 2019, 7:27 AM.

Details

Summary

The jcvt intrinsic defined in ACLE [1] is available when ARM_FEATURE_JCVT is defined.

This change introduces the AArch64 intrinsic, wires it up to the instruction and a new clang builtin function.
The __ARM_FEATURE_JCVT macro is now defined when an Armv8.3-A or higher target is used.
I've implemented the target detection logic in Clang so that this feature is enabled for architectures from armv8.3-a onwards (so -march=armv8.4-a also enables this, for example).

make check-all didn't show any new failures.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics

N.B. This is my first patch to LLVM. Apologies if some code looks weird. If this is okay can somebody please apply it for me?

Diff Detail

Repository
rL LLVM

Event Timeline

ktkachov created this revision.Jul 10 2019, 7:27 AM
SjoerdMeijer added inline comments.Jul 10 2019, 7:44 AM
clang/lib/Basic/Targets/AArch64.cpp
237 ↗(On Diff #208951)

It is a good change, but I think you should either add tests for these cases, or remove this (temporarily) because it is not adding much at the moment.

clang/test/CodeGen/arm_acle.c
829 ↗(On Diff #208951)

Same comment, better is to do a CHECK-LABEL first

clang/test/CodeGen/builtins-arm64.c
61 ↗(On Diff #208951)

Although this file doesn't seem to do this, better is check the function name first, e.g.:

// CHECK-LABEL: @jcvt(

followed by what you want to check:

//CHECK: call i32 @llvm.aarch64.fjcvtzs
SjoerdMeijer added inline comments.Jul 10 2019, 7:49 AM
clang/lib/Basic/Targets/AArch64.cpp
237 ↗(On Diff #208951)

Ah, sorry: "-march=armv8.4-a also enables this"
probably good to add some tests for v8.4 and v8.5 too then.

SjoerdMeijer added inline comments.Jul 10 2019, 8:03 AM
llvm/lib/Target/AArch64/AArch64InstrInfo.td
720 ↗(On Diff #208951)

and a last nit: this needs some reformatting (exceeding the max column width)

ktkachov updated this revision to Diff 208980.Jul 10 2019, 9:11 AM

Add more CHECK-LABEL tests, test v8.4a and v8.5a features. Fix formatting in pattern.

SjoerdMeijer accepted this revision.Jul 10 2019, 9:28 AM

Looks like a good change to me, some nits inlined.

It shouldn't be difficult to request an account and commit it yourself, which might be useful if you maybe intend to submit more patches.
But I can of course easily commit this on your behalf, just let me know. If you want me to commit this, it is easiest if you do upload a new diff with the nits fixed.

clang/test/CodeGen/arm_acle.c
5 ↗(On Diff #208980)

Some nits that you can fix before committing; no need for another review I think.

You can remove:

-check-prefix=CHECK-LABEL

in all these 3 lines below.

830 ↗(On Diff #208980)

and change

// CHECK-LABEL: @test_jcvt(

into

// AArch64-v8_3-LABEL: @test_jcvt(
This revision is now accepted and ready to land.Jul 10 2019, 9:28 AM
ktkachov updated this revision to Diff 209149.Jul 11 2019, 2:46 AM

Fix comments plus an offline comment I had (copy-pasto in an assert message)

This revision was automatically updated to reflect the committed changes.

FYI, this change broke git-llvm for everyone with a different username :-)
Fixed in r366198

FYI, this change broke git-llvm for everyone with a different username :-)
Fixed in r366198

Ah sorry, I accidentally included it in the commit!