| 1 |
;; Predicate definitions for Moxie |
| 2 |
;; Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by Anthony Green <[email protected]> |
| 4 |
|
| 5 |
;; This file is part of GCC. |
| 6 |
|
| 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. |
| 11 |
|
| 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. |
| 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 |
;; ------------------------------------------------------------------------- |
| 22 |
;; Predicates |
| 23 |
;; ------------------------------------------------------------------------- |
| 24 |
|
| 25 |
;; Nonzero if OP can be source of a simple move operation. |
| 26 |
|
| 27 |
(define_predicate "moxie_general_movsrc_operand" |
| 28 |
(match_code "mem,const_int,reg,subreg,symbol_ref,label_ref,const") |
| 29 |
{ |
| 30 |
/* Any (MEM LABEL_REF) is OK. That is a pc-relative load. */ |
| 31 |
if (MEM_P (op) && GET_CODE (XEXP (op, 0)) == LABEL_REF) |
| 32 |
return 1; |
| 33 |
|
| 34 |
if (MEM_P (op) |
| 35 |
&& GET_CODE (XEXP (op, 0)) == PLUS |
| 36 |
&& GET_CODE (XEXP (XEXP (op, 0), 0)) == REG |
| 37 |
&& GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT |
| 38 |
&& IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), -32768, 32767)) |
| 39 |
return 1; |
| 40 |
|
| 41 |
return general_operand (op, mode); |
| 42 |
}) |
| 43 |
|
| 44 |
;; Nonzero if OP can be an operand to an add/inc/dec instruction. |
| 45 |
|
| 46 |
(define_predicate "moxie_add_operand" |
| 47 |
(ior (match_code "reg") |
| 48 |
(and (match_code "const_int") |
| 49 |
(match_test "IN_RANGE (INTVAL (op), -255, 255)")))) |
| 50 |
|
| 51 |
;; Nonzero if OP can be an operand to an sub/dec instruction. |
| 52 |
|
| 53 |
(define_predicate "moxie_sub_operand" |
| 54 |
(ior (match_code "reg") |
| 55 |
(and (match_code "const_int") |
| 56 |
(match_test "IN_RANGE (INTVAL (op), 0, 255)")))) |