[m-rev.] for review: only reserve 2 registers for global register on x86

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Nov 8 17:45:50 AEDT 2007


For review by anyone.

Estimated hours taken: 1
Branches: main

As discussed on mercury-developers, reduce the number of registers that
are reserved for use as gcc global register variables on x86 machines
for non-PIC Mercury code from three to two.

This change should reduce the frequency of register allocation problems
occurring with gcc on x86 machines, at the cost of increasing execution
time for non-PIC by about 2.2%.   (That figure is based on our standard
benchmark.)

runtime/machdeps/i386_regs.h:
 	Do not reserve an extra register for use as a global register
 	variable for non-PIC on x86.

configure.in:
 	Conform to the new number of global register variables.

 	Define EXT_FOR_LINK_WITH_PIC_OBJECTS as .o rather than .lpic_o
 	on x86.  (The latter should only be used when MR_PIC_REG has
 	some meaning.)

compiler/compile_target_code.m:
 	Update a comment: MR_PIC_REG no longer has an effect on x86
 	machines.

Julien.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.508
diff -u -r1.508 configure.in
--- configure.in	8 Nov 2007 06:13:20 -0000	1.508
+++ configure.in	8 Nov 2007 06:22:56 -0000
@@ -3294,9 +3294,9 @@

  case "$host" in
  	i*86-*)
-		# NUM_REAL_REGS=3
+		# NUM_REAL_REGS=2
  		# but succip and sp are real regs, so subtract 2
-		NUM_REAL_R_REGS=1
+		NUM_REAL_R_REGS=0
  		NUM_REAL_R_TEMPS=0
  		HAVE_DELAY_SLOT=
  		;;
@@ -3476,7 +3476,7 @@
  # Object files with extension $EXT_FOR_LINK_WITH_PIC_OBJECTS are used
  # in executables which are linked with shared Mercury libraries.
  # EXT_FOR_LINK_WITH_PIC_OBJECTS should be `lpic_o' if `-DMR_PIC_REG'
-# has any effect (currently only on x86), or `o' otherwise.
+# has any effect (currently nowhere.)
  EXT_FOR_LINK_WITH_PIC_OBJECTS=lpic_o
  EXT_FOR_SHARED_LIB=$LIB_SUFFIX
  USE_DLLS=no
@@ -3556,13 +3556,14 @@
  				;;
  		esac

+		EXT_FOR_LINK_WITH_PIC_OBJECTS=o
+
  		# On x86_64 machines we use -fPIC rather than -fpic
  		# in order to avoid limits on the size of the global
  		# offset table implied by the latter.
  		case "$host" in
  			x86_64-*-linux*)
  				CFLAGS_FOR_PIC="-fPIC -DMR_PIC"
-				EXT_FOR_LINK_WITH_PIC_OBJECTS=o
  			;;
  		esac
  		;;
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.122
diff -u -r1.122 compile_target_code.m
--- compiler/compile_target_code.m	24 Oct 2007 09:21:14 -0000	1.122
+++ compiler/compile_target_code.m	8 Nov 2007 02:53:51 -0000
@@ -2260,8 +2260,7 @@
              ( MercuryLinkage = "shared" ->
                  (
                      % We only need to create `.lpic' files if `-DMR_PIC_REG'
-                    % has an effect, which currently is only with grades using
-                    % GCC global registers on x86 Unix.
+                    % has an effect, which is currently nowhere.
                      ( LinkWithPicObjExt = ObjExt
                      ; HighLevelCode = yes
                      ; GCCGlobals = no
Index: runtime/machdeps/i386_regs.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/machdeps/i386_regs.h,v
retrieving revision 1.22
diff -u -r1.22 i386_regs.h
--- runtime/machdeps/i386_regs.h	14 Feb 2003 09:57:27 -0000	1.22
+++ runtime/machdeps/i386_regs.h	7 Nov 2007 05:59:37 -0000
@@ -38,11 +38,7 @@
  ** the frame pointer.  (E.g. the one containing io__init_state/2.)
  */

-#if MR_PIC_REG
-  #define MR_NUM_REAL_REGS 2
-#else
-  #define MR_NUM_REAL_REGS 3
-#endif
+#define MR_NUM_REAL_REGS 2

  register	MR_Word	MR_mr0 __asm__("esi");	/* sp */
  register	MR_Word	MR_mr1 __asm__("edi");	/* succip */
@@ -50,50 +46,22 @@
  #define MR_real_reg_number_mr0	esi
  #define MR_real_reg_number_mr1	edi

-#if MR_PIC_REG
-  #define 	MR_mr2	MR_fake_reg[2]
-#else
-  register	MR_Word	MR_mr2 __asm__("ebx");	/* r1 */
-
-  #define MR_real_reg_number_mr2	ebx
-
-#endif
-
-#if MR_PIC_REG
-
-#define MR_save_regs_to_mem(save_area) (	\
-	save_area[0] = MR_mr0,			\
-	save_area[1] = MR_mr1,			\
-	(void)0					\
-)
-
-#define MR_restore_regs_from_mem(save_area) (	\
-	MR_mr0 = save_area[0],			\
-	MR_mr1 = save_area[1],			\
-	(void)0					\
-)
-
-#else /* ! MR_PIC_REG */
-
  #define MR_save_regs_to_mem(save_area) (	\
  	save_area[0] = MR_mr0,			\
  	save_area[1] = MR_mr1,			\
-	save_area[2] = MR_mr2,			\
  	(void)0					\
  )

  #define MR_restore_regs_from_mem(save_area) (	\
  	MR_mr0 = save_area[0],			\
  	MR_mr1 = save_area[1],			\
-	MR_mr2 = save_area[2],			\
  	(void)0					\
  )

-#endif	/* ! MR_PIC_REG */
-
  #define MR_save_transient_regs_to_mem(save_area)	((void)0)
  #define MR_restore_transient_regs_from_mem(save_area)	((void)0)

+#define MR_mr2	MR_fake_reg[2]
  #define	MR_mr3	MR_fake_reg[3]
  #define	MR_mr4	MR_fake_reg[4]
  #define	MR_mr5	MR_fake_reg[5]
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list