-
Notifications
You must be signed in to change notification settings - Fork 30
[AIE2P] Add alternative calling convention for library calls #664
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
base: aie-public
Are you sure you want to change the base?
Conversation
| 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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.
9660c19 to
cebc746
Compare
| : CalleeSavedRegs<(add lr, r8, r9, r10, r11, r12, r13, r14, r15, p6, p7)>; | ||
|
|
||
| def CSR_AIE2P_Vec | ||
| : CalleeSavedRegs<(add lr, r8, r9, r10, r11, r12, r13, r14, r15, p6, p7, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we write this as an extension to CSR_AIE2P?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. factoring using a named common set?
| : AIEBaseTargetLowering(TM, STI) { | ||
|
|
||
| if (VecCCLibcalls) { | ||
| setLibcallCallingConv(RTLIB::SINTTOFP_I32_F32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: perhaps make a data-driven routine running on an array of function ids?


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.