diff options
author | Vladimir N. Makarov <vmakarov@redhat.com> | 2020-11-13 12:45:59 -0500 |
---|---|---|
committer | Vladimir N. Makarov <vmakarov@redhat.com> | 2020-11-13 13:01:51 -0500 |
commit | e3b3b59683c1e7d31a9d313dd97394abebf644be (patch) | |
tree | 34a176a8e704a5a27a214f391da1c5ca041a2462 /gcc/ira.c | |
parent | 67100cb50ea22e1fc855360b887959f874fafe2c (diff) | |
download | gcc-e3b3b59683c1e7d31a9d313dd97394abebf644be.zip gcc-e3b3b59683c1e7d31a9d313dd97394abebf644be.tar.gz gcc-e3b3b59683c1e7d31a9d313dd97394abebf644be.tar.bz2 |
[PATCH] Implementation of asm goto outputs
gcc/
* cfgexpand.c (expand_asm_stmt): Output asm goto with outputs too.
Place insns after asm goto on edges.
* doc/extend.texi: Reflect the changes in asm goto documentation.
* gimple.c (gimple_build_asm_1): Remove an assert checking output
absence for asm goto.
* gimple.h (gimple_asm_label_op, gimple_asm_set_label_op): Take
possible asm goto outputs into account.
* ira.c (ira): Remove critical edges for potential asm goto output
reloads.
(ira_nullify_asm_goto): New function.
* ira.h (ira_nullify_asm_goto): New prototype.
* lra-assigns.c (lra_split_hard_reg_for): Use ira_nullify_asm_goto.
Check that splitting is done inside a basic block.
* lra-constraints.c (curr_insn_transform): Permit output reloads
for any jump insn.
* lra-spills.c (lra_final_code_change): Remove USEs added in ira
for asm gotos.
* lra.c (lra_process_new_insns): Place output reload insns after
jumps in the beginning of destination BBs.
* reload.c (find_reloads): Report error for asm gotos with
outputs. Modify them to keep CFG consistency to avoid crashes.
* tree-into-ssa.c (rewrite_stmt): Don't put debug stmt after asm
goto.
gcc/c/
* c-parser.c (c_parser_asm_statement): Parse outputs for asm
goto too.
* c-typeck.c (build_asm_expr): Remove an assert checking output
absence for asm goto.
gcc/cp
* parser.c (cp_parser_asm_definition): Parse outputs for asm
goto too.
gcc/testsuite/
* c-c++-common/asmgoto-2.c: Permit output in asm goto.
* gcc.c-torture/compile/asmgoto-2.c: New.
* gcc.c-torture/compile/asmgoto-3.c: New.
* gcc.c-torture/compile/asmgoto-4.c: New.
* gcc.c-torture/compile/asmgoto-5.c: New.
Diffstat (limited to 'gcc/ira.c')
-rw-r--r-- | gcc/ira.c | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -5401,6 +5401,48 @@ ira (FILE *f) int ira_max_point_before_emit; bool saved_flag_caller_saves = flag_caller_saves; enum ira_region saved_flag_ira_region = flag_ira_region; + basic_block bb; + edge_iterator ei; + edge e; + bool output_jump_reload_p = false; + + if (ira_use_lra_p) + { + /* First put potential jump output reloads on the output edges + as USE which will be removed at the end of LRA. The major + goal is actually to create BBs for critical edges for LRA and + populate them later by live info. In LRA it will be + difficult to do this. */ + FOR_EACH_BB_FN (bb, cfun) + { + rtx_insn *end = BB_END (bb); + if (!JUMP_P (end)) + continue; + extract_insn (end); + for (int i = 0; i < recog_data.n_operands; i++) + if (recog_data.operand_type[i] != OP_IN) + { + output_jump_reload_p = true; + FOR_EACH_EDGE (e, ei, bb->succs) + if (EDGE_CRITICAL_P (e) + && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)) + { + ira_assert (!(e->flags & EDGE_ABNORMAL)); + start_sequence (); + /* We need to put some no-op insn here. We can + not put a note as commit_edges insertion will + fail. */ + emit_insn (gen_rtx_USE (VOIDmode, const1_rtx)); + rtx_insn *insns = get_insns (); + end_sequence (); + insert_insn_on_edge (insns, e); + } + break; + } + } + if (output_jump_reload_p) + commit_edge_insertions (); + } if (flag_ira_verbose < 10) { @@ -5709,6 +5751,21 @@ ira (FILE *f) } } +/* Modify asm goto to avoid further trouble with this insn. We can + not replace the insn by USE as in other asm insns as we still + need to keep CFG consistency. */ +void +ira_nullify_asm_goto (rtx_insn *insn) +{ + ira_assert (JUMP_P (insn) && INSN_CODE (insn) < 0); + rtx tmp = extract_asm_operands (PATTERN (insn)); + PATTERN (insn) = gen_rtx_ASM_OPERANDS (VOIDmode, ggc_strdup (""), "", 0, + rtvec_alloc (0), + rtvec_alloc (0), + ASM_OPERANDS_LABEL_VEC (tmp), + ASM_OPERANDS_SOURCE_LOCATION(tmp)); +} + static void do_reload (void) { |