PING: PATCH [4/n] X32: Use ptr_mode for vtable adjustment

H.J. Lu hjl.tools@gmail.com
Wed Jul 13 14:52:00 GMT 2011


Hi Richard, Uros,

Is this patch OK?

Thanks.

H.J.
---
On Sun, Jul 10, 2011 at 6:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Jul 9, 2011 at 3:58 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sat, Jul 9, 2011 at 3:43 PM, Richard Henderson <rth@redhat.com> wrote:
>>> On 07/09/2011 02:36 PM, H.J. Lu wrote:
>>>>
>>>> Hi,
>>>>
>>>> Thunk is in ptr_mode, not Pmode.  OK for trunk?
>>>>
>>>> Thanks.
>>>>
>>>> H.J.
>>>> ---
>>>> 2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>
>>>>
>>>>       * config/i386/i386.c (x86_output_mi_thunk): Use ptr_mode instead
>>>>       of Pmode for vtable adjustment.
>>>>
>>> Not ok.  This is incoherent in its treatment of Pmode vs ptr_mode.
>>> You're creating an addition
>>>
>>>        (plus:P (reg:ptr tmp) (reg:P tmp2))
>>
>> It is because thunk is stored in ptr_mode, not Pmode.
>>
>>>
>>> I have a queued patch that replaces all of this with rtl.  I will
>>> post it later today.
>>>
>>
>> I will update it for x32 after your change is checked in.
>>
>
> I am testing this updated patch.  OK for trunk if it works?
>
> Thanks.
>
>
> --
> H.J.
> ---
> 2011-07-10  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * config/i386/i386.c (x86_output_mi_thunk): Support ptr_mode
>        != Pmode.
>
>        * config/i386/i386.md (*addsi_1_zext): Renamed to ...
>        (addsi_1_zext): This.
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index a46101b..d6744be 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -29346,7 +29673,7 @@ x86_output_mi_thunk (FILE *file,
>   /* Adjust the this parameter by a value stored in the vtable.  */
>   if (vcall_offset)
>     {
> -      rtx vcall_addr, vcall_mem;
> +      rtx vcall_addr, vcall_mem, this_mem;
>       unsigned int tmp_regno;
>
>       if (TARGET_64BIT)
> @@ -29361,7 +29688,10 @@ x86_output_mi_thunk (FILE *file,
>        }
>       tmp = gen_rtx_REG (Pmode, tmp_regno);
>
> -      emit_move_insn (tmp, gen_rtx_MEM (ptr_mode, this_reg));
> +      this_mem = gen_rtx_MEM (ptr_mode, this_reg);
> +      if (Pmode == DImode && ptr_mode == SImode)
> +       this_mem = gen_rtx_ZERO_EXTEND (DImode, this_mem);
> +      emit_move_insn (tmp, this_mem);
>
>       /* Adjust the this parameter.  */
>       vcall_addr = plus_constant (tmp, vcall_offset);
> @@ -29373,8 +29703,13 @@ x86_output_mi_thunk (FILE *file,
>          vcall_addr = gen_rtx_PLUS (Pmode, tmp, tmp2);
>        }
>
> -      vcall_mem = gen_rtx_MEM (Pmode, vcall_addr);
> -      emit_insn (ix86_gen_add3 (this_reg, this_reg, vcall_mem));
> +      vcall_mem = gen_rtx_MEM (ptr_mode, vcall_addr);
> +      if (Pmode == DImode && ptr_mode == SImode)
> +       emit_insn (gen_addsi_1_zext (this_reg,
> +                                    gen_rtx_REG (SImode, REGNO (this_reg)),
> +                                    vcall_mem));
> +      else
> +       emit_insn (ix86_gen_add3 (this_reg, this_reg, vcall_mem));
>     }
>
>   /* If necessary, drop THIS back to its stack slot.  */
> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> index a52941b..3136fd0 100644
> --- a/gcc/config/i386/i386.md
> +++ b/gcc/config/i386/i386.md
> @@ -5508,11 +5574,11 @@
>  ;; operands so proper swapping will be done in reload.  This allow
>  ;; patterns constructed from addsi_1 to match.
>
> -(define_insn "*addsi_1_zext"
> +(define_insn "addsi_1_zext"
>   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
>        (zero_extend:DI
>          (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r,r")
>                   (match_operand:SI 2 "general_operand" "g,0,li"))))
>    (clobber (reg:CC FLAGS_REG))]
>   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
>  {
>



More information about the Gcc-patches mailing list