diff options
author | Segher Boessenkool <segher@kernel.crashing.org> | 2017-06-11 00:21:34 +0200 |
---|---|---|
committer | Segher Boessenkool <segher@gcc.gnu.org> | 2017-06-11 00:21:34 +0200 |
commit | 85e71e35052b106c8a7de44a7c209292b2e9f560 (patch) | |
tree | 582399e89d12205dff4671c13c554f48cfa5ca4b /gcc | |
parent | e525ddf40fff65b421e6d00615b1c15c69e5b946 (diff) | |
download | gcc-85e71e35052b106c8a7de44a7c209292b2e9f560.zip gcc-85e71e35052b106c8a7de44a7c209292b2e9f560.tar.gz gcc-85e71e35052b106c8a7de44a7c209292b2e9f560.tar.bz2 |
rs6000: Factor out emit_split_stack_prologue
This is a first patch to make the prologue code more manageable.
* config/rs6000/rs6000.c (emit_split_stack_prologue): New function,
factored out from ...
(rs6000_emit_prologue): ... here.
From-SVN: r249095
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 86 |
2 files changed, 53 insertions, 39 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9799675..0ff3f68 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-06-10 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/rs6000.c (emit_split_stack_prologue): New function, + factored out from ... + (rs6000_emit_prologue): ... here. + 2017-06-10 Jan Hubicka <hubicka@ucw.cz> * predict.c (drop_profile): Also drop individual bb/edge and cgraph diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 63ca2d1..90d028c 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -28106,6 +28106,51 @@ rs6000_set_handled_components (sbitmap components) cfun->machine->lr_is_wrapped_separately = true; } +/* 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 + arg pointer is the top of the current frame. */ +static void +emit_split_stack_prologue (rs6000_stack_t *info, rtx_insn *sp_adjust, + HOST_WIDE_INT frame_off, rtx frame_reg_rtx) +{ + cfun->machine->split_stack_argp_used = true; + + if (sp_adjust) + { + rtx r12 = gen_rtx_REG (Pmode, 12); + rtx sp_reg_rtx = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM); + rtx set_r12 = gen_rtx_SET (r12, sp_reg_rtx); + emit_insn_before (set_r12, sp_adjust); + } + else if (frame_off != 0 || REGNO (frame_reg_rtx) != 12) + { + rtx r12 = gen_rtx_REG (Pmode, 12); + if (frame_off == 0) + emit_move_insn (r12, frame_reg_rtx); + else + emit_insn (gen_add3_insn (r12, frame_reg_rtx, GEN_INT (frame_off))); + } + + if (info->push_p) + { + rtx r12 = gen_rtx_REG (Pmode, 12); + rtx r29 = gen_rtx_REG (Pmode, 29); + rtx cr7 = gen_rtx_REG (CCUNSmode, CR7_REGNO); + rtx not_more = gen_label_rtx (); + rtx jump; + + jump = gen_rtx_IF_THEN_ELSE (VOIDmode, + gen_rtx_GEU (VOIDmode, cr7, const0_rtx), + gen_rtx_LABEL_REF (VOIDmode, not_more), + pc_rtx); + jump = emit_jump_insn (gen_rtx_SET (pc_rtx, jump)); + JUMP_LABEL (jump) = not_more; + LABEL_NUSES (not_more) += 1; + emit_move_insn (r12, r29); + emit_label (not_more); + } +} + /* Emit function prologue as insns. */ void @@ -29006,46 +29051,9 @@ rs6000_emit_prologue (void) emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT)); } + /* Set up the arg pointer (r12) for -fsplit-stack code. */ if (using_split_stack && split_stack_arg_pointer_used_p ()) - { - /* 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 arg pointer is the top of the - current frame. */ - cfun->machine->split_stack_argp_used = true; - if (sp_adjust) - { - rtx r12 = gen_rtx_REG (Pmode, 12); - rtx set_r12 = gen_rtx_SET (r12, sp_reg_rtx); - emit_insn_before (set_r12, sp_adjust); - } - else if (frame_off != 0 || REGNO (frame_reg_rtx) != 12) - { - rtx r12 = gen_rtx_REG (Pmode, 12); - if (frame_off == 0) - emit_move_insn (r12, frame_reg_rtx); - else - emit_insn (gen_add3_insn (r12, frame_reg_rtx, GEN_INT (frame_off))); - } - if (info->push_p) - { - rtx r12 = gen_rtx_REG (Pmode, 12); - rtx r29 = gen_rtx_REG (Pmode, 29); - rtx cr7 = gen_rtx_REG (CCUNSmode, CR7_REGNO); - rtx not_more = gen_label_rtx (); - rtx jump; - - jump = gen_rtx_IF_THEN_ELSE (VOIDmode, - gen_rtx_GEU (VOIDmode, cr7, const0_rtx), - gen_rtx_LABEL_REF (VOIDmode, not_more), - pc_rtx); - jump = emit_jump_insn (gen_rtx_SET (pc_rtx, jump)); - JUMP_LABEL (jump) = not_more; - LABEL_NUSES (not_more) += 1; - emit_move_insn (r12, r29); - emit_label (not_more); - } - } + emit_split_stack_prologue (info, sp_adjust, frame_off, frame_reg_rtx); } /* Output .extern statements for the save/restore routines we use. */ |