This is an archive of the discontinued LLVM Phabricator instance.

[ARM,MVE] Add intrinsics for 'administrative' vector operations.
ClosedPublic

Authored by simon_tatham on Nov 12 2019, 9:56 AM.

Details

Summary

This batch of intrinsics includes lots of things that move vector data
around or change its type without really affecting its value very
much. It includes the vreinterpretq family (cast one vector type to
another); vuninitializedq (create a vector of a given type with
don't-care contents); and vcreateq (make a 128-bit vector out of two
uint64_t halves).

These are all implemented using completely standard IR that's already
tested in existing LLVM unit tests, so I've just written a clang test
to check the IR is correct, and left it at that.

I've also added some richer infrastructure to the MveEmitter Tablegen
backend, to make it specify the exact integer type of integer
arguments passed to IR construction functions, and wrap those
arguments in a static_cast in the autogenerated C++. That was
necessary to prevent an overloading ambiguity when passing the integer
literal 0 to IRBuilder::CreateInsertElement, because otherwise, it
could mean either a null pointer llvm::Value * or a zero uint64_t.

Event Timeline

simon_tatham created this revision.Nov 12 2019, 9:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2019, 9:56 AM

Smaller patches are easier to review, if for example this could have the vgetq_lane/vsetq_lane split out.

clang/include/clang/Basic/arm_mve.td
384

Indent this line by an extra 4 spaces.

I'm going to have to trust you that it's doing the right thing. The !eq has to be on two strings?

clang/test/CodeGen/arm-mve-intrinsics/admin.c
1568

What's this zext about? Is it just left over from code that was removed?

1671

I see. This is the "non-evaluating" part. It looks odd from a C perspective.

simon_tatham marked 3 inline comments as done.Nov 13 2019, 4:15 AM
simon_tatham added inline comments.
clang/include/clang/Basic/arm_mve.td
384

Yes, unfortunately – it would be nice to be able to !eq two defs, but it only accepts strings.

clang/test/CodeGen/arm-mve-intrinsics/admin.c
1568

MveEmitter automatically promotes smaller integer types to i32, on the assumption that you were probably going to pass them to IR intrinsics which will instruction-select into things taking a GPR as input.

For my next batch of intrinsics I'm working on a system for suppressing that promotion in cases where it isn't what you wanted after all. Now you mention it, that might be a thing to pull out and apply here as well.

1671

Slightly, although it's no more odd than sizeof or __typeof for only using the type of its argument and not actually evaluating it. But it's what ACLE specifies!

(I think, rather like I just mentioned in D70088, that the use case is for polymorphism within something like a C++ template – if you have the vector type as a template parameter, this allows you to generate an uninit value of the same vector type reasonably easily, without having to write your own system of C++ template specializations that select the right explicitly suffixed intrinsic.)

Moved the get/set lane functions out into a separate patch.

dmgreen accepted this revision.Nov 14 2019, 2:33 PM

Thanks. That, er, makes it slightly simpler to review.

LGTM

clang/test/CodeGen/arm-mve-intrinsics/admin.c
1671

It's more like a macro than a function call. Makes sense.

This revision is now accepted and ready to land.Nov 14 2019, 2:33 PM
This revision was automatically updated to reflect the committed changes.