-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
use a builtin enum for calling conventions instead of keywords #661
Copy link
Copy link
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.
Milestone
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.
Type
Fields
Give feedbackNo fields configured for issues without a type.
right now we have these keywords for function calling conventions:
extern- must have C ABI. Also used to indicate C ABI on structs, enums, and unions.stdcallcccoldcc- cold calling convention is a thing, but this might be better off as an optimizer hint that the function is cold rather than specifying a calling convention. Currently the line is blurred.nakedcc- used for entry points like_startand when inline assembly defines the whole function.If no calling convention is specified, then the calling convention is selected automatically (and currently defaults to the "fast calling convention" that LLVM has available.) Related issue: #105 when mixing automatic calling convention with specified calling conventions.
Any function can be
exported, and if the calling convention of an exported function is not specified, thenexternis chosen.This proposal is to make a builtin enum:
And instead of keywords, the
fnkeyword has optional calling convention specifier that matchesalign, like this:If a calling convention is not specified,
builtin.CC.Autois the default. This is similar to the endianness in pointers proposal (see #649). When displaying a fn type, the calling convention only has to be specified if it is notbuiltin.CC.Auto.Then it becomes easier to add reflection with
@typeInfo(@typeOf(_start)).builtin.TypeInfo.CallingConventionshould be pulled out intobuiltin.CallingConventionNow that enum literals have arrived, this proposal is nicer: