| 1 |
;; Machine Description for TI MSP43* processors |
| 2 |
;; Copyright (C) 2013-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by Red Hat. |
| 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_register_constraint "R12" "R12_REGS" |
| 22 |
"Register R12.") |
| 23 |
|
| 24 |
(define_register_constraint "R13" "R13_REGS" |
| 25 |
"Register R13.") |
| 26 |
|
| 27 |
(define_constraint "K" |
| 28 |
"Integer constant 1-19." |
| 29 |
(and (match_code "const_int") |
| 30 |
(match_test "IN_RANGE (ival, 1, 19)"))) |
| 31 |
|
| 32 |
(define_constraint "L" |
| 33 |
"Integer constant -1^20..1^19." |
| 34 |
(and (match_code "const_int") |
| 35 |
(match_test "IN_RANGE (ival, HOST_WIDE_INT_M1U << 20, 1 << 19)"))) |
| 36 |
|
| 37 |
;; Valid shift amount for RRUM, RRAM, RLAM, RRCM. |
| 38 |
(define_constraint "M" |
| 39 |
"Integer constant 1-4." |
| 40 |
(and (match_code "const_int") |
| 41 |
(match_test "IN_RANGE (ival, 1, 4)"))) |
| 42 |
|
| 43 |
(define_constraint "N" |
| 44 |
"Integer constant 0-255." |
| 45 |
(and (match_code "const_int") |
| 46 |
(match_test "IN_RANGE (ival, 0, 255)"))) |
| 47 |
|
| 48 |
(define_constraint "O" |
| 49 |
"Integer constant 256-65535." |
| 50 |
(and (match_code "const_int") |
| 51 |
(match_test "IN_RANGE (ival, 256, 65535)"))) |
| 52 |
|
| 53 |
(define_constraint "P" |
| 54 |
"Integer constant 1-16." |
| 55 |
(and (match_code "const_int") |
| 56 |
(match_test "IN_RANGE (ival, 1, 16)"))) |
| 57 |
|
| 58 |
;; We do not allow arbitrary constants, eg symbols or labels, |
| 59 |
;; because their address may be above the 16-bit address limit |
| 60 |
;; supported by the offset used in the MOVA instruction. |
| 61 |
(define_constraint "Ya" |
| 62 |
"Memory reference, any type, but restricted range of constants" |
| 63 |
(and (match_code "mem") |
| 64 |
(ior (match_code "reg" "0") |
| 65 |
(and (match_code "plus" "0") |
| 66 |
(match_code "reg" "00") |
| 67 |
(match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))"))) |
| 68 |
(match_test "CONSTANT_P (XEXP (op, 0))") |
| 69 |
(match_code "post_inc" "0") |
| 70 |
))) |
| 71 |
|
| 72 |
(define_constraint "Yl" |
| 73 |
"Memory reference, labels only." |
| 74 |
(and (match_code "mem") |
| 75 |
(match_code "label_ref" "0"))) |
| 76 |
|
| 77 |
|
| 78 |
;; These are memory references that are safe to use without the X suffix, |
| 79 |
;; because we know/assume they need not index across the 64K boundary. |
| 80 |
;; Note that for a PSImode memory operand, we always need to use the X suffix, |
| 81 |
;; regardless of what this constraint decides. |
| 82 |
(define_constraint "Ys" |
| 83 |
"Memory reference, indexed or indirect register addressing modes." |
| 84 |
(and (match_code "mem") |
| 85 |
(ior |
| 86 |
(and (match_code "plus" "0") |
| 87 |
(and (match_code "reg" "00") |
| 88 |
(match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))")) |
| 89 |
(match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)")))) |
| 90 |
(match_code "reg" "0") |
| 91 |
(match_code "post_inc" "0") |
| 92 |
))) |
| 93 |
|
| 94 |
(define_constraint "Yc" |
| 95 |
"Memory reference, for CALL - we can't use SP." |
| 96 |
(and (match_code "mem") |
| 97 |
(match_code "mem" "0") |
| 98 |
(not (ior |
| 99 |
(and (match_code "plus" "00") |
| 100 |
(and (match_code "reg" "000") |
| 101 |
(match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO")))) |
| 102 |
(and (match_code "reg" "0") |
| 103 |
(match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO"))) |
| 104 |
)))) |
| 105 |
|
| 106 |
(define_constraint "Yx" |
| 107 |
"Memory reference, in lower memory below address 0x10000." |
| 108 |
(and (match_code "mem") |
| 109 |
(match_test "msp430_op_not_in_high_mem (op)"))) |