This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: Patch to gas/read.c to control implicit lcomm alignment


> Date: 10 Mar 2000 15:13:17 -0800
> From: Ian Lance Taylor <ian@zembu.com>

>    Date: Sat, 11 Mar 2000 00:10:18 +0100
>    From: Hans-Peter Nilsson <hans-peter.nilsson@axis.com>
> 	   * read.c (s_lcomm_internal): Wrap implicit alignment in #ifndef
> 	   NO_IMPLICIT_LCOMM_ALIGNMENT. 
> 
> Don't make macros negative.  That makes it harder to understand how to
> use them.  Make it IMPLICIT_LCOMM_ALIGNMENT, and give it a default of
> 1.

I was...ehrm... just testing the waters with a minimal patch. :-)

> However, in this case, I think a better fix would be a macro which
> takes the size and returns the alignment.  The current code could be
> the default implementation of that macro.
> 
> Document new macros in gas/doc/internals.texi.

Something like this?  I added a TC_ prefix that many of the
target-controlled macros seem to have.

gas/ChangeLog:
Sat Mar 11 00:01:39 2000  Hans-Peter Nilsson  <hp@axis.se>

	* read.c (TC_IMPLICIT_LCOMM_ALIGNMENT): New default-definition.
	(s_lcomm_internal): Use it.
	* doc/internals.texi (CPU backend): Document it.
	* config/obj-evax.h (TC_IMPLICIT_LCOMM_ALIGNMENT): Set to 2**3 bytes.

Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.16
diff -c -p -r1.16 read.c
*** read.c	2000/02/24 01:56:31	1.16
--- read.c	2000/03/11 00:50:04
*************** Software Foundation, 59 Temple Place - S
*** 53,58 ****
--- 53,73 ----
  #define TC_START_LABEL(x,y) (x==':')
  #endif
  
+ /* Set by the object-format or the target.  */
+ #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
+ #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR)        \
+  do {                                                   \
+   if ((SIZE) >= 8)                                      \
+     (P2VAR) = 3;                                        \
+   else if ((SIZE) >= 4)                                 \
+     (P2VAR) = 2;                                        \
+   else if ((SIZE) >= 2)                                 \
+     (P2VAR) = 1;                                        \
+   else                                                  \
+     (P2VAR) = 0;                                        \
+  } while (0)
+ #endif
+ 
  /* The NOP_OPCODE is for the alignment fill value.
   * fill it a nop instruction so that the disassembler does not choke
   * on it
*************** s_lcomm_internal (needs_align, bytes_p)
*** 1973,1996 ****
  	}
      }
  #endif
     if (!needs_align)
       {
!        /* FIXME. This needs to be machine independent. */
!        if (temp >= 8)
! 	 align = 3;
!        else if (temp >= 4)
! 	 align = 2;
!        else if (temp >= 2)
! 	 align = 1;
!        else
! 	 align = 0;
! 
! #ifdef OBJ_EVAX
!        /* FIXME: This needs to be done in a more general fashion.  */
!        align = 3;
! #endif
  
!        record_alignment(bss_seg, align);
       }
  
    if (needs_align)
--- 1988,2001 ----
  	}
      }
  #endif
+ 
     if (!needs_align)
       {
!        TC_IMPLICIT_LCOMM_ALIGNMENT (temp, align);
  
!        /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it.  */
!        if (align)
!          record_alignment(bss_seg, align);
       }
  
    if (needs_align)
Index: doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.7
diff -c -p -r1.7 internals.texi
*** internals.texi	2000/02/28 04:08:32	1.7
--- internals.texi	2000/03/11 00:55:50
*************** upon the number of bytes that the alignm
*** 1059,1064 ****
--- 1059,1074 ----
  You may define this macro to do special handling for an alignment directive.
  GAS will call it at the end of the assembly.
  
+ @item TC_IMPLICIT_LCOMM_ALIGNMENT (@var{size}, @var{p2var})
+ @cindex TC_IMPLICIT_LCOMM_ALIGNMENT
+ An @code{.lcomm} directive with no explicit alignment parameter will use this
+ macro to set @var{p2var} to the alignment that a request for @var{size} bytes
+ will have.  The alignment is expressed as a power of two.  If no alignment
+ should take place, the macro definition should do nothing.  Some targets define
+ a @code{.bss} directive that is also affected by this macro.  The default
+ definition will set @var{p2var} to the truncated power of two of sizes up to
+ eight bytes.
+ 
  @item md_flush_pending_output
  @cindex md_flush_pending_output
  If you define this macro, GAS will call it each time it skips any space because of a
Index: config/obj-evax.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-evax.h,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 obj-evax.h
*** obj-evax.h	1999/05/03 07:28:41	1.1.1.1
--- obj-evax.h	2000/03/11 00:50:05
***************
*** 1,5 ****
  /* This file is obj-evax.h
!    Copyright (C) 1996 Free Software Foundation, Inc.
     Contributed by Klaus Kämpf (kkaempf@progis.de) of
       proGIS Software, Aachen, Germany.
  
--- 1,5 ----
  /* This file is obj-evax.h
!    Copyright (C) 1996, 2000 Free Software Foundation, Inc.
     Contributed by Klaus Kämpf (kkaempf@progis.de) of
       proGIS Software, Aachen, Germany.
  
*************** typedef void *object_headers;
*** 84,89 ****
--- 84,91 ----
  #define PDSC_S_M_NO_JACKET 0x20		/* high byte */
  
  #define LKP_S_K_SIZE 16
+ 
+ #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 3
  
  /*
   * Local Variables:

brgds, H-P

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