From 2cc4ea95c06a76614a9b89506d2d03fe2b7b9d6a Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 27 May 2016 14:58:30 -0400 Subject: [PATCH 30/35] FIXME: WIP on auto-inc-dec.c selftest --- gcc/auto-inc-dec.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index bf4959b..849a379 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "dbgcnt.h" #include "print-rtl.h" +#include "selftest.h" /* This pass was originally removed from flow.c. However there is almost nothing that remains of that code. @@ -1502,3 +1503,60 @@ make_pass_inc_dec (gcc::context *ctxt) { return new pass_inc_dec (ctxt); } + +#if CHECKING_P + +namespace { + +class auto_inc_dec_test : public ::selftest::test +{ + protected: +}; + +TEST_F (auto_inc_dec_test, parse_add_or_inc) +{ + rtx_insn *jump_insn = emit_jump_insn + (gen_rtx_SET (pc_rtx, + gen_rtx_LABEL_REF (VOIDmode, + gen_label_rtx ()))); + EXPECT_FALSE (parse_add_or_inc (jump_insn, false)); + + rtx_insn *set_from_sp = emit_insn + (gen_rtx_SET (gen_rtx_REG (Pmode, FIRST_PSEUDO_REGISTER), + stack_pointer_rtx)); + EXPECT_FALSE (parse_add_or_inc (set_from_sp, false)); + +#if 0 + rtx_insn *set_from_sp = emit_insn + (gen_rtx_SET (gen_rtx_REG (Dmode, 101), + gen_rtx_PLUS (Dmode, 101),)); +#endif + +#if 0 + rtx_insn *insn = parse_insn ("(insn 32 31 34 6 (parallel [" + " (set (reg:DI 101 [ ivtmp.7 ])" + " (plus:DI (reg:DI 101 [ ivtmp.7 ])" + " (const_int 1 [0x1])))" + " (clobber (reg:CC 17 flags))" + " ]) -1" + " (nil))"); + EXPECT_TRUE (parse_add_or_inc (set_from_sp, false)); + + // FIXME: there's another parse_add_or_inc in sched-deps.c; it's + // that one that got called for this: + rtx_insn *insn = parse_insn + ("(insn 102 101 103 15 (parallel [\n" + " (set (reg:DI 37 r8 [orig:132 ivtmp.21 ] [132])\n" + " (plus:DI (reg:DI 37 r8 [orig:132 ivtmp.21 ] [132])\n" + " (const_int 16 [0x10])))\n" + " (clobber (reg:CC 17 flags))\n" + " ]) -1\n" + " (expr_list:REG_UNUSED (reg:CC 17 flags)\n" + " (nil)))\n"); + EXPECT_TRUE (parse_add_or_inc (insn, false)); +#endif +} + +} /* anon namespace. */ + +#endif /* #if CHECKING_P */ -- 1.8.5.3