comparison gcc/read-rtl-function.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 /* read-rtl-function.c - Reader for RTL function dumps 1 /* read-rtl-function.c - Reader for RTL function dumps
2 Copyright (C) 2016-2018 Free Software Foundation, Inc. 2 Copyright (C) 2016-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 under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
39 #include "toplev.h" 39 #include "toplev.h"
40 #include "varasm.h" 40 #include "varasm.h"
41 #include "read-rtl-function.h" 41 #include "read-rtl-function.h"
42 #include "selftest.h" 42 #include "selftest.h"
43 #include "selftest-rtl.h" 43 #include "selftest-rtl.h"
44 #include "regs.h"
45 #include "function-abi.h"
44 46
45 /* Forward decls. */ 47 /* Forward decls. */
46 class function_reader; 48 class function_reader;
47 class fixup; 49 class fixup;
48 50
50 and created at the end when all the blocks ought to exist. 52 and created at the end when all the blocks ought to exist.
51 This struct records an "edge-from" or "edge-to" directive seen 53 This struct records an "edge-from" or "edge-to" directive seen
52 at LOC, which will be turned into an actual CFG edge once 54 at LOC, which will be turned into an actual CFG edge once
53 the "insn-chain" is fully parsed. */ 55 the "insn-chain" is fully parsed. */
54 56
55 struct deferred_edge 57 class deferred_edge
56 { 58 {
59 public:
57 deferred_edge (file_location loc, int src_bb_idx, int dest_bb_idx, int flags) 60 deferred_edge (file_location loc, int src_bb_idx, int dest_bb_idx, int flags)
58 : m_loc (loc), m_src_bb_idx (src_bb_idx), m_dest_bb_idx (dest_bb_idx), 61 : m_loc (loc), m_src_bb_idx (src_bb_idx), m_dest_bb_idx (dest_bb_idx),
59 m_flags (flags) 62 m_flags (flags)
60 {} 63 {}
61 64
110 113
111 void add_fixup_note_insn_basic_block (file_location loc, rtx insn, 114 void add_fixup_note_insn_basic_block (file_location loc, rtx insn,
112 int operand_idx, int bb_idx); 115 int operand_idx, int bb_idx);
113 116
114 void add_fixup_source_location (file_location loc, rtx_insn *insn, 117 void add_fixup_source_location (file_location loc, rtx_insn *insn,
115 const char *filename, int lineno); 118 const char *filename, int lineno, int colno);
116 119
117 void add_fixup_expr (file_location loc, rtx x, 120 void add_fixup_expr (file_location loc, rtx x,
118 const char *desc); 121 const char *desc);
119 122
120 rtx consolidate_singletons (rtx x); 123 rtx consolidate_singletons (rtx x);
705 if (strcmp (tok, #NAME) == 0) \ 708 if (strcmp (tok, #NAME) == 0) \
706 return EDGE_##NAME; \ 709 return EDGE_##NAME; \
707 } while (0); 710 } while (0);
708 #include "cfg-flags.def" 711 #include "cfg-flags.def"
709 #undef DEF_EDGE_FLAG 712 #undef DEF_EDGE_FLAG
710 error ("unrecognized edge flag: '%s'", tok); 713 error ("unrecognized edge flag: %qs", tok);
711 return 0; 714 return 0;
712 } 715 }
713 716
714 /* Subroutine of function_reader::parse_edge. 717 /* Subroutine of function_reader::parse_edge.
715 Parse STR and convert to a flag value (or issue an error). 718 Parse STR and convert to a flag value (or issue an error).
976 for (int i = 0; i < num_values; i++) 979 for (int i = 0; i < num_values; i++)
977 { 980 {
978 if (strcmp (name.string, strings[i]) == 0) 981 if (strcmp (name.string, strings[i]) == 0)
979 return i; 982 return i;
980 } 983 }
981 error ("unrecognized enum value: '%s'", name.string); 984 error ("unrecognized enum value: %qs", name.string);
982 return 0; 985 return 0;
983 } 986 }
984 987
985 /* Parse operand IDX of X, of code 'i' or 'n' (as specified by FORMAT_CHAR). 988 /* Parse operand IDX of X, of code 'i' or 'n' (as specified by FORMAT_CHAR).
986 Special-cased handling of these, for reading function dumps. */ 989 Special-cased handling of these, for reading function dumps. */
1366 /* Placeholder hook for recording source location information seen in a dump. 1369 /* Placeholder hook for recording source location information seen in a dump.
1367 This is empty for now. */ 1370 This is empty for now. */
1368 1371
1369 void 1372 void
1370 function_reader::add_fixup_source_location (file_location, rtx_insn *, 1373 function_reader::add_fixup_source_location (file_location, rtx_insn *,
1371 const char *, int) 1374 const char *, int, int)
1372 { 1375 {
1373 } 1376 }
1374 1377
1375 /* Record that at LOC we saw textual description DESC of the MEM_EXPR or REG_EXPR 1378 /* Record that at LOC we saw textual description DESC of the MEM_EXPR or REG_EXPR
1376 of INSN, so that the fields can be fixed up in later post-processing. */ 1379 of INSN, so that the fields can be fixed up in later post-processing. */
1552 { 1555 {
1553 char *filename = read_quoted_string (); 1556 char *filename = read_quoted_string ();
1554 require_char (':'); 1557 require_char (':');
1555 struct md_name line_num; 1558 struct md_name line_num;
1556 read_name (&line_num); 1559 read_name (&line_num);
1557 add_fixup_source_location (loc, insn, filename, atoi (line_num.string)); 1560
1561 int column = 0;
1562 int ch = read_char ();
1563 if (ch == ':')
1564 {
1565 struct md_name column_num;
1566 read_name (&column_num);
1567 column = atoi (column_num.string);
1568 }
1569 else
1570 unread_char (ch);
1571 add_fixup_source_location (loc, insn, filename,
1572 atoi (line_num.string),
1573 column);
1558 } 1574 }
1559 else 1575 else
1560 unread_char (ch); 1576 unread_char (ch);
1561 } 1577 }
1562 1578
1608 1624
1609 bool 1625 bool
1610 read_rtl_function_body (const char *path) 1626 read_rtl_function_body (const char *path)
1611 { 1627 {
1612 initialize_rtl (); 1628 initialize_rtl ();
1629 crtl->abi = &default_function_abi;
1613 init_emit (); 1630 init_emit ();
1614 init_varasm_status (); 1631 init_varasm_status ();
1615 1632
1616 function_reader reader; 1633 function_reader reader;
1617 if (!reader.read_file (path)) 1634 if (!reader.read_file (path))
1641 "start of RTL fragment must be on an earlier line than end"); 1658 "start of RTL fragment must be on an earlier line than end");
1642 return false; 1659 return false;
1643 } 1660 }
1644 1661
1645 initialize_rtl (); 1662 initialize_rtl ();
1663 crtl->abi = &fndecl_abi (cfun->decl).base_abi ();
1646 init_emit (); 1664 init_emit ();
1647 init_varasm_status (); 1665 init_varasm_status ();
1648 1666
1649 function_reader reader; 1667 function_reader reader;
1650 if (!reader.read_file_fragment (exploc_start.file, exploc_start.line, 1668 if (!reader.read_file_fragment (exploc_start.file, exploc_start.line,