| 1 |
;; Constraints for C-SKY. |
| 2 |
;; Copyright (C) 2018-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by C-SKY Microsystems and Mentor Graphics. |
| 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 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, but |
| 13 |
;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
;; 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 |
;; Register constraints. |
| 22 |
|
| 23 |
(define_register_constraint "a" "MINI_REGS" "r0 - r7") |
| 24 |
(define_register_constraint "b" "LOW_REGS" "r0 - r15") |
| 25 |
(define_register_constraint "c" "C_REGS" "C register") |
| 26 |
(define_register_constraint "y" "HILO_REGS" "HI and LO registers") |
| 27 |
(define_register_constraint "v" "V_REGS" "vector registers") |
| 28 |
(define_register_constraint "z" "SP_REGS" "SP register") |
| 29 |
|
| 30 |
|
| 31 |
;; Memory and misc constraints. |
| 32 |
|
| 33 |
(define_memory_constraint "Q" |
| 34 |
"Memory operands with base register, index register and short displacement for FPUV2" |
| 35 |
(match_test "csky_valid_mem_constraint_operand (op, \"Q\")")) |
| 36 |
|
| 37 |
(define_memory_constraint "W" |
| 38 |
"Memory operands with base register, index register" |
| 39 |
(match_test "csky_valid_mem_constraint_operand (op, \"W\")")) |
| 40 |
|
| 41 |
(define_memory_constraint "Y" |
| 42 |
"Memory operands without index register" |
| 43 |
(not (match_test "csky_valid_mem_constraint_operand (op, \"W\")"))) |
| 44 |
|
| 45 |
(define_constraint "R" |
| 46 |
"Memory operands whose address is a label_ref" |
| 47 |
(and (match_code "mem") |
| 48 |
(match_test "GET_CODE (XEXP (op, 0)) == LABEL_REF"))) |
| 49 |
|
| 50 |
(define_constraint "S" |
| 51 |
"Symbol reference with optional offset" |
| 52 |
(match_test "csky_symbolic_address_p (op)")) |
| 53 |
|
| 54 |
|
| 55 |
;; Constant integer constraints. |
| 56 |
|
| 57 |
(define_constraint "I" |
| 58 |
"Constant in range [0, 65535]" |
| 59 |
(and (match_code "const_int") |
| 60 |
(match_test "CSKY_CONST_OK_FOR_I (ival)"))) |
| 61 |
|
| 62 |
(define_constraint "J" |
| 63 |
"Constant in range [1, 32]" |
| 64 |
(and (match_code "const_int") |
| 65 |
(match_test "CSKY_CONST_OK_FOR_J (ival)"))) |
| 66 |
|
| 67 |
(define_constraint "K" |
| 68 |
"Constant in range [0, 31]" |
| 69 |
(and (match_code "const_int") |
| 70 |
(match_test "CSKY_CONST_OK_FOR_K (ival)"))) |
| 71 |
|
| 72 |
(define_constraint "L" |
| 73 |
"Constant in range [1, 8]" |
| 74 |
(and (match_code "const_int") |
| 75 |
(match_test "CSKY_CONST_OK_FOR_L (ival)"))) |
| 76 |
|
| 77 |
(define_constraint "M" |
| 78 |
"Constant in range [1, 4096]" |
| 79 |
(and (match_code "const_int") |
| 80 |
(match_test "CSKY_CONST_OK_FOR_M (ival)"))) |
| 81 |
|
| 82 |
(define_constraint "N" |
| 83 |
"Constant in range [1, 256]" |
| 84 |
(and (match_code "const_int") |
| 85 |
(match_test "CSKY_CONST_OK_FOR_N (ival)"))) |
| 86 |
|
| 87 |
(define_constraint "O" |
| 88 |
"Constant in range [0, 4095]" |
| 89 |
(and (match_code "const_int") |
| 90 |
(match_test "CSKY_CONST_OK_FOR_O (ival)"))) |
| 91 |
|
| 92 |
(define_constraint "P" |
| 93 |
"Constant in range [4, 508] that is divisible by 4" |
| 94 |
(and (match_code "const_int") |
| 95 |
(match_test "CSKY_CONST_OK_FOR_P (ival)"))) |
| 96 |
|
| 97 |
(define_constraint "T" |
| 98 |
"Constant in range [-256, -1]" |
| 99 |
(and (match_code "const_int") |
| 100 |
(match_test "CSKY_CONST_OK_FOR_T (ival)"))) |
| 101 |
|
| 102 |
(define_constraint "Ua" |
| 103 |
"Constant 0" |
| 104 |
(and (match_code "const_int") |
| 105 |
(match_test "ival == 0"))) |
| 106 |
|
| 107 |
(define_constraint "Ub" |
| 108 |
"Unsigned int that is an exact power of 2" |
| 109 |
(and (match_code "const_int") |
| 110 |
(match_test "CSKY_CONST_OK_FOR_Ub (ival)"))) |
| 111 |
|
| 112 |
(define_constraint "Uc" |
| 113 |
"Unsigned int X such that X+1 is an exact power of 2" |
| 114 |
(and (match_code "const_int") |
| 115 |
(match_test "CSKY_CONST_OK_FOR_Uc (ival)"))) |
| 116 |
|
| 117 |
(define_constraint "Ud" |
| 118 |
"64-bit int whose high/low words separately satisfy I, Ub, or Uc" |
| 119 |
(and (match_code "const_int") |
| 120 |
(match_test "CSKY_CONST_OK_FOR_Ud (ival)"))) |
| 121 |
|
| 122 |
(define_constraint "Ug" |
| 123 |
"Constant in range [-508, -4] that is divisible by 4" |
| 124 |
(and (match_code "const_int") |
| 125 |
(match_test "CSKY_CONST_OK_FOR_Ug (ival)"))) |
| 126 |
|
| 127 |
(define_constraint "Uh" |
| 128 |
"Constant in range [-31, 0]" |
| 129 |
(and (match_code "const_int") |
| 130 |
(match_test "CSKY_CONST_OK_FOR_Uh (ival)"))) |
| 131 |
|
| 132 |
(define_constraint "Uj" |
| 133 |
"Constant in range [4, 1024] that is divisible by 4" |
| 134 |
(and (match_code "const_int") |
| 135 |
(match_test "CSKY_CONST_OK_FOR_Uj (ival)"))) |
| 136 |
|
| 137 |
(define_constraint "Uk" |
| 138 |
"Constant in range [1, 65536]" |
| 139 |
(and (match_code "const_int") |
| 140 |
(match_test "CSKY_CONST_OK_FOR_Uk (ival)"))) |
| 141 |
|
| 142 |
(define_constraint "Ul" |
| 143 |
"Constant in range [-1024, -4] that is divisible by 4" |
| 144 |
(and (match_code "const_int") |
| 145 |
(match_test "CSKY_CONST_OK_FOR_Ul (ival)"))) |
| 146 |
|
| 147 |
(define_constraint "Um" |
| 148 |
"Constant in range [-4096, -1]" |
| 149 |
(and (match_code "const_int") |
| 150 |
(match_test "CSKY_CONST_OK_FOR_Um (ival)"))) |
| 151 |
|
| 152 |
(define_constraint "Un" |
| 153 |
"Constant whose low 16 bits are all zeros" |
| 154 |
(and (match_code "const_int") |
| 155 |
(match_test "CSKY_CONST_OK_FOR_MOVIH (ival)"))) |
| 156 |
|
| 157 |
(define_constraint "Uo" |
| 158 |
"Constant that can be synthesized with an extra instruction" |
| 159 |
(and (match_code "const_int") |
| 160 |
(match_test "csky_inlinable_constant (ival)"))) |
| 161 |
|
| 162 |
(define_constraint "Up" |
| 163 |
"Constant in range [0, 255]" |
| 164 |
(and (match_code "const_int") |
| 165 |
(match_test "CSKY_CONST_OK_FOR_N (ival + 1)"))) |
| 166 |
|
| 167 |
(define_constraint "Uq" |
| 168 |
"Constant in range [0, 1020] that is divisible by 4" |
| 169 |
(and (match_code "const_int") |
| 170 |
(match_test "CSKY_CONST_OK_FOR_Uj (ival + 4)"))) |
| 171 |
|
| 172 |
(define_constraint "Ur" |
| 173 |
"Constant in range [-1020, -4] that is divisible by 4" |
| 174 |
(and (match_code "const_int") |
| 175 |
(match_test "CSKY_CONST_OK_FOR_Uj (-ival + 4)"))) |
| 176 |
|
| 177 |
(define_constraint "Us" |
| 178 |
"Constant in range [-8, -1]" |
| 179 |
(and (match_code "const_int") |
| 180 |
(match_test "CSKY_CONST_OK_FOR_US (ival)"))) |
| 181 |
|
| 182 |
(define_constraint "Dv" |
| 183 |
"@VFPv3 |
| 184 |
A const_double which can be used with a VFP fmovi |
| 185 |
instruction." |
| 186 |
(and (match_code "const_double") |
| 187 |
(match_test "fpuv3_const_double_rtx (op)"))) |