comparison gcc/reg-stack.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Register to Stack convert for GNU compiler. 1 /* Register to Stack convert for GNU compiler.
2 Copyright (C) 1992-2018 Free Software Foundation, Inc. 2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it 6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by 7 under the terms of the GNU General Public License as published by
366 366
367 Similarly if the stack is empty. */ 367 Similarly if the stack is empty. */
368 if (regstack->top <= 0) 368 if (regstack->top <= 0)
369 return; 369 return;
370 370
371 COPY_HARD_REG_SET (temp_stack.reg_set, regstack->reg_set); 371 temp_stack.reg_set = regstack->reg_set;
372 372
373 for (top = temp_stack.top = regstack->top; top >= 0; top--) 373 for (top = temp_stack.top = regstack->top; top >= 0; top--)
374 temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top; 374 temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top;
375 375
376 change_stack (insn, regstack, &temp_stack, EMIT_BEFORE); 376 change_stack (insn, regstack, &temp_stack, EMIT_BEFORE);
482 482
483 get_asm_operands_in_out (body, &n_outputs, &n_inputs); 483 get_asm_operands_in_out (body, &n_outputs, &n_inputs);
484 484
485 if (which_alternative < 0) 485 if (which_alternative < 0)
486 { 486 {
487 malformed_asm = 1;
488 /* Avoid further trouble with this insn. */ 487 /* Avoid further trouble with this insn. */
489 PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx); 488 PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
490 return 0; 489 return 0;
491 } 490 }
492 const operand_alternative *op_alt = which_op_alt (); 491 const operand_alternative *op_alt = which_op_alt ();
543 int j; 542 int j;
544 543
545 for (j = 0; j < n_clobbers; j++) 544 for (j = 0; j < n_clobbers; j++)
546 if (REGNO (recog_data.operand[i]) == REGNO (clobber_reg[j])) 545 if (REGNO (recog_data.operand[i]) == REGNO (clobber_reg[j]))
547 { 546 {
548 error_for_asm (insn, "output constraint %d cannot be specified together with \"%s\" clobber", 547 error_for_asm (insn, "output constraint %d cannot be "
548 "specified together with %qs clobber",
549 i, reg_names [REGNO (clobber_reg[j])]); 549 i, reg_names [REGNO (clobber_reg[j])]);
550 malformed_asm = 1; 550 malformed_asm = 1;
551 break; 551 break;
552 } 552 }
553 if (j == n_clobbers) 553 if (j == n_clobbers)
566 if (reg_used_as_output[i]) 566 if (reg_used_as_output[i])
567 break; 567 break;
568 568
569 if (i != LAST_STACK_REG + 1) 569 if (i != LAST_STACK_REG + 1)
570 { 570 {
571 error_for_asm (insn, "output regs must be grouped at top of stack"); 571 error_for_asm (insn, "output registers must be grouped at top of stack");
572 malformed_asm = 1; 572 malformed_asm = 1;
573 } 573 }
574 574
575 /* Enforce rule #2: All implicitly popped input regs must be closer 575 /* Enforce rule #2: All implicitly popped input regs must be closer
576 to the top of the reg-stack than any input that is not implicitly 576 to the top of the reg-stack than any input that is not implicitly
606 break; 606 break;
607 607
608 if (i != LAST_STACK_REG + 1) 608 if (i != LAST_STACK_REG + 1)
609 { 609 {
610 error_for_asm (insn, 610 error_for_asm (insn,
611 "implicitly popped regs must be grouped at top of stack"); 611 "implicitly popped registers must be grouped "
612 "at top of stack");
612 malformed_asm = 1; 613 malformed_asm = 1;
613 } 614 }
614 615
615 /* Search for first not-explicitly used reg. */ 616 /* Search for first not-explicitly used reg. */
616 for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++) 617 for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
623 break; 624 break;
624 625
625 if (i != LAST_STACK_REG + 1) 626 if (i != LAST_STACK_REG + 1)
626 { 627 {
627 error_for_asm (insn, 628 error_for_asm (insn,
628 "explicitly used regs must be grouped at top of stack"); 629 "explicitly used registers must be grouped "
630 "at top of stack");
629 malformed_asm = 1; 631 malformed_asm = 1;
630 } 632 }
631 633
632 /* Enforce rule #3: If any input operand uses the "f" constraint, all 634 /* Enforce rule #3: If any input operand uses the "f" constraint, all
633 output constraints must use the "&" earlyclobber. 635 output constraints must use the "&" earlyclobber.
1813 case UNSPEC_SIN: 1815 case UNSPEC_SIN:
1814 case UNSPEC_COS: 1816 case UNSPEC_COS:
1815 case UNSPEC_FRNDINT: 1817 case UNSPEC_FRNDINT:
1816 case UNSPEC_F2XM1: 1818 case UNSPEC_F2XM1:
1817 1819
1820 case UNSPEC_FRNDINT_ROUNDEVEN:
1818 case UNSPEC_FRNDINT_FLOOR: 1821 case UNSPEC_FRNDINT_FLOOR:
1819 case UNSPEC_FRNDINT_CEIL: 1822 case UNSPEC_FRNDINT_CEIL:
1820 case UNSPEC_FRNDINT_TRUNC: 1823 case UNSPEC_FRNDINT_TRUNC:
1821 1824
1822 /* Above insns operate on the top of the stack. */ 1825 /* Above insns operate on the top of the stack. */
2638 previously selected stack order. */ 2641 previously selected stack order. */
2639 2642
2640 /* By now, the only difference should be the order of the stack, 2643 /* By now, the only difference should be the order of the stack,
2641 not their depth or liveliness. */ 2644 not their depth or liveliness. */
2642 2645
2643 gcc_assert (hard_reg_set_equal_p (old->reg_set, new_stack->reg_set)); 2646 gcc_assert (old->reg_set == new_stack->reg_set);
2644 gcc_assert (old->top == new_stack->top); 2647 gcc_assert (old->top == new_stack->top);
2645 2648
2646 /* If the stack is not empty (new_stack->top != -1), loop here emitting 2649 /* If the stack is not empty (new_stack->top != -1), loop here emitting
2647 swaps until the stack is correct. 2650 swaps until the stack is correct.
2648 2651
2925 change_stack (after, &regstack, target_stack, EMIT_BEFORE); 2928 change_stack (after, &regstack, target_stack, EMIT_BEFORE);
2926 2929
2927 seq = get_insns (); 2930 seq = get_insns ();
2928 end_sequence (); 2931 end_sequence ();
2929 2932
2933 set_insn_locations (seq, e->goto_locus);
2930 insert_insn_on_edge (seq, e); 2934 insert_insn_on_edge (seq, e);
2931 return true; 2935 return true;
2932 } 2936 }
2933 return false; 2937 return false;
2934 } 2938 }
3152 3156
3153 /* Something failed if the stack lives don't match. If we had malformed 3157 /* Something failed if the stack lives don't match. If we had malformed
3154 asms, we zapped the instruction itself, but that didn't produce the 3158 asms, we zapped the instruction itself, but that didn't produce the
3155 same pattern of register kills as before. */ 3159 same pattern of register kills as before. */
3156 3160
3157 gcc_assert (hard_reg_set_equal_p (regstack.reg_set, bi->out_reg_set) 3161 gcc_assert (regstack.reg_set == bi->out_reg_set || any_malformed_asm);
3158 || any_malformed_asm);
3159 bi->stack_out = regstack; 3162 bi->stack_out = regstack;
3160 bi->done = true; 3163 bi->done = true;
3161 3164
3162 return cfg_altered; 3165 return cfg_altered;
3163 } 3166 }