[m68k] Add uClinux-specific code generation options

Richard Henderson rth@redhat.com
Wed Sep 3 23:31:00 GMT 2003


On Wed, Sep 03, 2003 at 11:41:07PM +0200, Bernardo Innocenti wrote:
> +#define LEA(sym,reg)	movel	a5@(_current_shared_library_a5_offset_), 

I assume _current_shared_library_a5_offset_ is some sort of magic
assembler/linker symbol?  

You might also consider using gas macros instead of cpp macros.
I find them more readable, since you don't have to use parenthesis.

> %{!mc68000:%{!m68000:%{!m68302:%{!m68010:%{!mc68020:%{!m68020:%{!m68030:%{!m68040:%{!m68020-40:%{!m68020-60:%{!m68060:%{!mcpu32: %{!m68332:%{!m5200:%{!m5206e:%{!m528x:%{!m5307:%{!m5407:%(cpp_cpu_default)}}}}}}}}}}}}}}}}}} \
> +%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} 

Please convert all of this to use, as needed,

  TARGET_CPU_CPP_BUILTINS
  TARGET_OS_CPP_BUILTINS
  TARGET_OBJFMT_CPP_BUILTINS

And please do that first.

> +  /* Library identification */
> +  if (m68k_library_id_string)
> +    {
> +      if (! TARGET_ID_SHARED_LIBRARY)
> +	error ("-mshared-library-id= specified without -mid-shared-library");
> +      m68k_library_id = atoi (m68k_library_id_string);
> +      if (m68k_library_id < 0 || m68k_library_id > MAX_LIBRARY_ID)
> +	error ("-mshared-library-id=%d is not between 0 and %d",
> +	       m68k_library_id, MAX_LIBRARY_ID);
> +    }
> +  else
> +    m68k_library_id = -1;
[...]
> +	  if (m68k_library_id > 0)
> +	    {
> +	      asm_fprintf (stream, "\tmovel %s@(%d), %s\n",
> +			   reg_names[PIC_OFFSET_TABLE_REGNUM],
> +			   m68k_library_id * -4 - 4,
> +			   reg_names[PIC_OFFSET_TABLE_REGNUM]);
> +	    }
> +	  else
> +	    {
> +	      asm_fprintf (stream, "\tmovel 
> %s@(_current_shared_library_a5_offset_), %s\n",
> +			   reg_names[PIC_OFFSET_TABLE_REGNUM],
> +			   reg_names[PIC_OFFSET_TABLE_REGNUM]);
> +	    }

Consider doing

	if (m68k_library_id_string)
	  {
	    // stuff, computing a new m68k_library_id_string with
	    // the proper decimal offset.
	  }
	else
	  m68k_library_id_string = "_current_shared_library_a5_offset_";

	asm_fprintf (stream, "\tmovel %s@(%s), %s\n",
		     reg_names[PIC_OFFSET_TABLE_REGNUM],
		     m68k_library_id_string,
		     reg_names[PIC_OFFSET_TABLE_REGNUM]);

> -  if (! TARGET_68020 && flag_pic == 2)
> +  if (!TARGET_68020 && !TARGET_COLDFIRE && (flag_pic == 2))
>     error("-fPIC is not currently supported on the 68000 or 68010\n");

Update the message if you're going to do that.

> -  if (flag_pic && current_function_uses_pic_offset_table)
> +  if (! TARGET_SEP_DATA && flag_pic &&
> +		  (current_function_uses_pic_offset_table ||
> +		   ( ! current_function_is_leaf && 

Formatting.

> +    { "hwdiv", MASK_CF_HWDIV,					\
> +      N_("Use hardware divisor") },					\
> +    { "no-hwdiv", -MASK_CF_HWDIV,					\
> +      N_("Don't use hardware divisor") },				\
> +    { "mac", 0,							\
> +      N_("Use hardware Multiply-accumulate unit") },			\
> +    { "no-mac", 0,							\
> +      N_("Don't use hardware Multiply-accumulate unit") },		\

>From some other patch, I assume.

> +/* The maximum alignment which the object file format can support. */
> +#undef MAX_OFILE_ALIGNMENT
> +#define MAX_OFILE_ALIGNMENT 128

Why is this in m68k.h?

> +      /* We output a bsr instruction if we've using -fpic or we're 
> building for
> +       * a target that supports long branches.  If we're building -fPIC on 
> the
> +       * 68000. 68010 or coldfire we're generate one of two sequences
> +       * a shorter one that uses a GOT entry or a longer one that doesn't.
> +       * We'll use the -Os commandline flag to decide which to generate.
> +       * Both sequences take the same time to execute on the coldfire.
> +       */
> +      if (TARGET_SEP_DATA || TARGET_ID_SHARED_LIBRARY)
> +        return \"move.l %0@GOT(%%a5), %%a1\\n\\tjsr (%%a1)\";
> +      else if (TARGET_PCREL)
> +	return \"bsr.l %o0\";
> +      else if (flag_pic == 1 || TARGET_68020)
> #ifdef HPUX_ASM
> -      return \"bsr.l %0\";
> +        return \"bsr.l %0\";
> #else
> #ifdef USE_GAS
> -      return \"bsr.l %0@PLTPC\";
> +        return \"bsr %0@PLTPC\";
> #else
> -      return \"bsr %0@PLTPC\";
> -#endif
> -#endif
> -#else
> -#ifdef USE_GAS
> -      return \"bsr.l %0\";
> -#else
> -      /* The ',a1' is a dummy argument telling the Sun assembler we want 
> PIC,
> -	 GAS just plain ignores it.  FIXME: not anymore, gas doesn't!  */
> -      return \"jbsr %0,a1\";
> +        return \"bsr.l %0@PLTPC\";
> #endif

It'd be really nice if you moved this out of line to m68k.c,
so that we didn't have multiple copies of it.


r~



More information about the Gcc-patches mailing list