This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/14] [x86_64] Vector math functions (vector cos)


On Fri, 15 May 2015, Andrew Senkevich wrote:

> diff --git a/include/libc-symbols.h b/include/libc-symbols.h
> index ca3fe00..8992e9e 100644
> --- a/include/libc-symbols.h
> +++ b/include/libc-symbols.h
> @@ -526,7 +526,7 @@ for linking")
>  # define rtld_hidden_data_ver(local, name)
>  #endif
>  
> -#if IS_IN (libm)
> +#if IS_IN (libm) || IS_IN(libmvec)
>  # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
>  # define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
>  # define libm_hidden_def(name) hidden_def (name)

I think it would be better to have a completely separate set of 
libmvec_hidden_* definitions (sorry for misleading you in my previous 
comments by referring to libm_hidden_*).  Also remember the space before 
'(' in the IS_IN call, and in other macro calls such as ENTRY, END and 
libmvec_hidden_def.

> +        jne       .LBL_1_3
> +
> +.LBL_1_2:
> +        movq      %rbp, %rsp
> +        cfi_def_cfa_register (%rsp)
> +        popq      %rbp
> +        cfi_adjust_cfa_offset (-8)
> +        cfi_restore (%rbp)
> +        ret
> +
> +.LBL_1_3:
> +        movups    %xmm3, 192(%rsp)

This won't yield correct CFI at .LBL_1_3 and afterwards.  At .LBL_1_3, the 
correct CFI is the same as that at .LBL_1_2 - *not* the same as that at 
the ret instruction.  So you should do cfi_remember_state before the CFI 
changes here, and cfi_restore_state after ret, for the CFI to be correct 
for the rest of the function.

> +        movups    %xmm0, 256(%rsp)
> +        je        .LBL_1_2
> +
> +        xorb      %dl, %dl
> +        xorl      %eax, %eax
> +        movups    %xmm8, 112(%rsp)
> +        movups    %xmm9, 96(%rsp)
> +        movups    %xmm10, 80(%rsp)
> +        movups    %xmm11, 64(%rsp)
> +        movups    %xmm12, 48(%rsp)
> +        movups    %xmm13, 32(%rsp)
> +        movups    %xmm14, 16(%rsp)
> +        movups    %xmm15, (%rsp)
> +        movq      %rsi, 136(%rsp)
> +        movq      %rdi, 128(%rsp)
> +        movq      %r12, 168(%rsp)
> +        movb      %dl, %r12b
> +        movq      %r13, 160(%rsp)
> +        movl      %ecx, %r13d
> +        movq      %r14, 152(%rsp)
> +        movl      %eax, %r14d
> +        movq      %r15, 144(%rsp)

The ABI says that r12-r15 are callee-saved registers.  That means you need 
CFI describing when they are saved and restored (and again need 
cfi_remember_state and cfi_restore_state to deal with how some code that's 
physically after the restoration is logically before it, and so needs the 
CFI describing how those registers are saved on the stack).

Similar issues apply with the CFI in other function implementations here.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]