PR/56490
[official-gcc.git] / gcc / config / picochip / predicates.md
blob8e713af6a57c9f949c7adef48cfc0f8d02c3c693
1 ;; GCC machine description for picochip
2 ;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 ;; Contributed by Picochip Ltd (http://www.picochip.com)
4 ;; Maintained by Daniel Towner (dant@picochip.com) and Hariharan
5 ;; Sandanagobalane (hariharan@picochip.com)
6 ;;
7 ;; This file is part of GCC.
8 ;;
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; any later version.
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3.  If not, see
21 ;; <http://www.gnu.org/licenses/>.
23 (define_predicate "picochip_register_or_immediate_operand"
24   (ior (match_operand 0 "register_operand")
25        (match_operand 0 "immediate_operand")))
27 (define_predicate "power_of_2_imm_operand"
28   (match_code "const_int")
30   if (GET_CODE (op) == CONST_INT)
31     {
32       if (exact_log2 (INTVAL (op)) <= 16 && exact_log2 (INTVAL (op)) > 0)
33         return 1;
34     }
36   return 0;
39 ;; Limit the comparison operators to a selected subset.
40 (define_predicate "picochip_supported_comparison_operator"
41   (and (match_operand 0 "comparison_operator")
42        (match_code "ne,eq,ge,geu,lt,ltu")))
43 (define_predicate "picochip_peephole_comparison_operator"
44   (and (match_operand 0 "comparison_operator")
45        (match_code "ne,eq")))
47 ;; Allow selected arithmetic operators to apply a shift to their first
48 ;; operands
50 (define_predicate "picochip_first_op_shift_operator"
51   (match_code "and,plus,minus,ior,xor"))
53 ;; The same as the previous predicate, but only allowing those
54 ;; operators which can accept an immediate.
55 (define_predicate "picochip_first_op_shift_operator_imm"
56   (match_code "plus,minus"))
58 ;; Predicate on a J type integer.
59 (define_predicate "picochip_J_operand"
60   (match_operand 0 "immediate_operand")
61   {
62     return (CONST_INT == GET_CODE(op) &&
63             picochip_const_ok_for_letter_p (INTVAL(op), 'J'));
64   })
66 ;; Is the operand suitable for use in a compare?
68 (define_predicate "picochip_comparison_operand"
69   (ior (match_operand 0 "register_operand")
70        (and (match_operand 0 "immediate_operand")
71             (match_test "picochip_const_ok_for_letter_p(INTVAL(op), 'O')"))))