Commit 9a58d6cd by Segher Boessenkool Committed by Segher Boessenkool

rs6000: Factor out emit_vrsave_prologue

This is a second patch to make the prologue code more manageable.


	* config/rs6000/rs6000.c (emit_vrsave_prologue): New function,
	factored out from ...
	(rs6000_emit_prologue): ... here.

From-SVN: r249096
parent 85e71e35
2017-06-10 Segher Boessenkool <segher@kernel.crashing.org> 2017-06-10 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.c (emit_vrsave_prologue): New function,
factored out from ...
(rs6000_emit_prologue): ... here.
2017-06-10 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.c (emit_split_stack_prologue): New function, * config/rs6000/rs6000.c (emit_split_stack_prologue): New function,
factored out from ... factored out from ...
(rs6000_emit_prologue): ... here. (rs6000_emit_prologue): ... here.
......
...@@ -28106,6 +28106,34 @@ rs6000_set_handled_components (sbitmap components) ...@@ -28106,6 +28106,34 @@ rs6000_set_handled_components (sbitmap components)
cfun->machine->lr_is_wrapped_separately = true; cfun->machine->lr_is_wrapped_separately = true;
} }
/* VRSAVE is a bit vector representing which AltiVec registers
are used. The OS uses this to determine which vector
registers to save on a context switch. We need to save
VRSAVE on the stack frame, add whatever AltiVec registers we
used in this function, and do the corresponding magic in the
epilogue. */
static void
emit_vrsave_prologue (rs6000_stack_t *info, int save_regno,
HOST_WIDE_INT frame_off, rtx frame_reg_rtx)
{
/* Get VRSAVE into a GPR. */
rtx reg = gen_rtx_REG (SImode, save_regno);
rtx vrsave = gen_rtx_REG (SImode, VRSAVE_REGNO);
if (TARGET_MACHO)
emit_insn (gen_get_vrsave_internal (reg));
else
emit_insn (gen_rtx_SET (reg, vrsave));
/* Save VRSAVE. */
int offset = info->vrsave_save_offset + frame_off;
emit_insn (gen_frame_store (reg, frame_reg_rtx, offset));
/* Include the registers in the mask. */
emit_insn (gen_iorsi3 (reg, reg, GEN_INT (info->vrsave_mask)));
emit_insn (generate_set_vrsave (reg, info, 0));
}
/* Set up the arg pointer (r12) for -fsplit-stack code. If __morestack was /* Set up the arg pointer (r12) for -fsplit-stack code. If __morestack was
called, it left the arg pointer to the old stack in r29. Otherwise, the called, it left the arg pointer to the old stack in r29. Otherwise, the
arg pointer is the top of the current frame. */ arg pointer is the top of the current frame. */
...@@ -28933,17 +28961,12 @@ rs6000_emit_prologue (void) ...@@ -28933,17 +28961,12 @@ rs6000_emit_prologue (void)
used in this function, and do the corresponding magic in the used in this function, and do the corresponding magic in the
epilogue. */ epilogue. */
if (!WORLD_SAVE_P (info) if (!WORLD_SAVE_P (info) && info->vrsave_size != 0)
&& info->vrsave_size != 0)
{ {
rtx reg, vrsave; /* Get VRSAVE into a GPR. Note that ABI_V4 and ABI_DARWIN might
int offset;
int save_regno;
/* Get VRSAVE onto a GPR. Note that ABI_V4 and ABI_DARWIN might
be using r12 as frame_reg_rtx and r11 as the static chain be using r12 as frame_reg_rtx and r11 as the static chain
pointer for nested functions. */ pointer for nested functions. */
save_regno = 12; int save_regno = 12;
if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
&& !using_static_chain_p) && !using_static_chain_p)
save_regno = 11; save_regno = 11;
...@@ -28953,23 +28976,9 @@ rs6000_emit_prologue (void) ...@@ -28953,23 +28976,9 @@ rs6000_emit_prologue (void)
if (using_static_chain_p) if (using_static_chain_p)
save_regno = 0; save_regno = 0;
} }
NOT_INUSE (save_regno); NOT_INUSE (save_regno);
reg = gen_rtx_REG (SImode, save_regno);
vrsave = gen_rtx_REG (SImode, VRSAVE_REGNO);
if (TARGET_MACHO)
emit_insn (gen_get_vrsave_internal (reg));
else
emit_insn (gen_rtx_SET (reg, vrsave));
/* Save VRSAVE. */
offset = info->vrsave_save_offset + frame_off;
insn = emit_insn (gen_frame_store (reg, frame_reg_rtx, offset));
/* Include the registers in the mask. */
emit_insn (gen_iorsi3 (reg, reg, GEN_INT ((int) info->vrsave_mask)));
insn = emit_insn (generate_set_vrsave (reg, info, 0)); emit_vrsave_prologue (info, save_regno, frame_off, frame_reg_rtx);
} }
/* If we are using RS6000_PIC_OFFSET_TABLE_REGNUM, we need to set it up. */ /* If we are using RS6000_PIC_OFFSET_TABLE_REGNUM, we need to set it up. */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment