Mercurial > hg > CbC > CbC_gcc
comparison gcc/regrename.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Register renaming for the GNU compiler. | 1 /* Register renaming for the GNU compiler. |
2 Copyright (C) 2000-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2018 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 |
961 regrename_do_replace (struct du_head *head, int reg) | 961 regrename_do_replace (struct du_head *head, int reg) |
962 { | 962 { |
963 struct du_chain *chain; | 963 struct du_chain *chain; |
964 unsigned int base_regno = head->regno; | 964 unsigned int base_regno = head->regno; |
965 machine_mode mode; | 965 machine_mode mode; |
966 rtx last_reg = NULL_RTX, last_repl = NULL_RTX; | |
966 | 967 |
967 for (chain = head->first; chain; chain = chain->next_use) | 968 for (chain = head->first; chain; chain = chain->next_use) |
968 { | 969 { |
969 unsigned int regno = ORIGINAL_REGNO (*chain->loc); | 970 unsigned int regno = ORIGINAL_REGNO (*chain->loc); |
970 struct reg_attrs *attr = REG_ATTRS (*chain->loc); | 971 struct reg_attrs *attr = REG_ATTRS (*chain->loc); |
973 if (DEBUG_INSN_P (chain->insn) && REGNO (*chain->loc) != base_regno) | 974 if (DEBUG_INSN_P (chain->insn) && REGNO (*chain->loc) != base_regno) |
974 validate_change (chain->insn, &(INSN_VAR_LOCATION_LOC (chain->insn)), | 975 validate_change (chain->insn, &(INSN_VAR_LOCATION_LOC (chain->insn)), |
975 gen_rtx_UNKNOWN_VAR_LOC (), true); | 976 gen_rtx_UNKNOWN_VAR_LOC (), true); |
976 else | 977 else |
977 { | 978 { |
978 validate_change (chain->insn, chain->loc, | 979 if (*chain->loc != last_reg) |
979 gen_raw_REG (GET_MODE (*chain->loc), reg), true); | 980 { |
980 if (regno >= FIRST_PSEUDO_REGISTER) | 981 last_repl = gen_raw_REG (GET_MODE (*chain->loc), reg); |
981 ORIGINAL_REGNO (*chain->loc) = regno; | 982 if (regno >= FIRST_PSEUDO_REGISTER) |
982 REG_ATTRS (*chain->loc) = attr; | 983 ORIGINAL_REGNO (last_repl) = regno; |
983 REG_POINTER (*chain->loc) = reg_ptr; | 984 REG_ATTRS (last_repl) = attr; |
985 REG_POINTER (last_repl) = reg_ptr; | |
986 last_reg = *chain->loc; | |
987 } | |
988 validate_change (chain->insn, chain->loc, last_repl, true); | |
984 } | 989 } |
985 } | 990 } |
986 | 991 |
987 if (!apply_change_group ()) | 992 if (!apply_change_group ()) |
988 return false; | 993 return false; |
1654 (5) For any non-earlyclobber write we find, close open chains | 1659 (5) For any non-earlyclobber write we find, close open chains |
1655 that overlap it. | 1660 that overlap it. |
1656 (6) For any non-earlyclobber write we find in an operand, make | 1661 (6) For any non-earlyclobber write we find in an operand, make |
1657 a new chain or mark the hard register as live. | 1662 a new chain or mark the hard register as live. |
1658 (7) For any REG_UNUSED, close any chains we just opened. | 1663 (7) For any REG_UNUSED, close any chains we just opened. |
1659 (8) For any REG_CFA_RESTORE, kill any chain containing it. | 1664 (8) For any REG_CFA_RESTORE or REG_CFA_REGISTER, kill any chain |
1665 containing its dest. | |
1660 | 1666 |
1661 We cannot deal with situations where we track a reg in one mode | 1667 We cannot deal with situations where we track a reg in one mode |
1662 and see a reference in another mode; these will cause the chain | 1668 and see a reference in another mode; these will cause the chain |
1663 to be marked unrenamable or even cause us to abort the entire | 1669 to be marked unrenamable or even cause us to abort the entire |
1664 basic block. */ | 1670 basic block. */ |
1695 /* A special case to deal with instruction patterns that | 1701 /* A special case to deal with instruction patterns that |
1696 have matching operands with different modes. If we're | 1702 have matching operands with different modes. If we're |
1697 not already tracking such a reg, we won't start here, | 1703 not already tracking such a reg, we won't start here, |
1698 and we must instead make sure to make the operand visible | 1704 and we must instead make sure to make the operand visible |
1699 to the machinery that tracks hard registers. */ | 1705 to the machinery that tracks hard registers. */ |
1700 if (matches >= 0 | 1706 machine_mode i_mode = recog_data.operand_mode[i]; |
1701 && (GET_MODE_SIZE (recog_data.operand_mode[i]) | 1707 if (matches >= 0) |
1702 != GET_MODE_SIZE (recog_data.operand_mode[matches])) | |
1703 && !verify_reg_in_set (op, &live_in_chains)) | |
1704 { | 1708 { |
1705 untracked_operands |= 1 << i; | 1709 machine_mode matches_mode |
1706 untracked_operands |= 1 << matches; | 1710 = recog_data.operand_mode[matches]; |
1711 | |
1712 if (maybe_ne (GET_MODE_SIZE (i_mode), | |
1713 GET_MODE_SIZE (matches_mode)) | |
1714 && !verify_reg_in_set (op, &live_in_chains)) | |
1715 { | |
1716 untracked_operands |= 1 << i; | |
1717 untracked_operands |= 1 << matches; | |
1718 } | |
1707 } | 1719 } |
1708 } | 1720 } |
1709 #ifdef STACK_REGS | 1721 #ifdef STACK_REGS |
1710 if (regstack_completed | 1722 if (regstack_completed |
1711 && REG_P (op) | 1723 && REG_P (op) |
1869 scan_rtx (insn, &XEXP (note, 0), NO_REGS, terminate_dead, | 1881 scan_rtx (insn, &XEXP (note, 0), NO_REGS, terminate_dead, |
1870 OP_IN); | 1882 OP_IN); |
1871 } | 1883 } |
1872 | 1884 |
1873 /* Step 8: Kill the chains involving register restores. Those | 1885 /* Step 8: Kill the chains involving register restores. Those |
1874 should restore _that_ register. */ | 1886 should restore _that_ register. Similar for REG_CFA_REGISTER. */ |
1875 for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) | 1887 for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) |
1876 if (REG_NOTE_KIND (note) == REG_CFA_RESTORE) | 1888 if (REG_NOTE_KIND (note) == REG_CFA_RESTORE |
1877 scan_rtx (insn, &XEXP (note, 0), NO_REGS, mark_all_read, OP_IN); | 1889 || REG_NOTE_KIND (note) == REG_CFA_REGISTER) |
1878 } | 1890 { |
1879 else if (DEBUG_INSN_P (insn) | 1891 rtx *x = &XEXP (note, 0); |
1892 if (!*x) | |
1893 x = &PATTERN (insn); | |
1894 if (GET_CODE (*x) == PARALLEL) | |
1895 x = &XVECEXP (*x, 0, 0); | |
1896 if (GET_CODE (*x) == SET) | |
1897 x = &SET_DEST (*x); | |
1898 scan_rtx (insn, x, NO_REGS, mark_all_read, OP_IN); | |
1899 } | |
1900 } | |
1901 else if (DEBUG_BIND_INSN_P (insn) | |
1880 && !VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn))) | 1902 && !VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (insn))) |
1881 { | 1903 { |
1882 scan_rtx (insn, &INSN_VAR_LOCATION_LOC (insn), | 1904 scan_rtx (insn, &INSN_VAR_LOCATION_LOC (insn), |
1883 ALL_REGS, mark_read, OP_IN); | 1905 ALL_REGS, mark_read, OP_IN); |
1884 } | 1906 } |