Patchwork [RFA/ARM,01/02] : Thumb2 epilogue in RTL

login
register
mail settings
Submitter Ramana Radhakrishnan
Date Nov. 18, 2011, 11:11 p.m.
Message ID <CACUk7=XBPH_xd2tF2JaLxQ2_ZJmw+UcfU2kd06kUMXdV7QwaJQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/126503/
State New
Headers show

Comments

Ramana Radhakrishnan - Nov. 18, 2011, 11:11 p.m.
On 10 November 2011 18:07, Sameera Deshpande <sameera.deshpande@arm.com> wrote:
> Please find attached the reworked patch.

OK but for a very small bit .

I'll note that we need to add support for the iwMMXt registers but the
attached patch (untested) should be what is needed to support the
iwMMxt registers and this should be something that should be
incorporated into your ARM RTL epilogues patch as well. My
understanding is that this is all you should need to do as there is a
wldrd as a part of *iwmmx*_movdi instruction and therefore this should
just work in this form.

Xinyu can you help in testing this patch once this is applied along
with your other patches to turn on Thumb2 for iwmmxt ?

cheers
Ramana
Xinyu Qi - Nov. 22, 2011, 1:55 a.m.
At 2011-11-19 07:11:17,"Ramana Radhakrishnan" <ramana.radhakrishnan@linaro.org> wrote:
> On 10 November 2011 18:07, Sameera Deshpande
> <sameera.deshpande@arm.com> wrote:
> > Please find attached the reworked patch.
> 
> OK but for a very small bit .
> 
> I'll note that we need to add support for the iwMMXt registers but the
> attached patch (untested) should be what is needed to support the iwMMxt
> registers and this should be something that should be incorporated into your
> ARM RTL epilogues patch as well. My understanding is that this is all you
> should need to do as there is a wldrd as a part of *iwmmx*_movdi instruction
> and therefore this should just work in this form.
> 
> Xinyu can you help in testing this patch once this is applied along with your
> other patches to turn on Thumb2 for iwmmxt ?
> 
> cheers
> Ramana

Hi, Ramana,

Though I don't fully understand this patch, I think it is unnecessary to consider turn on Thumb2 for iwmmxt,
because there is no chip that supports WMMX instructions with thumb2 mode.

Thanks,
Xinyu
Sameera Deshpande - Nov. 22, 2011, 10:26 a.m.
On Tue, 2011-11-22 at 01:55 +0000, Xinyu Qi wrote:
> At 2011-11-19 07:11:17,"Ramana Radhakrishnan" <ramana.radhakrishnan@linaro.org> wrote:
> > On 10 November 2011 18:07, Sameera Deshpande
> > <sameera.deshpande@arm.com> wrote:
> > > Please find attached the reworked patch.
> > 
> > OK but for a very small bit .
> > 
> > I'll note that we need to add support for the iwMMXt registers but the
> > attached patch (untested) should be what is needed to support the iwMMxt
> > registers and this should be something that should be incorporated into your
> > ARM RTL epilogues patch as well. My understanding is that this is all you
> > should need to do as there is a wldrd as a part of *iwmmx*_movdi instruction
> > and therefore this should just work in this form.
> > 
> > Xinyu can you help in testing this patch once this is applied along with your
> > other patches to turn on Thumb2 for iwmmxt ?
> > 
> > cheers
> > Ramana
> 
> Hi, Ramana,
> 
> Though I don't fully understand this patch, I think it is unnecessary to consider turn on Thumb2 for iwmmxt,
> because there is no chip that supports WMMX instructions with thumb2 mode.
> 
> Thanks,
> Xinyu
> 

Ramana, in that case, should I add the change you suggested in ARM RTL
epilogue patch only?

--
Ramana Radhakrishnan - Nov. 22, 2011, 10:37 a.m.
>>
>> Though I don't fully understand this patch, I think it is unnecessary to consider turn on Thumb2 for iwmmxt,
>> because there is no chip that supports WMMX instructions with thumb2 mode.

Xinyu: I seem to have mis-remembered that one of your patches was
turning on Thumb2 for wMMX.

>
> Ramana, in that case, should I add the change you suggested in ARM RTL
> epilogue patch only?

The comment in Thumb2 epilogues should remain and yes - it should be
added to the ARM RTL epilogue patch only. I'm also ok with that being
in with a #if 0 around it but given it's in the epilogue whoever tries
turning on Thumb2 for iwMMX will surely notice that in the first
testrun :)

I'll try and find some time later today to apply both the patches and
see where I get to.

cheers
Ramana

>
> --
>
>
>
Xinyu Qi - Nov. 23, 2011, 1:40 a.m.
At 2011-11-22 18:37:16,"Ramana Radhakrishnan" <ramana.radhakrishnan@linaro.org> wrote: 
> >>
> >> Though I don't fully understand this patch, I think it is unnecessary to
> consider turn on Thumb2 for iwmmxt,
> >> because there is no chip that supports WMMX instructions with thumb2
> mode.
> 
> Xinyu: I seem to have mis-remembered that one of your patches was
> turning on Thumb2 for wMMX.

Hi Ramana,
I remember I just enable iwmmxt with vfp in the first part of my patch.

> 
> >
> > Ramana, in that case, should I add the change you suggested in ARM RTL
> > epilogue patch only?
> 
> The comment in Thumb2 epilogues should remain and yes - it should be
> added to the ARM RTL epilogue patch only. I'm also ok with that being
> in with a #if 0 around it but given it's in the epilogue whoever tries
> turning on Thumb2 for iwMMX will surely notice that in the first
> testrun :)
> 
> I'll try and find some time later today to apply both the patches and
> see where I get to.
> 
> cheers
> Ramana
> 
> >
> > --
> >
> >
> >

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 708142e..1fb86fd 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -264,7 +264,7 @@  static reg_class_t arm_preferred_rename_class (reg_class_t rclass);
 static unsigned int arm_autovectorize_vector_sizes (void);
 static int arm_default_branch_cost (bool, bool);
 static int arm_cortex_a5_branch_cost (bool, bool);
-
+static void arm_epilogue_restore_iwmmxt_regs (void);
 
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -22563,6 +22563,30 @@  thumb2_expand_return (void)
     }
 }
 
+static void
+arm_epilogue_restore_iwmmxt_regs (void)
+{
+									
+  int reg;
+  for (reg = FIRST_IWMMXT_REGNUM; reg <= LAST_IWMMXT_REGNUM; reg++)
+    if (df_regs_ever_live_p (reg) && !call_used_regs[reg])
+      {
+	rtx tmp = gen_rtx_SET (DImode,
+			       gen_rtx_REG (reg, DImode),
+			       gen_frame_mem (DImode, 
+					      gen_rtx_POST_INC 
+					      (DImode,
+					       stack_pointer_rtx)));
+	rtx dwarf = alloc_reg_note (REG_CFA_RESTORE,
+				    gen_rtx_REG (reg, DImode),
+				    NULL_RTX);
+	
+	RTX_FRAME_RELATED_P (tmp) = 1;
+	emit_insn (tmp);
+      }
+  
+}
+
 /* Generate RTL to represent a Thumb-2 epilogue.
 
    Note that this RTL does not include the
@@ -22652,6 +22676,10 @@  thumb2_expand_epilogue (void)
   /* iWMMXt is not supported when Thumb-2 in use.  If it were, we would
      want to be restoring the appropriate iWMMXt regs here, in a similar
      way to arm_output_epilogue.  */
+  if (TARGET_IWMMXT)
+    {
+      arm_epilogue_restore_iwmmxt_regs ();
+    }
 
   /* If there are registers to restore, make it happen.  */
   if (saved_regs_mask)