Skip to content

Conversation

konstantinschwarz
Copy link
Collaborator

In AIEs default calling convention, all vector registers are caller saved. However, most compiler-rt builtin library functions do not use vector registers. To avoid having to spill vectors to memory in the caller function, we can attach a different calling convention to these library functions.

I manually inspected each library function where we apply the alternative calling convention to make sure none of them actually use vector registers. To make this actually save and robust, we should also add a custom calling convention attribute to the frontend that ensures vector registers are actually saved by the callee.

In AIEs default calling convention, all vector registers are caller saved.
However, most compiler-rt builtin library functions do not use vector registers.
To avoid having to spill vectors to memory in the caller function,
we can attach a different calling convention to these library functions.
@konstantinschwarz
Copy link
Collaborator Author

This saves up to 512 bytes of stack (ArgMin/ArgMax), and some very minor code size savings.

Core_PMSize_absolute Core_StackSize_absolute

setLibcallCallingConv(RTLIB::SREM_I32, CallingConv::AIE_PreserveAll_Vec);
setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::AIE_PreserveAll_Vec);
setLibcallCallingConv(RTLIB::UREM_I32, CallingConv::AIE_PreserveAll_Vec);
setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::AIE_PreserveAll_Vec);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see some other libcalls in the LegalizerHelper. Are these only the verified ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, these are only the ones I verified. Others could likely be included as well, but I wanted to keep this limited for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants