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
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
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/>. */
22 #include "coretypes.h"
27 #include "fixed-value.h"
31 #include "tree-core.h"
32 #include "stor-layout.h"
34 #include "stringpool.h"
35 #include "stor-layout.h"
37 #include "pretty-print.h"
39 #include "print-rtl.h"
49 /* Verify that PAT is printed as EXPECTED. Helper function for
53 verify_print_pattern (const char *expected
, rtx pat
)
56 print_pattern (&pp
, pat
, 1);
57 ASSERT_STREQ (expected
, pp_formatted_text (&pp
));
60 /* Unit testing of "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
,
72 rtx_insn
*jump_insn
= emit_jump_insn (set_pc
);
73 ASSERT_EQ (set_pc
, single_set (jump_insn
));
78 /* Construct an unconditional jump to a label, and verify that
79 various properties of it are sane. */
84 rtx_insn
*label
= gen_label_rtx ();
85 rtx jump_pat
= gen_rtx_SET (pc_rtx
,
86 gen_rtx_LABEL_REF (VOIDmode
,
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. */
113 set_first_insn (NULL
);
114 set_last_insn (NULL
);
117 } // namespace selftest
118 #endif /* #if CHECKING_P */