Vector registers assumed to be caller or callee-saved?

Stefan Schulze Frielinghaus ml at
Sun Jun 30 18:36:42 UTC 2019

But this only includes the NCG. What about the LLVM backend? For LLVM I
only found in compiler/llvmGen/LlvmCodeGen/CodeGen.hs function
definition getTrashRegs which makes use of function callerSaves which is
defined in includes/CodeGen.Platform.hs:

callerSaves :: GlobalReg -> Bool
#if defined(CALLER_SAVES_Base)
callerSaves BaseReg           = True
callerSaves _                 = False

There only for general-purpose and floating-point registers function
callerSaves may be defined to True. Thus, for XMMi, YMMi, and ZMMi
arguments the function evaluates to False.

Do I miss something for the LLVM backend? Maybe we just need to extend
the definition of callerSaves in order to respect vector registers, too?


On Sun, Jun 30, 2019 at 07:16:15PM +0200, Andreas Klebinger wrote:
> What you want is not the macro but this function:
> whose results depend on the System ABI.
> Cheers,
> Andreas
> > Hi all,
> >
> > I'm wondering what GHC assumes about vector registers XMMi, YMMi, and ZMMi used
> > by the STG machine: are those assumed to be caller or callee-saved? Only for
> > the x86-64 architecture there exist macro definitions like CALLER_SAVES_XMM1 in
> > includes/stg/MachRegs.h.  However, I cannot find any other place where those
> > macros are used.  AFAIK most C ABIs assume that vector registers are call
> > clobbered. Is this also the case for GHC?
> >
> > Many thanks in advance,
> > Stefan
> >

More information about the ghc-devs mailing list