| 1 |
;; Constraint definitions for the Motorola MCore |
| 2 |
;; Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
;; This file is part of GCC. |
| 5 |
|
| 6 |
;; GCC is free software; you can redistribute it and/or modify |
| 7 |
;; it under the terms of the GNU General Public License as published by |
| 8 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 9 |
;; any later version. |
| 10 |
|
| 11 |
;; GCC is distributed in the hope that it will be useful, |
| 12 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
;; GNU General Public License for more details. |
| 15 |
|
| 16 |
;; You should have received a copy of the GNU General Public License |
| 17 |
;; along with GCC; see the file COPYING3. If not see |
| 18 |
;; <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
;; Register constraints. |
| 21 |
(define_register_constraint "a" "LRW_REGS" |
| 22 |
"@internal") |
| 23 |
|
| 24 |
(define_register_constraint "b" "ONLYR1_REGS" |
| 25 |
"@internal") |
| 26 |
|
| 27 |
(define_register_constraint "c" "C_REGS" |
| 28 |
"@internal") |
| 29 |
|
| 30 |
(define_register_constraint "x" "ALL_REGS" |
| 31 |
"@internal") |
| 32 |
|
| 33 |
;; Integer constraints. |
| 34 |
(define_constraint "I" |
| 35 |
"An integer in the range 0 to 127." |
| 36 |
(and (match_code "const_int") |
| 37 |
(match_test "IN_RANGE (ival, 0, 127)"))) |
| 38 |
|
| 39 |
(define_constraint "J" |
| 40 |
"An integer in the range 1 to 32." |
| 41 |
(and (match_code "const_int") |
| 42 |
(match_test "IN_RANGE (ival, 1, 32)"))) |
| 43 |
|
| 44 |
(define_constraint "K" |
| 45 |
"A shift operand, an integer in the range 0 to 31." |
| 46 |
(and (match_code "const_int") |
| 47 |
(match_test "IN_RANGE (ival, 0, 31)"))) |
| 48 |
|
| 49 |
(define_constraint "L" |
| 50 |
"A negative arithmetic operand in the range -32 to -1." |
| 51 |
(and (match_code "const_int") |
| 52 |
(match_test "IN_RANGE (ival, -32, -1)"))) |
| 53 |
|
| 54 |
(define_constraint "M" |
| 55 |
"A constant loadable by bgeni." |
| 56 |
(and (match_code "const_int") |
| 57 |
(match_test "exact_log2 (ival) >= 0 && exact_log2 (ival) <= 30"))) |
| 58 |
|
| 59 |
(define_constraint "N" |
| 60 |
"A constant loadable by bmaskii, including -1." |
| 61 |
(and (match_code "const_int") |
| 62 |
(ior (match_test "ival == -1") |
| 63 |
(and (match_test "exact_log2 (ival + 1) >= 0") |
| 64 |
(match_test "exact_log2 (ival + 1) <= 30"))))) |
| 65 |
|
| 66 |
(define_constraint "O" |
| 67 |
"A constant allowed by cmov with two constants +/- 1 of each other." |
| 68 |
(and (match_code "const_int") |
| 69 |
(ior (match_test "insn_const_int_ok_for_constraint (ival, CONSTRAINT_I)") |
| 70 |
(match_test "insn_const_int_ok_for_constraint (ival, CONSTRAINT_M)") |
| 71 |
(match_test "insn_const_int_ok_for_constraint (ival, CONSTRAINT_N)") |
| 72 |
(match_test "insn_const_int_ok_for_constraint (ival - 1, CONSTRAINT_M)") |
| 73 |
(match_test "insn_const_int_ok_for_constraint (ival + 1, CONSTRAINT_N)")))) |
| 74 |
|
| 75 |
(define_constraint "P" |
| 76 |
"A value that can be generated without an lrw instruction." |
| 77 |
(and (match_code "const_int") |
| 78 |
(match_test "mcore_const_ok_for_inline (ival)"))) |
| 79 |
|
| 80 |
;; Floating-point constraints. |
| 81 |
(define_constraint "G" |
| 82 |
"@internal" |
| 83 |
(and (match_code "const_double") |
| 84 |
(match_test "insn_const_int_ok_for_constraint (hval, CONSTRAINT_I)") |
| 85 |
(match_test "insn_const_int_ok_for_constraint (ival, CONSTRAINT_I)"))) |
| 86 |
|
| 87 |
;; Other constraints. |
| 88 |
(define_constraint "Q" |
| 89 |
"The integer constant one." |
| 90 |
(and (match_code "const_int") |
| 91 |
(match_test "ival == 1"))) |
| 92 |
|
| 93 |
(define_constraint "R" |
| 94 |
"@internal" |
| 95 |
(and (match_code "mem") |
| 96 |
(match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF"))) |
| 97 |
|
| 98 |
(define_constraint "S" |
| 99 |
"An integer constant with 0, 1, or 2 bits clear." |
| 100 |
(and (match_code "const_int") |
| 101 |
(match_test "mcore_num_zeros (ival) <= 2"))) |
| 102 |
|
| 103 |
(define_constraint "T" |
| 104 |
"An integer constant with 2 set bits." |
| 105 |
(and (match_code "const_int") |
| 106 |
(match_test "mcore_num_ones (ival) == 2"))) |
| 107 |
|
| 108 |
(define_constraint "U" |
| 109 |
"The integer constant zero." |
| 110 |
(and (match_code "const_int") |
| 111 |
(match_test "ival == 0"))) |