diff mbox

[i386] : Remove SLOT_VIRTUAL from enum ix86_stack_slot

Message ID CAFULd4bW9+gz55NzGr9muT04UbwgX7L-Rw41HdbPgSx7NXyXYA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Nov. 6, 2012, 4:07 p.m. UTC
Hello!

Attached patch removes SLOT_VIRTUAL and introduces
TARGET_INSTANTIATE_DECLS that takes care of instantiating registers in
ix86_stack_locals array. The patch enables some more stack slot
sharing.

2012-11-06  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (TARGET_INSTANTIATE_DECLS): New define.
	(ix86_instantiate_decls): New function.
	(ix86_expand_builtin) <case IX86_BUILTIN_LDMXCSR>: Use SLOT_TEMP
	stack slot instead of SLOT_VIRTUAL.
	<case IX86_BUILTIN_STMXCSR>: Ditto.
	(assign_386_stack_local): Do not assert when virtual slot is valid.
	* config/i386/i386.h (enum ix86_stack_slot): Remove SLOT_VIRTUAL.
	* config/i386/i386.md (truncdfsf2): Do not use SLOT_VIRTUAL stack slot.
	(truncxf<mode>2): Ditto.
	(floatunssi<mode>2): Ditto.
	(isinf<mode>2): Ditto.
	* config/i386/sync.md (atomic_load<mode>): Ditto.
	(atomic_store<mode>): Ditto.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

Uros.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 193180)
+++ config/i386/i386.c	(working copy)
@@ -23751,9 +23751,6 @@  assign_386_stack_local (enum machine_mode mode, en
 
   gcc_assert (n < MAX_386_STACK_LOCALS);
 
-  /* Virtual slot is valid only before vregs are instantiated.  */
-  gcc_assert ((n == SLOT_VIRTUAL) == !virtuals_instantiated);
-
   for (s = ix86_stack_locals; s; s = s->next)
     if (s->mode == mode && s->n == n)
       return validize_mem (copy_rtx (s->rtl));
@@ -23767,6 +23764,16 @@  assign_386_stack_local (enum machine_mode mode, en
   ix86_stack_locals = s;
   return validize_mem (s->rtl);
 }
+
+static void
+ix86_instantiate_decls (void)
+{
+  struct stack_local_entry *s;
+
+  for (s = ix86_stack_locals; s; s = s->next)
+    if (s->rtl != NULL_RTX)
+      instantiate_decl_rtl (s->rtl);
+}
 
 /* Calculate the length of the memory address in the instruction encoding.
    Includes addr32 prefix, does not include the one-byte modrm, opcode,
@@ -30586,13 +30593,13 @@  ix86_expand_builtin (tree exp, rtx target, rtx sub
 
     case IX86_BUILTIN_LDMXCSR:
       op0 = expand_normal (CALL_EXPR_ARG (exp, 0));
-      target = assign_386_stack_local (SImode, SLOT_VIRTUAL);
+      target = assign_386_stack_local (SImode, SLOT_TEMP);
       emit_move_insn (target, op0);
       emit_insn (gen_sse_ldmxcsr (target));
       return 0;
 
     case IX86_BUILTIN_STMXCSR:
-      target = assign_386_stack_local (SImode, SLOT_VIRTUAL);
+      target = assign_386_stack_local (SImode, SLOT_TEMP);
       emit_insn (gen_sse_stmxcsr (target));
       return copy_to_mode_reg (SImode, target);
 
@@ -41402,6 +41409,9 @@  ix86_memmodel_check (unsigned HOST_WIDE_INT val)
 #undef TARGET_MEMBER_TYPE_FORCES_BLK
 #define TARGET_MEMBER_TYPE_FORCES_BLK ix86_member_type_forces_blk
 
+#undef TARGET_INSTANTIATE_DECLS
+#define TARGET_INSTANTIATE_DECLS ix86_instantiate_decls
+
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD ix86_secondary_reload
 
Index: config/i386/i386.h
===================================================================
--- config/i386/i386.h	(revision 193180)
+++ config/i386/i386.h	(working copy)
@@ -2150,8 +2150,7 @@  enum ix86_entity
 
 enum ix86_stack_slot
 {
-  SLOT_VIRTUAL = 0,
-  SLOT_TEMP,
+  SLOT_TEMP = 0,
   SLOT_CW_STORED,
   SLOT_CW_TRUNC,
   SLOT_CW_FLOOR,
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 193180)
+++ config/i386/i386.md	(working copy)
@@ -4071,10 +4071,7 @@ 
     ;
   else
     {
-      enum ix86_stack_slot slot = (virtuals_instantiated
-				   ? SLOT_TEMP
-				   : SLOT_VIRTUAL);
-      rtx temp = assign_386_stack_local (SFmode, slot);
+      rtx temp = assign_386_stack_local (SFmode, SLOT_TEMP);
       emit_insn (gen_truncdfsf2_with_temp (operands[0], operands[1], temp));
       DONE;
     }
@@ -4255,12 +4252,7 @@ 
       DONE;
     }
   else
-    {
-      enum ix86_stack_slot slot = (virtuals_instantiated
-				   ? SLOT_TEMP
-				   : SLOT_VIRTUAL);
-      operands[2] = assign_386_stack_local (<MODE>mode, slot);
-    }
+    operands[2] = assign_386_stack_local (<MODE>mode, SLOT_TEMP);
 })
 
 (define_insn "*truncxfsf2_mixed"
@@ -5468,12 +5460,7 @@ 
       DONE;
     }
   else
-    {
-      enum ix86_stack_slot slot = (virtuals_instantiated
-				   ? SLOT_TEMP
-				   : SLOT_VIRTUAL);
-      operands[2] = assign_386_stack_local (DImode, slot);
-    }
+    operands[2] = assign_386_stack_local (DImode, SLOT_TEMP);
 })
 
 (define_expand "floatunsdisf2"
@@ -15563,10 +15550,7 @@ 
     emit_insn (gen_fxam<mode>2_i387_with_temp (scratch, operands[1]));
   else
     {
-      enum ix86_stack_slot slot = (virtuals_instantiated
-				   ? SLOT_TEMP
-				   : SLOT_VIRTUAL);
-      rtx temp = assign_386_stack_local (<MODE>mode, slot);
+      rtx temp = assign_386_stack_local (<MODE>mode, SLOT_TEMP);
 
       emit_move_insn (temp, operands[1]);
       emit_insn (gen_fxam<mode>2_i387_with_temp (scratch, temp));
Index: config/i386/sync.md
===================================================================
--- config/i386/sync.md	(revision 193180)
+++ config/i386/sync.md	(working copy)
@@ -149,9 +149,7 @@ 
   if (<MODE>mode == DImode && !TARGET_64BIT)
     emit_insn (gen_atomic_loaddi_fpu
 	       (operands[0], operands[1],
-	        assign_386_stack_local (DImode,
-					(virtuals_instantiated
-					 ? SLOT_TEMP : SLOT_VIRTUAL))));
+	        assign_386_stack_local (DImode, SLOT_TEMP)));
   else
     emit_move_insn (operands[0], operands[1]);
   DONE;
@@ -212,9 +210,7 @@ 
 	 out to be significantly larger than this plus a barrier.  */
       emit_insn (gen_atomic_storedi_fpu
 		 (operands[0], operands[1],
-	          assign_386_stack_local (DImode,
-					  (virtuals_instantiated
-					   ? SLOT_TEMP : SLOT_VIRTUAL))));
+	          assign_386_stack_local (DImode, SLOT_TEMP)));
     }
   else
     {