diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-01-24 17:07:36 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-01-24 17:07:36 +0000 |
commit | c2e843276310bfa2eb0fa40c6b54f530ac207a4f (patch) | |
tree | 3de19fa9c6316e31a6092997031d1600b7d4bfcc /gcc/read-rtl-function.c | |
parent | 82b239054da5fcae11d01a055c277258cd73f235 (diff) | |
download | gcc-c2e843276310bfa2eb0fa40c6b54f530ac207a4f.zip gcc-c2e843276310bfa2eb0fa40c6b54f530ac207a4f.tar.gz gcc-c2e843276310bfa2eb0fa40c6b54f530ac207a4f.tar.bz2 |
Add "__RTL" to cc1
gcc/c-family/ChangeLog:
* c-common.c (c_common_reswords): Add "__RTL".
* c-common.h (enum rid): Add RID_RTL.
gcc/c/ChangeLog:
* c-parser.c: Include "read-rtl-function.h" and
"run-rtl-passes.h".
(c_parser_declaration_or_fndef): Rename "gimple-pass-list" in
grammar to gimple-or-rtl-pass-list. Add rtl-function-definition
production. Update for renaming of field "gimple_pass" to
"gimple_or_rtl_pass". If __RTL was seen, call
c_parser_parse_rtl_body. Convert a timevar_push/pop pair
to an auto_timevar, to cope with early exit.
(c_parser_declspecs): Update RID_GIMPLE handling for renaming of
field "gimple_pass" to "gimple_or_rtl_pass", and for renaming of
c_parser_gimple_pass_list to c_parser_gimple_or_rtl_pass_list.
Handle RID_RTL.
(c_parser_parse_rtl_body): New function.
* c-tree.h (enum c_declspec_word): Add cdw_rtl.
(struct c_declspecs): Rename field "gimple_pass" to
"gimple_or_rtl_pass". Add field "rtl_p".
* gimple-parser.c (c_parser_gimple_pass_list): Rename to...
(c_parser_gimple_or_rtl_pass_list): ...this, updating accordingly.
* gimple-parser.h (c_parser_gimple_pass_list): Rename to...
(c_parser_gimple_or_rtl_pass_list): ...this.
gcc/ChangeLog:
* cfg.c (original_copy_tables_initialized_p): New function.
* cfg.h (original_copy_tables_initialized_p): New decl.
* cfgrtl.c (relink_block_chain): Guard the call to
free_original_copy_tables with a call to
original_copy_tables_initialized_p.
* cgraph.h (symtab_node::native_rtl_p): New decl.
* cgraphunit.c (symtab_node::native_rtl_p): New function.
(symtab_node::needed_p): Don't assert for early assembly output
for __RTL functions.
(cgraph_node::finalize_function): Set "force_output" for __RTL
functions.
(cgraph_node::analyze): Bail out early for __RTL functions.
(analyze_functions): Update assertion to support __RTL functions.
(cgraph_node::expand): Bail out early for __RTL functions.
* final.c (rest_of_clean_state): Don't call delete_tree_ssa for
__RTL functions.
* function.h (struct function): Update comment for field
"pass_startwith".
* gimple-expr.c: Include "tree-pass.h".
(gimple_has_body_p): Return false for __RTL functions.
* Makefile.in (OBJS): Add run-rtl-passes.o.
* pass_manager.h (gcc::pass_manager::get_rest_of_compilation): New
accessor.
(gcc::pass_manager::get_clean_slate): New accessor.
* passes.c: Include "insn-addr.h".
(should_skip_pass_p): Add logging. Update logic for running
"expand" to be compatible with both __GIMPLE and __RTL. Guard
property-provider override so it is only done for gimple passes.
Don't skip dfinit.
(skip_pass): New function.
(execute_one_pass): Call skip_pass when skipping passes.
* read-md.c (md_reader::read_char): Support filtering
the input to a subset of line numbers.
(md_reader::md_reader): Initialize fields
m_first_line and m_last_line.
(md_reader::read_file_fragment): New function.
* read-md.h (md_reader::read_file_fragment): New decl.
(md_reader::m_first_line): New field.
(md_reader::m_last_line): New field.
* read-rtl-function.c (function_reader::create_function): Only
create cfun if it doesn't already exist. Set PROP_rtl on cfun's
curr_properties. Set DECL_INITIAL to a dummy block.
(read_rtl_function_body_from_file_range): New function.
* read-rtl-function.h (read_rtl_function_body_from_file_range):
New decl.
* run-rtl-passes.c: New file.
* run-rtl-passes.h: New file.
gcc/testsuite/ChangeLog:
* gcc.dg/rtl/aarch64/asr_div1.c: New test case.
* gcc.dg/rtl/aarch64/pr71779.c: New test case.
* gcc.dg/rtl/rtl.exp: New file.
* gcc.dg/rtl/test.c: New file.
* gcc.dg/rtl/truncated-rtl-file.c: New test case.
* gcc.dg/rtl/unknown-rtx-code.c: New test case.
* gcc.dg/rtl/x86_64/dfinit.c: New test case.
* gcc.dg/rtl/x86_64/different-structs.c: New test case.
* gcc.dg/rtl/x86_64/final.c: New test case.
* gcc.dg/rtl/x86_64/into-cfglayout.c: New test case.
* gcc.dg/rtl/x86_64/ira.c: New test case.
* gcc.dg/rtl/x86_64/pro_and_epilogue.c: New test case.
* gcc.dg/rtl/x86_64/test-multiple-fns.c: New test case.
* gcc.dg/rtl/x86_64/test-return-const.c.after-expand.c: New test case.
* gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c: New test case.
* gcc.dg/rtl/x86_64/test-rtl.c: New test case.
* gcc.dg/rtl/x86_64/test_1.h: New file.
* gcc.dg/rtl/x86_64/times-two.c.after-expand.c: New test case.
* gcc.dg/rtl/x86_64/times-two.c.before-df.c: New test case.
* gcc.dg/rtl/x86_64/times-two.h: New file.
* gcc.dg/rtl/x86_64/vregs.c: New test case.
From-SVN: r244878
Diffstat (limited to 'gcc/read-rtl-function.c')
-rw-r--r-- | gcc/read-rtl-function.c | 81 |
1 files changed, 65 insertions, 16 deletions
diff --git a/gcc/read-rtl-function.c b/gcc/read-rtl-function.c index 9ef9610..bead858 100644 --- a/gcc/read-rtl-function.c +++ b/gcc/read-rtl-function.c @@ -475,22 +475,37 @@ function_reader::create_function () /* We start in cfgrtl mode, rather than cfglayout mode. */ rtl_register_cfg_hooks (); - /* Create cfun. */ - tree fn_name = get_identifier (m_name ? m_name : "test_1"); - tree int_type = integer_type_node; - tree return_type = int_type; - tree arg_types[3] = {int_type, int_type, int_type}; - tree fn_type = build_function_type_array (return_type, 3, arg_types); - tree fndecl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn_name, fn_type); - tree resdecl = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, - return_type); - DECL_ARTIFICIAL (resdecl) = 1; - DECL_IGNORED_P (resdecl) = 1; - DECL_RESULT (fndecl) = resdecl; - allocate_struct_function (fndecl, false); - /* This sets cfun. */ - - current_function_decl = fndecl; + /* When run from selftests or "rtl1", cfun is NULL. + When run from "cc1" for a C function tagged with __RTL, cfun is the + tagged function. */ + if (!cfun) + { + tree fn_name = get_identifier (m_name ? m_name : "test_1"); + tree int_type = integer_type_node; + tree return_type = int_type; + tree arg_types[3] = {int_type, int_type, int_type}; + tree fn_type = build_function_type_array (return_type, 3, arg_types); + tree fndecl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn_name, fn_type); + tree resdecl = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, + return_type); + DECL_ARTIFICIAL (resdecl) = 1; + DECL_IGNORED_P (resdecl) = 1; + DECL_RESULT (fndecl) = resdecl; + allocate_struct_function (fndecl, false); + /* This sets cfun. */ + current_function_decl = fndecl; + } + + gcc_assert (cfun); + gcc_assert (current_function_decl); + tree fndecl = current_function_decl; + + /* Mark this function as being specified as __RTL. */ + cfun->curr_properties |= PROP_rtl; + + /* cc1 normally inits DECL_INITIAL (fndecl) to be error_mark_node. + Create a dummy block for it. */ + DECL_INITIAL (fndecl) = make_node (BLOCK); cfun->curr_properties = (PROP_cfg | PROP_rtl); @@ -1582,6 +1597,40 @@ read_rtl_function_body (const char *path) return true; } +/* Run the RTL dump parser on the range of lines between START_LOC and + END_LOC (including those lines). */ + +bool +read_rtl_function_body_from_file_range (location_t start_loc, + location_t end_loc) +{ + expanded_location exploc_start = expand_location (start_loc); + expanded_location exploc_end = expand_location (end_loc); + + if (exploc_start.file != exploc_end.file) + { + error_at (end_loc, "start/end of RTL fragment are in different files"); + return false; + } + if (exploc_start.line >= exploc_end.line) + { + error_at (end_loc, + "start of RTL fragment must be on an earlier line than end"); + return false; + } + + initialize_rtl (); + init_emit (); + init_varasm_status (); + + function_reader reader; + if (!reader.read_file_fragment (exploc_start.file, exploc_start.line, + exploc_end.line - 1)) + return false; + + return true; +} + #if CHECKING_P namespace selftest { |