Add APIs to allow calling conventions to provide requirements for being considered during heuristic calling convention detection #7861
+250
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.