Skip to content

[AArch64][SME] Rewrite __arm_get_current_vg to preserve required registers #100143

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 3 commits into from
Jul 24, 2024

Conversation

kmclaughlin-arm
Copy link
Contributor

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:

  • X1-X15, X19-X29 and SP
  • Z0-Z31
  • P0-P15

This patch rewrites the implementation of this routine in compiler-rt, as
the current version does not guarantee that these registers will be preserved.

…sters

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt, as
the current version does not guarantee that these registers will be preserved.

See https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#arm-get-current-vg
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_get_current_vg)
.variant_pcs __arm_get_current_vg
BTI_C
mov x0, xzr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary? I'd expect it to be overwritten by the call to __arm_sme_state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does get overwritten, I've removed this


__attribute__((target("sve"))) long
__arm_get_current_vg(void) __arm_streaming_compatible {
struct SME_STATE State = __arm_sme_state();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the definition of this struct and the prototype of __arm_sme_state be removed as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They can indeed :)

.cfi_offset w30, -8
.cfi_offset w29, -16
mov x17, x1
bl __arm_sme_state
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this call be moved into the 0: branch?

  __arm_sme_state call to the '0' branch.
- Removed SME_STATE struct from sme-abi-vg.c
@kmclaughlin-arm kmclaughlin-arm merged commit 6da6772 into llvm:main Jul 24, 2024
6 checks passed
@AZero13
Copy link
Contributor

AZero13 commented Jul 24, 2024

Should this be backported to 19.x

@kmclaughlin-arm
Copy link
Contributor Author

Should this be backported to 19.x

Hi @AtariDreams, yes it should be. I will create an issue to backport it.

@kmclaughlin-arm kmclaughlin-arm added this to the LLVM 19.X Release milestone Jul 25, 2024
@kmclaughlin-arm
Copy link
Contributor Author

/cherry-pick 6da6772

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 25, 2024
…sters (llvm#100143)

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.

(cherry picked from commit 6da6772)
@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2024

/pull-request #100546

yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
…sters (#100143)

Summary:
The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250669
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 26, 2024
…sters (llvm#100143)

The documentation for the __arm_get_current_vg support routine specifies
that the following registers are call-preserved:
 - X1-X15, X19-X29 and SP
 - Z0-Z31
 - P0-P15

This patch rewrites the implementation of this routine in compiler-rt,
as the current version does not guarantee that these registers will be
preserved.

(cherry picked from commit 6da6772)
@kmclaughlin-arm kmclaughlin-arm deleted the x1_current_vg branch August 19, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants