xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/msp430/constraints.md (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1;;  Machine Description for TI MSP43* processors
2;;  Copyright (C) 2013-2020 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."
29  (and (match_code "const_int")
30       (match_test "IN_RANGE (ival, 1, 1)")))
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(define_constraint "M"
38  "Integer constant 1-4."
39  (and (match_code "const_int")
40       (match_test "IN_RANGE (ival, 1, 4)")))
41
42(define_constraint "N"
43  "Integer constant 0-255."
44  (and (match_code "const_int")
45       (match_test "IN_RANGE (ival, 0, 255)")))
46
47(define_constraint "O"
48  "Integer constant 256-65535."
49  (and (match_code "const_int")
50       (match_test "IN_RANGE (ival, 256, 65535)")))
51
52;; We do not allow arbitrary constants, eg symbols or labels,
53;; because their address may be above the 16-bit address limit
54;; supported by the offset used in the MOVA instruction.
55(define_constraint "Ya"
56  "Memory reference, any type, but restricted range of constants"
57  (and (match_code "mem")
58       (ior (match_code "reg" "0")
59	    (and (match_code "plus" "0")
60		 (match_code "reg" "00")
61		 (match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))")))
62	    (match_test "CONSTANT_P (XEXP (op, 0))")
63	    (match_code "post_inc" "0")
64	    )))
65
66(define_constraint "Yl"
67  "Memory reference, labels only."
68  (and (match_code "mem")
69       (match_code "label_ref" "0")))
70
71
72;; These are memory references that are safe to use without the X suffix,
73;; because we know/assume they need not index across the 64K boundary.
74;; Note that for a PSImode memory operand, we always need to use the X suffix,
75;; regardless of what this constraint decides.
76(define_constraint "Ys"
77  "Memory reference, indexed or indirect register addressing modes."
78  (and (match_code "mem")
79       (ior
80	(and (match_code "plus" "0")
81	     (and (match_code "reg" "00")
82		  (match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))"))
83		  (match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)"))))
84	(match_code "reg" "0")
85	(match_code "post_inc" "0")
86	)))
87
88(define_constraint "Yc"
89  "Memory reference, for CALL - we can't use SP."
90  (and (match_code "mem")
91       (match_code "mem" "0")
92       (not (ior
93	     (and (match_code "plus" "00")
94		  (and (match_code "reg" "000")
95		       (match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO"))))
96	     (and (match_code "reg" "0")
97		  (match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO")))
98	     ))))
99
100(define_constraint "Yx"
101  "Memory reference, in lower memory below address 0x10000."
102  (and (match_code "mem")
103       (match_test "msp430_op_not_in_high_mem (op)")))
104