Skip to content

[Clang][SME2] Add single and multi min and max builtins #71688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions clang/include/clang/Basic/arm_sve.td
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,26 @@ defm SVREVD : SInstZPZ<"svrevd", "csilUcUsUiUl", "aarch64_sve_revd">;
// SME intrinsics which operate only on vectors and do not require ZA should be added here,
// as they could possibly become SVE instructions in the future.

multiclass MinMaxIntr<string i, string zm, string mul, string t> {
def SVS # NAME : SInst<"sv" # i # "[" # zm # "_{d}_" # mul # "]", t, "csil", MergeNone, "aarch64_sve_s" # i # zm # "_" # mul, [IsStreaming], []>;
def SVU # NAME : SInst<"sv" # i # "[" # zm # "_{d}_" # mul # "]", t, "UcUsUiUl", MergeNone, "aarch64_sve_u" # i # zm # "_" # mul, [IsStreaming], []>;
def SVF # NAME : SInst<"sv" # i # "[" # zm # "_{d}_" # mul # "]", t, "hfd", MergeNone, "aarch64_sve_f" # i # zm # "_" # mul, [IsStreaming], []>;
}

let TargetGuard = "sme2" in {
// == SMAX / UMAX / FMAX ==
defm MAX_SINGLE_X2 : MinMaxIntr<"max", "_single", "x2", "22d">;
defm MAX_MULTI_X2 : MinMaxIntr<"max", "", "x2", "222">;
defm MAX_SINGLE_X4 : MinMaxIntr<"max", "_single", "x4", "44d">;
defm MAX_MULTI_X4 : MinMaxIntr<"max", "", "x4", "444">;

// == SMIN / UMIN / FMIN ==
defm MIN_SINGLE_X2 : MinMaxIntr<"min", "_single", "x2", "22d">;
defm MIN_MULTI_X2 : MinMaxIntr<"min", "", "x2", "222">;
defm MIN_SINGLE_X4 : MinMaxIntr<"min", "_single", "x4", "44d">;
defm MIN_MULTI_X4 : MinMaxIntr<"min", "", "x4", "444">;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a suggestion, but I think it could be worth adding the definitions that use a multiclass separately from this let TargetGuard = "sme2" block. I find it quite useful to have the multiclasses close to the definitions that use them when reading how the builtins are defined, and when more are added here this could become harder to follow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I agree. I've done that now and will go ahead and merge.

}

let TargetGuard = "sme2" in {
// == ADD (vectors) ==
def SVADD_SINGLE_X2 : SInst<"svadd[_single_{d}_x2]", "22d", "cUcsUsiUilUl", MergeNone, "aarch64_sve_add_single_x2", [IsStreaming], []>;
Expand Down
Loading