1 ;; Predicate definitions for FT32
2 ;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
3 ;; Contributed by FTDI <support@ftdi.com>
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
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/>.
21 ;; -------------------------------------------------------------------------
23 ;; -------------------------------------------------------------------------
25 ;; Nonzero if OP can be source of a simple move operation.
27 ;; The CONST_INT could really be CONST if we were to fix
28 ;; ft32_print_operand_address to format the address correctly.
29 ;; It might require assembler/linker work as well to ensure
30 ;; the right relocation is emitted.
32 (define_predicate "ft32_general_movsrc_operand"
33 (match_code "mem,const_int,reg,subreg,symbol_ref,label_ref,const")
35 /* Any (MEM LABEL_REF) is OK. That is a pc-relative load. */
36 if (MEM_P (op) && GET_CODE (XEXP (op, 0)) == LABEL_REF)
40 && GET_CODE (XEXP (op, 0)) == PLUS
41 && GET_CODE (XEXP (XEXP (op, 0), 0)) == REG
42 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
45 return general_operand (op, mode);
48 (define_predicate "ft32_general_movdst_operand"
49 (match_code "mem,const_int,reg,subreg,symbol_ref,label_ref,const")
52 && GET_CODE (XEXP (op, 0)) == PLUS
53 && GET_CODE (XEXP (XEXP (op, 0), 0)) == REG
54 && CONST_INT_P (XEXP (XEXP (op, 0), 1)))
56 if (MEM_P (op) && GET_CODE (XEXP (op, 0)) == SYMBOL_REF)
59 (MEM_P(op) && REG_P(XEXP (op, 0)));
62 (define_predicate "reg_indirect"
65 return (MEM_P(op) && REG_P(XEXP (op, 0)));
68 ;; Nonzero if OP can be an operand to an add/inc/dec instruction.
70 (define_predicate "ft32_add_operand"
71 (ior (match_code "reg")
72 (and (match_code "const_int")
73 (match_test "IN_RANGE (INTVAL (op), -32768, 32767)"))))
75 ;; Nonzero if OP can be an operand to an sub/dec instruction.
77 (define_predicate "ft32_sub_operand"
78 (ior (match_code "reg")
79 (and (match_code "const_int")
80 (match_test "IN_RANGE (INTVAL (op), -32767, 32768)"))))
83 (define_predicate "ft32_rimm_operand"
84 (ior (match_code "reg")
85 (and (match_code "const_int")
86 (match_test "IN_RANGE (INTVAL (op), -512, 511)"))))
88 (define_predicate "ft32_imm_operand"
89 (and (match_code "const_int")
90 (match_test "IN_RANGE (INTVAL (op), -512, 511)")))
92 (define_predicate "ft32_bwidth_operand"
93 (and (match_code "const_int")
94 (match_test "IN_RANGE (INTVAL (op), 1, 16)")))