@@ -36,6 +36,29 @@ along with GCC; see the file COPYING3. If not see
namespace selftest {
+/* Compare rtx EXPECTED and ACTUAL by pointer equality, calling
+ ::selftest::pass if they are equal, aborting if they are non-equal.
+ LOC is the effective location of the assertion, MSG describes it. */
+
+void
+assert_rtx_ptr_eq_at (const location &loc, const char *msg,
+ rtx expected, rtx actual)
+{
+ if (expected == actual)
+ ::selftest::pass (loc, msg);
+ else
+ {
+ fprintf (stderr, "%s:%i: %s: FAIL: %s\n", loc.m_file, loc.m_line,
+ loc.m_function, msg);
+ fprintf (stderr, " expected (at %p): ", (void *)expected);
+ print_rtl (stderr, expected);
+ fprintf (stderr, "\n actual (at %p): ", (void *)actual);
+ print_rtl (stderr, actual);
+ fprintf (stderr, "\n");
+ abort ();
+ }
+}
+
/* Constructor for selftest::rtl_dump_test.
Read a dumped RTL function from PATH.
Takes ownership of PATH, freeing in dtor.
@@ -47,6 +47,24 @@ assert_rtl_dump_eq (const location &loc, const char *expected_dump, rtx x,
assert_rtl_dump_eq (SELFTEST_LOCATION, (EXPECTED_DUMP), (RTX), \
(REUSE_MANAGER))
+/* Evaluate rtx EXPECTED and ACTUAL and compare them with ==
+ (i.e. pointer equality), calling ::selftest::pass if they are
+ equal, aborting if they are non-equal. */
+
+#define ASSERT_RTX_PTR_EQ(EXPECTED, ACTUAL) \
+ SELFTEST_BEGIN_STMT \
+ const char *desc = "ASSERT_RTX_PTR_EQ (" #EXPECTED ", " #ACTUAL ")"; \
+ ::selftest::assert_rtx_ptr_eq_at (SELFTEST_LOCATION, desc, (EXPECTED), \
+ (ACTUAL)); \
+ SELFTEST_END_STMT
+
+/* Compare rtx EXPECTED and ACTUAL by pointer equality, calling
+ ::selftest::pass if they are equal, aborting if they are non-equal.
+ LOC is the effective location of the assertion, MSG describes it. */
+
+extern void assert_rtx_ptr_eq_at (const location &loc, const char *msg,
+ rtx expected, rtx actual);
+
/* A class for testing RTL function dumps. */
class rtl_dump_test