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"
48 /* Verify that PAT is printed as EXPECTED. Helper function for
52 verify_print_pattern (const char *expected
, rtx pat
)
55 print_pattern (&pp
, pat
, 1);
56 ASSERT_STREQ (expected
, pp_formatted_text (&pp
));
59 /* Unit testing of "single_set". */
64 /* A label is not a SET. */
65 ASSERT_EQ (NULL_RTX
, single_set (gen_label_rtx ()));
67 /* An unconditional jump insn is a single SET. */
68 rtx set_pc
= gen_rtx_SET (pc_rtx
,
69 gen_rtx_LABEL_REF (VOIDmode
,
71 rtx_insn
*jump_insn
= emit_jump_insn (set_pc
);
72 ASSERT_EQ (set_pc
, single_set (jump_insn
));
77 /* Construct an unconditional jump to a label, and verify that
78 various properties of it are sane. */
83 rtx_insn
*label
= gen_label_rtx ();
84 rtx jump_pat
= gen_rtx_SET (pc_rtx
,
85 gen_rtx_LABEL_REF (VOIDmode
,
87 ASSERT_EQ (SET
, jump_pat
->code
);
88 ASSERT_EQ (LABEL_REF
, SET_SRC (jump_pat
)->code
);
89 ASSERT_EQ (label
, LABEL_REF_LABEL (SET_SRC (jump_pat
)));
90 ASSERT_EQ (PC
, SET_DEST (jump_pat
)->code
);
92 verify_print_pattern ("pc=L0", jump_pat
);
94 rtx_insn
*jump_insn
= emit_jump_insn (jump_pat
);
95 ASSERT_FALSE (any_condjump_p (jump_insn
));
96 ASSERT_TRUE (any_uncondjump_p (jump_insn
));
97 ASSERT_TRUE (pc_set (jump_insn
));
98 ASSERT_TRUE (simplejump_p (jump_insn
));
99 ASSERT_TRUE (onlyjump_p (jump_insn
));
100 ASSERT_TRUE (control_flow_insn_p (jump_insn
));
103 /* Run all of the selftests within this file. */
112 set_first_insn (NULL
);
113 set_last_insn (NULL
);
116 } // namespace selftest
117 #endif /* #if CHECKING_P */