Page MenuHomePhabricator

[SVE][Inline-Asm] Add constraints for SVE predicate registers
Needs ReviewPublic

Authored by kmclaughlin on Wed, Aug 21, 4:12 AM.

Details

Summary

Adds the following inline asm constraints for SVE:

  • Upl: One of the low eight SVE predicate registers, P0 to P7 inclusive
  • Upa: SVE predicate register with full range, P0 to P15

Diff Detail

Event Timeline

kmclaughlin created this revision.Wed, Aug 21, 4:12 AM
Herald added a project: Restricted Project. · View Herald Transcript
sdesmalen added inline comments.Wed, Aug 21, 5:53 AM
lib/IR/InlineAsm.cpp
188

"Expected a digit" seems more appropriate, since this code is only testing a single character.

192

StringRef can be used here instead of std::string.

lib/Target/AArch64/AArch64ISelLowering.cpp
5819

This is missing a check that Constraint.size() == 3. Or perhaps it is even better to split this code out into a separate function, because this patch writes out the condition three times. Maybe something like PredicateConstraint isPredicateConstraint(StringRef S), where PredicateConstraint is an enum.

  • Added isPredicateConstraint function to AArch64ISelLowering.cpp, which returns Upl, Upa or Invalid. This is used to replace some repeated checks of the predicate type
  • Minor changes to InlineAsm.cpp
rovka added a comment.Mon, Sep 2, 2:24 AM

Just some drive-by suggestions :)

lib/Target/AArch64/AArch64ISelLowering.cpp
5747

Nit: I think get- or parsePredicateConstraint reads better, since this doesn't return a simple yes/no answer.

test/CodeGen/AArch64/aarch64-sve-asm.ll
54

Nit: I would be a bit pedantic here and also check that they are used for the inline asm.

greened added inline comments.Tue, Sep 3, 7:31 AM
docs/LangRef.rst
3818

What do these names mean? "<something> predicate lower|all?" I see they are the names used in gcc, so I guess it makes sense to use them here. Are these names used in the SVE architecture manual somewhere? I cannot find them.

lib/Target/AArch64/AArch64ISelLowering.cpp
5747

+1.

  • Renamed the isPredicateConstraint function to parsePredicateConstraint
  • Added more thorough checks to the tests in aarch64-sve-asm.ll
kmclaughlin marked 3 inline comments as done.Tue, Sep 10, 5:38 AM
kmclaughlin added inline comments.
docs/LangRef.rst
3818

The length of the constraint depends on the first letter, and for AArch64 'U' was chosen to indicate a 3-letter constraint. These are not in the SVE architecture manual as they are only for compatibility with GCC inline asm (see https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints)

lib/Target/AArch64/AArch64ISelLowering.cpp
5747

Thanks for the suggestion @rovka - I have changed this to parsePredicateConstraint