]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/nios2/predicates.md
nios2.h (SMALL_INT12): New macro.
[thirdparty/gcc.git] / gcc / config / nios2 / predicates.md
1 ;; Predicate definitions for Altera Nios II.
2 ;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
3 ;; Contributed by Chung-Lin Tang <cltang@codesourcery.com>
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
10 ;; any later version.
11 ;;
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 (define_predicate "const_0_operand"
22 (and (match_code "const_int,const_double,const_vector")
23 (match_test "op == CONST0_RTX (GET_MODE (op))")))
24
25 (define_predicate "reg_or_0_operand"
26 (ior (match_operand 0 "const_0_operand")
27 (match_operand 0 "register_operand")))
28
29 (define_predicate "const_uns_arith_operand"
30 (and (match_code "const_int")
31 (match_test "SMALL_INT_UNSIGNED (INTVAL (op))")))
32
33 (define_predicate "uns_arith_operand"
34 (ior (match_operand 0 "const_uns_arith_operand")
35 (match_operand 0 "register_operand")))
36
37 (define_predicate "const_arith_operand"
38 (and (match_code "const_int")
39 (match_test "SMALL_INT (INTVAL (op))")))
40
41 (define_predicate "arith_operand"
42 (ior (match_operand 0 "const_arith_operand")
43 (match_operand 0 "register_operand")))
44
45 (define_predicate "add_regimm_operand"
46 (ior (match_operand 0 "arith_operand")
47 (match_test "nios2_unspec_reloc_p (op)")))
48
49 (define_predicate "const_logical_operand"
50 (and (match_code "const_int")
51 (match_test "(INTVAL (op) & 0xffff) == 0
52 || (INTVAL (op) & 0xffff0000) == 0")))
53
54 (define_predicate "logical_operand"
55 (ior (match_operand 0 "const_logical_operand")
56 (match_operand 0 "register_operand")))
57
58 (define_predicate "const_shift_operand"
59 (and (match_code "const_int")
60 (match_test "SHIFT_INT (INTVAL (op))")))
61
62 (define_predicate "shift_operand"
63 (ior (match_operand 0 "const_shift_operand")
64 (match_operand 0 "register_operand")))
65
66 (define_predicate "call_operand"
67 (ior (match_operand 0 "immediate_operand")
68 (match_operand 0 "register_operand")))
69
70 (define_predicate "rdwrctl_operand"
71 (and (match_code "const_int")
72 (match_test "RDWRCTL_INT (INTVAL (op))")))
73
74 (define_predicate "custom_insn_opcode"
75 (and (match_code "const_int")
76 (match_test "CUSTOM_INSN_OPCODE (INTVAL (op))")))
77
78 (define_special_predicate "expandable_comparison_operator"
79 (match_operand 0 "ordered_comparison_operator")
80 {
81 return (GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) != MODE_FLOAT
82 || nios2_validate_fpu_compare (GET_MODE (XEXP (op, 0)), &op,
83 &XEXP (op, 0), &XEXP (op, 1),
84 false));
85 })
86
87 (define_predicate "ldstio_memory_operand"
88 (match_code "mem")
89 {
90 if (TARGET_ARCH_R2)
91 {
92 rtx addr = XEXP (op, 0);
93 if (REG_P (addr))
94 return true;
95 else if (GET_CODE (addr) == PLUS)
96 return (REG_P (XEXP (addr, 0))
97 && CONST_INT_P (XEXP (addr, 1))
98 && SMALL_INT12 (INTVAL (XEXP (addr, 1))));
99 return false;
100 }
101 return memory_operand (op, mode);
102 })