2016-06-06 19:11:30 +02:00
|
|
|
/* Unit tests for RTL-handling.
|
2017-01-01 13:07:43 +01:00
|
|
|
Copyright (C) 2015-2017 Free Software Foundation, Inc.
|
2016-06-06 19:11:30 +02:00
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "opts.h"
|
|
|
|
#include "signop.h"
|
|
|
|
#include "hash-set.h"
|
|
|
|
#include "fixed-value.h"
|
|
|
|
#include "alias.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "tree-core.h"
|
|
|
|
#include "stor-layout.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "stringpool.h"
|
|
|
|
#include "stor-layout.h"
|
|
|
|
#include "rtl.h"
|
|
|
|
#include "pretty-print.h"
|
|
|
|
#include "cfgbuild.h"
|
|
|
|
#include "print-rtl.h"
|
|
|
|
#include "selftest.h"
|
2016-11-04 18:05:38 +01:00
|
|
|
#include "selftest-rtl.h"
|
2016-06-06 19:11:30 +02:00
|
|
|
#include "function.h"
|
Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
into ...
* memmodel.h: This file.
* alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
compare-elim.c, config/aarch64/aarch64-builtins.c,
config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/epiphany/epiphany.c,
config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c,
config/microblaze/microblaze.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c,
config/msp430/msp430.c, config/nds32/nds32-cost.c,
config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
config/nds32/nds32-memory-manipulation.c,
config/nds32/nds32-predicates.c, config/nds32/nds32.c,
config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
var-tracking.c, varasm.c: Include memmodel.h.
* genattrtab.c (write_header): Include memmodel.h in generated file.
* genautomata.c (main): Likewise.
* gengtype.c (open_base_files): Likewise.
* genopinit.c (main): Likewise.
* genconditions.c (write_header): Include memmodel.h earlier in
generated file.
* genemit.c (main): Likewise.
* genoutput.c (output_prologue): Likewise.
* genpeep.c (main): Likewise.
* genpreds.c (write_insn_preds_c): Likewise.
* genrecog.c (write_header): Likewise.
* Makefile.in (PLUGIN_HEADERS): Include memmodel.h
gcc/ada/
* gcc-interface/utils2.c: Include memmodel.h.
gcc/c-family/
* c-cppbuiltin.c: Include memmodel.h.
* c-opts.c: Likewise.
* c-pragma.c: Likewise.
* c-warn.c: Likewise.
gcc/c/
* c-typeck.c: Include memmodel.h.
gcc/cp/
* decl2.c: Include memmodel.h.
* rtti.c: Likewise.
gcc/fortran/
* trans-intrinsic.c: Include memmodel.h.
gcc/go/
* go-backend.c: Include memmodel.h.
libgcc/
* libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
equivalent.
* config/tilepro/atomic.c: Likewise and stop casting model to
enum memmodel.
From-SVN: r241121
2016-10-13 16:17:52 +02:00
|
|
|
#include "memmodel.h"
|
2016-06-06 19:11:30 +02:00
|
|
|
#include "emit-rtl.h"
|
|
|
|
|
|
|
|
#if CHECKING_P
|
|
|
|
|
|
|
|
namespace selftest {
|
|
|
|
|
|
|
|
/* Verify that PAT is printed as EXPECTED. Helper function for
|
|
|
|
selftests. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
verify_print_pattern (const char *expected, rtx pat)
|
|
|
|
{
|
|
|
|
pretty_printer pp;
|
|
|
|
print_pattern (&pp, pat, 1);
|
|
|
|
ASSERT_STREQ (expected, pp_formatted_text (&pp));
|
|
|
|
}
|
|
|
|
|
2016-10-21 15:52:53 +02:00
|
|
|
/* Verify that X is dumped as EXPECTED_DUMP, using compact mode.
|
|
|
|
Use LOC as the effective location when reporting errors. */
|
|
|
|
|
2016-11-04 18:05:38 +01:00
|
|
|
void
|
2016-12-06 22:03:33 +01:00
|
|
|
assert_rtl_dump_eq (const location &loc, const char *expected_dump, rtx x,
|
|
|
|
rtx_reuse_manager *reuse_manager)
|
2016-10-21 15:52:53 +02:00
|
|
|
{
|
|
|
|
named_temp_file tmp_out (".rtl");
|
|
|
|
FILE *outfile = fopen (tmp_out.get_filename (), "w");
|
2016-12-06 22:03:33 +01:00
|
|
|
rtx_writer w (outfile, 0, false, true, reuse_manager);
|
2016-10-26 18:51:53 +02:00
|
|
|
w.print_rtl (x);
|
2016-10-21 15:52:53 +02:00
|
|
|
fclose (outfile);
|
|
|
|
|
|
|
|
char *dump = read_file (SELFTEST_LOCATION, tmp_out.get_filename ());
|
|
|
|
ASSERT_STREQ_AT (loc, expected_dump, dump);
|
|
|
|
free (dump);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify that regs are dumped as expected (in compact mode). */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dumping_regs ()
|
|
|
|
{
|
|
|
|
/* Dumps of hard regs contain a target-specific name, so we don't test
|
2016-11-04 18:05:38 +01:00
|
|
|
it here; this can be tested in target-specific selftests. */
|
2016-10-21 15:52:53 +02:00
|
|
|
|
|
|
|
/* Test dumping of virtual regs. The various virtual regs are inited as
|
|
|
|
Pmode, so this is target-specific. The tests below assume DImode, so
|
|
|
|
only run the tests for targets where Pmode is DImode. */
|
|
|
|
if (Pmode == DImode)
|
|
|
|
{
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-incoming-args)",
|
|
|
|
virtual_incoming_args_rtx);
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-stack-vars)",
|
|
|
|
virtual_stack_vars_rtx);
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-stack-dynamic)",
|
|
|
|
virtual_stack_dynamic_rtx);
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-outgoing-args)",
|
|
|
|
virtual_outgoing_args_rtx);
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-cfa)",
|
|
|
|
virtual_cfa_rtx);
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:DI virtual-preferred-stack-boundary)",
|
|
|
|
virtual_preferred_stack_boundary_rtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test dumping of non-virtual pseudos. */
|
2016-12-19 16:24:47 +01:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:SI <0>)",
|
2016-10-21 15:52:53 +02:00
|
|
|
gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 1));
|
2016-12-19 16:24:47 +01:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(reg:SI <1>)",
|
2016-10-21 15:52:53 +02:00
|
|
|
gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify that insns are dumped as expected (in compact mode). */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dumping_insns ()
|
|
|
|
{
|
|
|
|
/* Barriers. */
|
|
|
|
rtx_barrier *barrier = as_a <rtx_barrier *> (rtx_alloc (BARRIER));
|
|
|
|
SET_NEXT_INSN (barrier) = NULL;
|
2016-10-26 20:25:14 +02:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(cbarrier 0)\n", barrier);
|
2016-10-21 15:52:53 +02:00
|
|
|
|
|
|
|
/* Labels. */
|
|
|
|
rtx_insn *label = gen_label_rtx ();
|
|
|
|
CODE_LABEL_NUMBER (label) = 42;
|
2016-11-07 16:19:17 +01:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(clabel 0 42)\n", label);
|
2016-10-21 15:52:53 +02:00
|
|
|
|
|
|
|
LABEL_NAME (label)= "some_label";
|
|
|
|
ASSERT_RTL_DUMP_EQ ("(clabel 0 42 (\"some_label\"))\n", label);
|
|
|
|
}
|
|
|
|
|
2016-12-06 22:03:33 +01:00
|
|
|
/* Manually exercise the rtx_reuse_manager code. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dumping_rtx_reuse ()
|
|
|
|
{
|
|
|
|
rtx_reuse_manager r;
|
|
|
|
|
|
|
|
rtx x = rtx_alloc (SCRATCH);
|
|
|
|
rtx y = rtx_alloc (SCRATCH);
|
|
|
|
rtx z = rtx_alloc (SCRATCH);
|
|
|
|
|
|
|
|
/* x and y will be seen more than once. */
|
|
|
|
r.preprocess (x);
|
|
|
|
r.preprocess (x);
|
|
|
|
r.preprocess (y);
|
|
|
|
r.preprocess (y);
|
|
|
|
|
|
|
|
/* z will be only seen once. */
|
|
|
|
r.preprocess (z);
|
|
|
|
|
|
|
|
/* Verify that x and y have been assigned reuse IDs. */
|
|
|
|
int reuse_id_for_x;
|
|
|
|
ASSERT_TRUE (r.has_reuse_id (x, &reuse_id_for_x));
|
|
|
|
ASSERT_EQ (0, reuse_id_for_x);
|
|
|
|
|
|
|
|
int reuse_id_for_y;
|
|
|
|
ASSERT_TRUE (r.has_reuse_id (y, &reuse_id_for_y));
|
|
|
|
ASSERT_EQ (1, reuse_id_for_y);
|
|
|
|
|
|
|
|
/* z is only seen once and thus shouldn't get a reuse ID. */
|
|
|
|
ASSERT_FALSE (r.has_reuse_id (z, NULL));
|
|
|
|
|
|
|
|
/* The first dumps of x and y should be prefixed by reuse ID;
|
|
|
|
all subsequent dumps of them should show up as "reuse_rtx". */
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(0|scratch)", x, &r);
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(reuse_rtx 0)", x, &r);
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(reuse_rtx 0)", x, &r);
|
|
|
|
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(1|scratch)", y, &r);
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(reuse_rtx 1)", y, &r);
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(reuse_rtx 1)", y, &r);
|
|
|
|
|
|
|
|
/* z only appears once and thus shouldn't be prefixed with a
|
|
|
|
reuse ID. */
|
|
|
|
ASSERT_RTL_DUMP_EQ_WITH_REUSE ("(scratch)", z, &r);
|
|
|
|
}
|
|
|
|
|
2016-06-06 19:11:30 +02:00
|
|
|
/* Unit testing of "single_set". */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_single_set ()
|
|
|
|
{
|
|
|
|
/* A label is not a SET. */
|
|
|
|
ASSERT_EQ (NULL_RTX, single_set (gen_label_rtx ()));
|
|
|
|
|
|
|
|
/* An unconditional jump insn is a single SET. */
|
|
|
|
rtx set_pc = gen_rtx_SET (pc_rtx,
|
|
|
|
gen_rtx_LABEL_REF (VOIDmode,
|
|
|
|
gen_label_rtx ()));
|
|
|
|
rtx_insn *jump_insn = emit_jump_insn (set_pc);
|
|
|
|
ASSERT_EQ (set_pc, single_set (jump_insn));
|
|
|
|
|
|
|
|
/* etc */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct an unconditional jump to a label, and verify that
|
|
|
|
various properties of it are sane. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_uncond_jump ()
|
|
|
|
{
|
Introduce RTL function reader
This is the combination of these patches:
- [8a/9] Introduce class function_reader (v8)
- Add ASSERT_RTX_PTR_EQ
- [8b/9] Add target-independent selftests of RTL function reader (v2)
- [8c/9] Add aarch64-specific selftests for RTL function reader (v2)
- [8d/9] Add x86_64-specific selftests for RTL function reader (v2)
gcc/ChangeLog:
* Makefile.in (OBJS): Add read-md.o, read-rtl.o,
read-rtl-function.o, and selftest-rtl.o.
* config/aarch64/aarch64.c: Include selftest.h and
selftest-rtl.h.
(selftest::aarch64_test_loading_full_dump): New function.
(selftest::aarch64_run_selftests): New function.
(TARGET_RUN_TARGET_SELFTESTS): Wire it up to
selftest::aarch64_run_selftests.
* config/i386/i386.c
(selftest::ix86_test_loading_dump_fragment_1): New function.
(selftest::ix86_test_loading_call_insn): New function.
(selftest::ix86_test_loading_full_dump): New function.
(selftest::ix86_test_loading_unspec): New function.
(selftest::ix86_run_selftests): Call the new functions.
* emit-rtl.c (maybe_set_max_label_num): New function.
* emit-rtl.h (maybe_set_max_label_num): New decl.
* function.c (instantiate_decls): Guard call to
instantiate_decls_1 with if (DECL_INITIAL (fndecl)).
* function-tests.c (selftest::verify_three_block_rtl_cfg): Remove
"static".
* gensupport.c (gen_reader::gen_reader): Pass "false"
for new "compact" param of rtx_reader.
* print-rtl.c (rtx_writer::print_rtx_operand): Print "(nil)"
rather than an empty string for NULL strings.
* read-md.c: Potentially include config.h rather than bconfig.h.
Wrap include of errors.h with #ifdef GENERATOR_FILE.
(have_error): New global, copied from errors.c.
(md_reader::read_name): Rename to...
(md_reader::read_name_1): ...this, adding "out_loc" param,
and converting "missing name or number" to returning false, rather
than failing.
(md_reader::read_name): Reimplement in terms of read_name_1.
(md_reader::read_name_or_nil): New function.
(md_reader::read_string): Handle "(nil)" by returning NULL.
(md_reader::md_reader): Add new param "compact".
(md_reader::read_md_files): Wrap with #ifdef GENERATOR_FILE.
(md_reader::read_file): New method.
* read-md.h (md_reader::md_reader): Add new param "compact".
(md_reader::read_file): New method.
(md_reader::is_compact): New accessor.
(md_reader::read_name): Convert return type from void to
file_location.
(md_reader::read_name_or_nil): New decl.
(md_reader::read_name_1): New decl.
(md_reader::m_compact): New field.
(noop_reader::noop_reader): Pass "false" for new "compact" param
of rtx_reader.
(rtx_reader::rtx_reader): Add new "compact" param.
(rtx_reader::read_rtx_operand): Make virtual and convert return
type from void to rtx.
(rtx_reader::read_until): New decl.
(rtx_reader::handle_any_trailing_information): New virtual
function.
(rtx_reader::postprocess): New virtual function.
(rtx_reader::finalize_string): New virtual function.
(rtx_reader::m_in_call_function_usage): New field.
(rtx_reader::m_reuse_rtx_by_id): New field.
* read-rtl-function.c: New file.
* selftest-rtl.c (selftest::assert_rtx_ptr_eq_at): New function.
* selftest-rtl.h (ASSERT_RTX_PTR_EQ): New macro.
(selftest::verify_three_block_rtl_cfg): New decl.
* read-rtl-function.h: New file.
* read-rtl.c: Potentially include config.h rather than bconfig.h.
For host, include function.h, memmodel.h, and emit-rtl.h.
(one_time_initialization): New function.
(struct compact_insn_name): New struct.
(compact_insn_names): New array.
(find_code): Handle insn codes in compact dumps.
(apply_subst_iterator): Wrap with #ifdef GENERATOR_FILE.
(bind_subst_iter_and_attr): Likewise.
(add_condition_to_string): Likewise.
(add_condition_to_rtx): Likewise.
(apply_attribute_uses): Likewise.
(add_current_iterators): Likewise.
(apply_iterators): Likewise.
(initialize_iterators): Guard usage of apply_subst_iterator with
#ifdef GENERATOR_FILE.
(read_conditions): Wrap with #ifdef GENERATOR_FILE.
(md_reader::read_mapping): Likewise.
(add_define_attr_for_define_subst): Likewise.
(add_define_subst_attr): Likewise.
(read_subst_mapping): Likewise.
(check_code_iterator): Likewise.
(rtx_reader::read_rtx): Likewise. Move one-time initialization
logic to...
(one_time_initialization): New function.
(rtx_reader::read_until): New method.
(read_flags): New function.
(parse_reg_note_name): New function.
(rtx_reader::read_rtx_code): Initialize "iterator" to NULL.
Handle reuse_rtx ids.
Wrap iterator lookup within #ifdef GENERATOR_FILE.
Add parsing support for RTL dumps, mirroring the special-cases in
print_rtx, by calling read_flags, reading REG_NOTE names, INSN_UID
values, and calling handle_any_trailing_information.
(rtx_reader::read_rtx_operand): Convert return type from void
to rtx, returning return_rtx. Handle case 'e'. Call
finalize_string on XSTR and XTMPL fields.
(rtx_reader::read_nested_rtx): Handle dumps in which trailing
"(nil)" values were omitted. Call the postprocess vfunc on the
return_rtx.
(rtx_reader::rtx_reader): Add new "compact" param and pass to base
class ctor. Initialize m_in_call_function_usage. Call
one_time_initialization.
* rtl-tests.c (selftest::test_uncond_jump): Call
set_new_first_and_last_insn.
* rtl.h (read_rtx): Wrap decl with #ifdef GENERATOR_FILE.
* selftest-rtl.c: New file.
* selftest-rtl.h (class selftest::rtl_dump_test): New class.
(selftest::get_insn_by_uid): New decl.
* selftest-run-tests.c (selftest::run_tests): Call
read_rtl_function_c_tests.
* selftest.h (selftest::read_rtl_function_c_tests): New decl.
* tree-dfa.c (ssa_default_def): Return NULL_TREE for rtl function
dumps.
gcc/testsuite/ChangeLog:
* selftests/asr_div1.rtl: New file.
* selftests/aarch64: New subdirectory.
* selftests/aarch64/times-two.rtl: New file.
* selftests/bb-index.rtl: New file.
* selftests/cfg-test.rtl: New file.
* selftests/const-int.rtl: New file.
* selftests/example-labels.rtl: New file.
* selftests/insn-with-mode.rtl: New file.
* selftests/jump-to-label-ref.rtl: New file.
* selftests/jump-to-return.rtl: New file.
* selftests/jump-to-simple-return.rtl: New file.
* selftests/mem.rtl: New file.
* selftests/note-insn-deleted.rtl: New file.
* selftests/note_insn_basic_block.rtl: New file.
* selftests/simple-cse.rtl: New file.
* selftests/symbol-ref.rtl: New file.
* selftests/x86_64: New subdirectory.
* selftests/x86_64/call-insn.rtl: New file.
* selftests/x86_64/copy-hard-reg-into-frame.rtl: New file.
* selftests/x86_64/times-two.rtl: New file.
* selftests/x86_64/unspec.rtl: New file.
From-SVN: r244110
2017-01-05 20:32:09 +01:00
|
|
|
set_new_first_and_last_insn (NULL, NULL);
|
2016-06-06 19:11:30 +02:00
|
|
|
rtx_insn *label = gen_label_rtx ();
|
|
|
|
rtx jump_pat = gen_rtx_SET (pc_rtx,
|
|
|
|
gen_rtx_LABEL_REF (VOIDmode,
|
|
|
|
label));
|
|
|
|
ASSERT_EQ (SET, jump_pat->code);
|
|
|
|
ASSERT_EQ (LABEL_REF, SET_SRC (jump_pat)->code);
|
2016-10-21 14:32:56 +02:00
|
|
|
ASSERT_EQ (label, label_ref_label (SET_SRC (jump_pat)));
|
2016-06-06 19:11:30 +02:00
|
|
|
ASSERT_EQ (PC, SET_DEST (jump_pat)->code);
|
|
|
|
|
|
|
|
verify_print_pattern ("pc=L0", jump_pat);
|
|
|
|
|
2016-10-21 15:52:53 +02:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(set (pc)\n"
|
|
|
|
" (label_ref 0))",
|
|
|
|
jump_pat);
|
|
|
|
|
2016-06-06 19:11:30 +02:00
|
|
|
rtx_insn *jump_insn = emit_jump_insn (jump_pat);
|
|
|
|
ASSERT_FALSE (any_condjump_p (jump_insn));
|
|
|
|
ASSERT_TRUE (any_uncondjump_p (jump_insn));
|
|
|
|
ASSERT_TRUE (pc_set (jump_insn));
|
|
|
|
ASSERT_TRUE (simplejump_p (jump_insn));
|
|
|
|
ASSERT_TRUE (onlyjump_p (jump_insn));
|
|
|
|
ASSERT_TRUE (control_flow_insn_p (jump_insn));
|
2016-10-21 15:52:53 +02:00
|
|
|
|
2016-10-26 20:25:14 +02:00
|
|
|
ASSERT_RTL_DUMP_EQ ("(cjump_insn 1 (set (pc)\n"
|
2016-11-07 16:19:17 +01:00
|
|
|
" (label_ref 0)))\n",
|
2016-10-21 15:52:53 +02:00
|
|
|
jump_insn);
|
2016-06-06 19:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Run all of the selftests within this file. */
|
|
|
|
|
|
|
|
void
|
|
|
|
rtl_tests_c_tests ()
|
|
|
|
{
|
2016-10-21 15:52:53 +02:00
|
|
|
test_dumping_regs ();
|
|
|
|
test_dumping_insns ();
|
2016-12-06 22:03:33 +01:00
|
|
|
test_dumping_rtx_reuse ();
|
2016-06-06 19:11:30 +02:00
|
|
|
test_single_set ();
|
|
|
|
test_uncond_jump ();
|
|
|
|
|
|
|
|
/* Purge state. */
|
|
|
|
set_first_insn (NULL);
|
|
|
|
set_last_insn (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace selftest
|
|
|
|
#endif /* #if CHECKING_P */
|