Skip to content

Conversation

@D0ntPanic
Copy link
Member

Several modern languages, like Rust and Swift, have custom calling conventions that input or output in registers that are normally reserved as callee saved registers. To account for this, we need to add calling conventions that define these additional register uses.

Unfortunately, adding these calling conventions will cause the heuristic calling convention detection to run into a lot of cases where there are multiple apparently equivalent solutions to the optimal calling convention. Most of the time we want the base calling convention that doesn't include the non-standard register usage.

To allow for this, this commit adds two new APIs. One provides the set of arguments that must be present, and the other provides the set of registers that must be clobbered.

For non-standard inputs, the calling convention should supply the register as an argument register, and also supply it as a required argument register. This will cause the calling convention detection code to avoid the calling convention unless usage of the non-standard input register is actually found. It will also allow the calling convention code to avoid it even if there are no arguments to the function (in this case, just adding the register as a normal argument register will cause a conflict and may not choose the desired base convention).

For non-standard outputs, supply the register as a required clobbered register. This will avoid detecting the convention when the non-standard output is not written.

…ng considered during heuristic calling convention detection
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