2005-05-13 Josh Conner <jconner@apple.com>
[official-gcc.git] / gcc / config / sh / predicates.md
blob981cc8f10f5118ab8cc76947c1f6413c8b30d18a
1 (define_predicate "trapping_target_operand"
2   (match_code "if_then_else")
4   rtx cond, mem, res, tar, and;
6   if (GET_MODE (op) != PDImode)
7     return 0;
8   cond = XEXP (op, 0);
9   mem = XEXP (op, 1);
10   res = XEXP (op, 2);
11   if (GET_CODE (mem) != MEM
12       || (GET_CODE (res) != SIGN_EXTEND && GET_CODE (res) != TRUNCATE))
13     return 0;
14   tar = XEXP (res, 0);
15   if (!rtx_equal_p (XEXP (mem, 0), tar)
16       || GET_MODE (tar) != Pmode)
17     return 0;
18   if (GET_CODE (cond) == CONST)
19     {
20       cond = XEXP (cond, 0);
21       if (!EXTRA_CONSTRAINT_Csy (tar))
22         return 0;
23       if (GET_CODE (tar) == CONST)
24         tar = XEXP (tar, 0);
25     }
26   else if (!arith_reg_operand (tar, VOIDmode)
27            && ! EXTRA_CONSTRAINT_Csy (tar))
28     return 0;
29   if (GET_CODE (cond) != EQ)
30     return 0;
31   and = XEXP (cond, 0);
32   return (GET_CODE (and) == AND
33           && rtx_equal_p (XEXP (and, 0), tar)
34           && GET_CODE (XEXP (and, 1)) == CONST_INT
35           && GET_CODE (XEXP (cond, 1)) == CONST_INT
36           && INTVAL (XEXP (and, 1)) == 3
37           && INTVAL (XEXP (cond, 1)) == 3);