[PATCH] D27050: [X86] Add explicit regparm flag for X86-32 calling convention.

Nirav Davé via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 06:24:44 PST 2016


I agree that we by the end of this we should be able to remove inreg (at
least from integer parameters). My hesistation is that it's not just the C
convention that we need to list, it's also stdcall, fastcall, vectorcall,
(and potentially intel_ocl_bi though I think not). If we need to do the
same for  "-msseregparm" this would be the majority of llvm calling
conventions. Function attributes would keep the number smaller, but perhaps
this isn't such a big deal if these are the only variants.

-Nirav






On Mon, Nov 28, 2016 at 3:33 PM, James Y Knight via Phabricator <
reviews at reviews.llvm.org> wrote:

> jyknight added a comment.
>
> There's two cases:
>
> 1. The calling convention for functions named in the IR. This can be set
> separately for each function by the frontend. Today, it's done by putting
> "inreg" attributes on appropriate parameters.
> 2. The calling convention used for library calls generated by LLVM. Today,
> this is not handled.
>
> The former can be specified by __attribute__((regparm(N))), and the
> -mregparm command-line flag specifies both 2, and the default for 1.
>
> This patch adds support for 2, without changing the way 1 works. But,
> ISTM, both of these should be really handled similarly -- I don't much like
> that this patch is adding new calling convention code for 2, but leaving
> the handling for 1 in clang's decision about whether to use "inreg".
>
> I think, instead, that 3 new calling conventions, "x86_regparm_{1,2,3}"
> should be defined -- variants of the C calling convention, with a different
> number of args passed in registers.
>
> Then --
>
> 1. Clang can emit the right cc for functions it defines/declares, rather
> than choosing where to place inreg.
> 2. Which one of the calling convention to use for libcalls can be set by a
> subtarget feature (selected by clang based on -mregparm=N command-line
> option, examined by X86TargetLowering to determine what to pass to
> setLibcallCallingConv).
>
>
> https://reviews.llvm.org/D27050
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/f992e035/attachment.html>


More information about the llvm-commits mailing list