annotate gcc/selftest-rtl.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* A self-testing framework, for use by -fself-test.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_SELFTEST_RTL_H
kono
parents:
diff changeset
21 #define GCC_SELFTEST_RTL_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 /* The selftest code should entirely disappear in a production
kono
parents:
diff changeset
24 configuration, hence we guard all of it with #if CHECKING_P. */
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 #if CHECKING_P
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 class rtx_reuse_manager;
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 namespace selftest {
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Verify that X is dumped as EXPECTED_DUMP, using compact mode.
kono
parents:
diff changeset
33 Use LOC as the effective location when reporting errors. */
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 extern void
kono
parents:
diff changeset
36 assert_rtl_dump_eq (const location &loc, const char *expected_dump, rtx x,
kono
parents:
diff changeset
37 rtx_reuse_manager *reuse_manager);
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* Verify that RTX is dumped as EXPECTED_DUMP, using compact mode. */
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 #define ASSERT_RTL_DUMP_EQ(EXPECTED_DUMP, RTX) \
kono
parents:
diff changeset
42 assert_rtl_dump_eq (SELFTEST_LOCATION, (EXPECTED_DUMP), (RTX), NULL)
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 /* As above, but using REUSE_MANAGER when dumping. */
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 #define ASSERT_RTL_DUMP_EQ_WITH_REUSE(EXPECTED_DUMP, RTX, REUSE_MANAGER) \
kono
parents:
diff changeset
47 assert_rtl_dump_eq (SELFTEST_LOCATION, (EXPECTED_DUMP), (RTX), \
kono
parents:
diff changeset
48 (REUSE_MANAGER))
kono
parents:
diff changeset
49
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 #define ASSERT_RTX_EQ(EXPECTED, ACTUAL) \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
51 SELFTEST_BEGIN_STMT \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
52 const char *desc_ = "ASSERT_RTX_EQ (" #EXPECTED ", " #ACTUAL ")"; \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 ::selftest::assert_rtx_eq_at (SELFTEST_LOCATION, desc_, (EXPECTED), \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
54 (ACTUAL)); \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
55 SELFTEST_END_STMT
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
56
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 extern void assert_rtx_eq_at (const location &, const char *, rtx, rtx);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58
111
kono
parents:
diff changeset
59 /* Evaluate rtx EXPECTED and ACTUAL and compare them with ==
kono
parents:
diff changeset
60 (i.e. pointer equality), calling ::selftest::pass if they are
kono
parents:
diff changeset
61 equal, aborting if they are non-equal. */
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 #define ASSERT_RTX_PTR_EQ(EXPECTED, ACTUAL) \
kono
parents:
diff changeset
64 SELFTEST_BEGIN_STMT \
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
65 const char *desc_ = "ASSERT_RTX_PTR_EQ (" #EXPECTED ", " #ACTUAL ")"; \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
66 ::selftest::assert_rtx_ptr_eq_at (SELFTEST_LOCATION, desc_, (EXPECTED), \
111
kono
parents:
diff changeset
67 (ACTUAL)); \
kono
parents:
diff changeset
68 SELFTEST_END_STMT
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* Compare rtx EXPECTED and ACTUAL by pointer equality, calling
kono
parents:
diff changeset
71 ::selftest::pass if they are equal, aborting if they are non-equal.
kono
parents:
diff changeset
72 LOC is the effective location of the assertion, MSG describes it. */
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 extern void assert_rtx_ptr_eq_at (const location &loc, const char *msg,
kono
parents:
diff changeset
75 rtx expected, rtx actual);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 /* A class for testing RTL function dumps. */
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 class rtl_dump_test
kono
parents:
diff changeset
80 {
kono
parents:
diff changeset
81 public:
kono
parents:
diff changeset
82 /* Takes ownership of PATH. */
kono
parents:
diff changeset
83 rtl_dump_test (const location &loc, char *path);
kono
parents:
diff changeset
84 ~rtl_dump_test ();
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 private:
kono
parents:
diff changeset
87 char *m_path;
kono
parents:
diff changeset
88 };
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* Get the insn with the given uid, or NULL if not found. */
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 extern rtx_insn *get_insn_by_uid (int uid);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 extern void verify_three_block_rtl_cfg (function *fun);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 } /* end of namespace selftest. */
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 #endif /* #if CHECKING_P */
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #endif /* GCC_SELFTEST_RTL_H */