From e3b3b59683c1e7d31a9d313dd97394abebf644be Mon Sep 17 00:00:00 2001 From: "Vladimir N. Makarov" Date: Fri, 13 Nov 2020 12:45:59 -0500 Subject: [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. --- gcc/reload.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/reload.c') diff --git a/gcc/reload.c b/gcc/reload.c index 78b4049..445f9bd 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -2656,6 +2656,22 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, hard_regs_live_known = live_known; static_reload_reg_p = reload_reg_p; + if (JUMP_P (insn) && INSN_CODE (insn) < 0) + { + extract_insn (insn); + for (i = 0; i < recog_data.n_operands; i++) + if (recog_data.operand_type[i] != OP_IN) + break; + if (i < recog_data.n_operands) + { + error_for_asm (insn, + "the target does not support asm goto " + "with outputs in %"); + ira_nullify_asm_goto (insn); + return 0; + } + } + /* JUMP_INSNs and CALL_INSNs are not allowed to have any output reloads; neither are insns that SET cc0. Insns that use CC0 are not allowed to have any input reloads. */ -- cgit v1.1