Commit 1509ec03 by Chung-Ju Wu Committed by Chung-Ju Wu

[NDS32] In nds32_valid_stack_push_pop_p(), we look into OP rtx to see if we…

[NDS32] In nds32_valid_stack_push_pop_p(), we look into OP rtx to see if we indeed save $fp/$gp/$lp registers.

	* config/nds32/nds32-predicates.c
	(nds32_valid_stack_push_pop): Rename to ...
	(nds32_valid_stack_push_pop_p): ... this.
	* config/nds32/nds32-protos.h: Likewise.
	* config/nds32/predicates.md: Likewise.

From-SVN: r214853
parent 88437f39
2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com> 2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32-predicates.c
(nds32_valid_stack_push_pop): Rename to ...
(nds32_valid_stack_push_pop_p): ... this.
* config/nds32/nds32-protos.h: Likewise.
* config/nds32/predicates.md: Likewise.
2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32.c (nds32_gen_stack_v3push): Rename to ... * config/nds32/nds32.c (nds32_gen_stack_v3push): Rename to ...
(nds32_emit_stack_v3push): ... this. (nds32_emit_stack_v3push): ... this.
(nds32_gen_stack_v3pop): Rename to ... (nds32_gen_stack_v3pop): Rename to ...
...@@ -173,12 +173,13 @@ nds32_valid_multiple_load_store (rtx op, bool load_p) ...@@ -173,12 +173,13 @@ nds32_valid_multiple_load_store (rtx op, bool load_p)
3. The last element must be stack adjustment rtx. 3. The last element must be stack adjustment rtx.
See the prologue/epilogue implementation for details. */ See the prologue/epilogue implementation for details. */
bool bool
nds32_valid_stack_push_pop (rtx op, bool push_p) nds32_valid_stack_push_pop_p (rtx op, bool push_p)
{ {
int index; int index;
int total_count; int total_count;
int rest_count; int rest_count;
int first_regno; int first_regno;
int save_fp, save_gp, save_lp;
rtx elt; rtx elt;
rtx elt_reg; rtx elt_reg;
rtx elt_mem; rtx elt_mem;
...@@ -234,14 +235,18 @@ nds32_valid_stack_push_pop (rtx op, bool push_p) ...@@ -234,14 +235,18 @@ nds32_valid_stack_push_pop (rtx op, bool push_p)
The $sp adjustment rtx, $fp push rtx, $gp push rtx, The $sp adjustment rtx, $fp push rtx, $gp push rtx,
and $lp push rtx are excluded. */ and $lp push rtx are excluded. */
/* Detect whether we have $fp, $gp, or $lp in the parallel rtx. */
save_fp = reg_mentioned_p (gen_rtx_REG (SImode, FP_REGNUM), op);
save_gp = reg_mentioned_p (gen_rtx_REG (SImode, GP_REGNUM), op);
save_lp = reg_mentioned_p (gen_rtx_REG (SImode, LP_REGNUM), op);
/* Exclude last $sp adjustment rtx. */ /* Exclude last $sp adjustment rtx. */
rest_count = total_count - 1; rest_count = total_count - 1;
/* Exclude $fp, $gp, and $lp if they are in the parallel rtx. */ /* Exclude $fp, $gp, and $lp if they are in the parallel rtx. */
if (cfun->machine->fp_size) if (save_fp)
rest_count--; rest_count--;
if (cfun->machine->gp_size) if (save_gp)
rest_count--; rest_count--;
if (cfun->machine->lp_size) if (save_lp)
rest_count--; rest_count--;
if (rest_count > 0) if (rest_count > 0)
...@@ -275,7 +280,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p) ...@@ -275,7 +280,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p)
/* Check $fp/$gp/$lp one by one. /* Check $fp/$gp/$lp one by one.
We use 'push_p' to pick up reg rtx and mem rtx. */ We use 'push_p' to pick up reg rtx and mem rtx. */
if (cfun->machine->fp_size) if (save_fp)
{ {
elt = XVECEXP (op, 0, index); elt = XVECEXP (op, 0, index);
elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt); elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
...@@ -287,7 +292,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p) ...@@ -287,7 +292,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p)
|| REGNO (elt_reg) != FP_REGNUM) || REGNO (elt_reg) != FP_REGNUM)
return false; return false;
} }
if (cfun->machine->gp_size) if (save_gp)
{ {
elt = XVECEXP (op, 0, index); elt = XVECEXP (op, 0, index);
elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt); elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
...@@ -299,7 +304,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p) ...@@ -299,7 +304,7 @@ nds32_valid_stack_push_pop (rtx op, bool push_p)
|| REGNO (elt_reg) != GP_REGNUM) || REGNO (elt_reg) != GP_REGNUM)
return false; return false;
} }
if (cfun->machine->lp_size) if (save_lp)
{ {
elt = XVECEXP (op, 0, index); elt = XVECEXP (op, 0, index);
elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt); elt_mem = push_p ? SET_DEST (elt) : SET_SRC (elt);
......
...@@ -80,7 +80,7 @@ extern bool nds32_valid_multiple_load_store (rtx, bool); ...@@ -80,7 +80,7 @@ extern bool nds32_valid_multiple_load_store (rtx, bool);
/* Auxiliary functions for stack operation predicate checking. */ /* Auxiliary functions for stack operation predicate checking. */
extern bool nds32_valid_stack_push_pop (rtx, bool); extern bool nds32_valid_stack_push_pop_p (rtx, bool);
/* Auxiliary functions for bit operation detection. */ /* Auxiliary functions for bit operation detection. */
......
...@@ -77,16 +77,16 @@ ...@@ -77,16 +77,16 @@
(match_code "parallel") (match_code "parallel")
{ {
/* To verify 'push' operation, pass 'true' for the second argument. /* To verify 'push' operation, pass 'true' for the second argument.
See the implementation in nds32.c for details. */ See the implementation in nds32-predicates.c for details. */
return nds32_valid_stack_push_pop (op, true); return nds32_valid_stack_push_pop_p (op, true);
}) })
(define_special_predicate "nds32_stack_pop_operation" (define_special_predicate "nds32_stack_pop_operation"
(match_code "parallel") (match_code "parallel")
{ {
/* To verify 'pop' operation, pass 'false' for the second argument. /* To verify 'pop' operation, pass 'false' for the second argument.
See the implementation in nds32.c for details. */ See the implementation in nds32-predicates.c for details. */
return nds32_valid_stack_push_pop (op, false); return nds32_valid_stack_push_pop_p (op, false);
}) })
;; ------------------------------------------------------------------------ ;; ------------------------------------------------------------------------
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