[2/5] gas: Add md_generic_table_relax_frag

Message ID 20191112161905.10048-3-hjl.tools@gmail.com
State Superseded
Headers show
Series
  • i386: Optimize for Jump Conditional Code Erratum
Related show

Commit Message

H.J. Lu Nov. 12, 2019, 4:19 p.m.
Add md_generic_table_relax_frag for TC_GENERIC_RELAX_TABLE targets so
that a backend can extend relax_frag beyond TC_GENERIC_RELAX_TABLE.

	* write.c (relax_segment): Call md_generic_table_relax_frag
	instead of relax_frag if defined.
---
 gas/write.c | 5 +++++
 1 file changed, 5 insertions(+)

-- 
2.21.0

Comments

Jan Beulich Nov. 12, 2019, 4:55 p.m. | #1
On 12.11.2019 17:19,  H.J. Lu  wrote:
> --- a/gas/write.c

> +++ b/gas/write.c

> @@ -3030,7 +3030,12 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)

>  #ifdef TC_GENERIC_RELAX_TABLE

>  		/* The default way to relax a frag is to look through

>  		   TC_GENERIC_RELAX_TABLE.  */

> +#ifdef md_generic_table_relax_frag

> +		growth = md_generic_table_relax_frag (segment, fragP,

> +						      stretch);

> +#else

>  		growth = relax_frag (segment, fragP, stretch);

> +#endif /* md_generic_table_relax_frag */

>  #endif /* TC_GENERIC_RELAX_TABLE  */

>  #endif

>  		break;


Wouldn't

#ifndef md_generic_table_relax_frag
#define md_generic_table_relax_frag relax_frag
#endif

higher up in the file result in somewhat better readable code
above?

Jan
H.J. Lu Nov. 12, 2019, 8:13 p.m. | #2
On Tue, Nov 12, 2019 at 8:55 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> On 12.11.2019 17:19,  H.J. Lu  wrote:

> > --- a/gas/write.c

> > +++ b/gas/write.c

> > @@ -3030,7 +3030,12 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)

> >  #ifdef TC_GENERIC_RELAX_TABLE

> >               /* The default way to relax a frag is to look through

> >                  TC_GENERIC_RELAX_TABLE.  */

> > +#ifdef md_generic_table_relax_frag

> > +             growth = md_generic_table_relax_frag (segment, fragP,

> > +                                                   stretch);

> > +#else

> >               growth = relax_frag (segment, fragP, stretch);

> > +#endif /* md_generic_table_relax_frag */

> >  #endif /* TC_GENERIC_RELAX_TABLE  */

> >  #endif

> >               break;

>

> Wouldn't

>

> #ifndef md_generic_table_relax_frag

> #define md_generic_table_relax_frag relax_frag

> #endif

>

> higher up in the file result in somewhat better readable code

> above?

>


Will do.

Thanks.

-- 
H.J.
Michael Matz Nov. 13, 2019, 11:58 a.m. | #3
Hi,

On Tue, 12 Nov 2019, H.J. Lu wrote:

> Add md_generic_table_relax_frag for TC_GENERIC_RELAX_TABLE targets so


This needs documentation in internals.texi as well.


Ciao,
Michael.

> that a backend can extend relax_frag beyond TC_GENERIC_RELAX_TABLE.

> 

> 	* write.c (relax_segment): Call md_generic_table_relax_frag

> 	instead of relax_frag if defined.

> ---

>  gas/write.c | 5 +++++

>  1 file changed, 5 insertions(+)

> 

> diff --git a/gas/write.c b/gas/write.c

> index 8f7786eb36..35b86ba976 100644

> --- a/gas/write.c

> +++ b/gas/write.c

> @@ -3030,7 +3030,12 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)

>  #ifdef TC_GENERIC_RELAX_TABLE

>  		/* The default way to relax a frag is to look through

>  		   TC_GENERIC_RELAX_TABLE.  */

> +#ifdef md_generic_table_relax_frag

> +		growth = md_generic_table_relax_frag (segment, fragP,

> +						      stretch);

> +#else

>  		growth = relax_frag (segment, fragP, stretch);

> +#endif /* md_generic_table_relax_frag */

>  #endif /* TC_GENERIC_RELAX_TABLE  */

>  #endif

>  		break;

>

Patch

diff --git a/gas/write.c b/gas/write.c
index 8f7786eb36..35b86ba976 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -3030,7 +3030,12 @@  relax_segment (struct frag *segment_frag_root, segT segment, int pass)
 #ifdef TC_GENERIC_RELAX_TABLE
 		/* The default way to relax a frag is to look through
 		   TC_GENERIC_RELAX_TABLE.  */
+#ifdef md_generic_table_relax_frag
+		growth = md_generic_table_relax_frag (segment, fragP,
+						      stretch);
+#else
 		growth = relax_frag (segment, fragP, stretch);
+#endif /* md_generic_table_relax_frag */
 #endif /* TC_GENERIC_RELAX_TABLE  */
 #endif
 		break;