[AArch64] Use new target pass registration framework for FMA steering pass
[official-gcc.git] / gcc / rtl-tests.c
blob723efa5a0f61fc5fa3c589e32e639cd4e412db10
1 /* Unit tests for RTL-handling.
2 Copyright (C) 2015-2016 Free Software Foundation, Inc.
4 This file is part of GCC.
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
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "opts.h"
25 #include "signop.h"
26 #include "hash-set.h"
27 #include "fixed-value.h"
28 #include "alias.h"
29 #include "flags.h"
30 #include "symtab.h"
31 #include "tree-core.h"
32 #include "stor-layout.h"
33 #include "tree.h"
34 #include "stringpool.h"
35 #include "stor-layout.h"
36 #include "rtl.h"
37 #include "pretty-print.h"
38 #include "cfgbuild.h"
39 #include "print-rtl.h"
40 #include "selftest.h"
41 #include "function.h"
42 #include "memmodel.h"
43 #include "emit-rtl.h"
45 #if CHECKING_P
47 namespace selftest {
49 /* Verify that PAT is printed as EXPECTED. Helper function for
50 selftests. */
52 static void
53 verify_print_pattern (const char *expected, rtx pat)
55 pretty_printer pp;
56 print_pattern (&pp, pat, 1);
57 ASSERT_STREQ (expected, pp_formatted_text (&pp));
60 /* Unit testing of "single_set". */
62 static void
63 test_single_set ()
65 /* A label is not a SET. */
66 ASSERT_EQ (NULL_RTX, single_set (gen_label_rtx ()));
68 /* An unconditional jump insn is a single SET. */
69 rtx set_pc = gen_rtx_SET (pc_rtx,
70 gen_rtx_LABEL_REF (VOIDmode,
71 gen_label_rtx ()));
72 rtx_insn *jump_insn = emit_jump_insn (set_pc);
73 ASSERT_EQ (set_pc, single_set (jump_insn));
75 /* etc */
78 /* Construct an unconditional jump to a label, and verify that
79 various properties of it are sane. */
81 static void
82 test_uncond_jump ()
84 rtx_insn *label = gen_label_rtx ();
85 rtx jump_pat = gen_rtx_SET (pc_rtx,
86 gen_rtx_LABEL_REF (VOIDmode,
87 label));
88 ASSERT_EQ (SET, jump_pat->code);
89 ASSERT_EQ (LABEL_REF, SET_SRC (jump_pat)->code);
90 ASSERT_EQ (label, LABEL_REF_LABEL (SET_SRC (jump_pat)));
91 ASSERT_EQ (PC, SET_DEST (jump_pat)->code);
93 verify_print_pattern ("pc=L0", jump_pat);
95 rtx_insn *jump_insn = emit_jump_insn (jump_pat);
96 ASSERT_FALSE (any_condjump_p (jump_insn));
97 ASSERT_TRUE (any_uncondjump_p (jump_insn));
98 ASSERT_TRUE (pc_set (jump_insn));
99 ASSERT_TRUE (simplejump_p (jump_insn));
100 ASSERT_TRUE (onlyjump_p (jump_insn));
101 ASSERT_TRUE (control_flow_insn_p (jump_insn));
104 /* Run all of the selftests within this file. */
106 void
107 rtl_tests_c_tests ()
109 test_single_set ();
110 test_uncond_jump ();
112 /* Purge state. */
113 set_first_insn (NULL);
114 set_last_insn (NULL);
117 } // namespace selftest
118 #endif /* #if CHECKING_P */