xref: /netbsd-src/external/gpl3/gcc/dist/gcc/config/or1k/constraints.md (revision e9e6e0f6fbc36b8de7586170291cf5fc97cab8b6)
1;; Constraint definitions for OpenRISC
2;; Copyright (C) 2018-2022 Free Software Foundation, Inc.
3;; Contributed by Stafford Horne
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;; Constraints
23;; -------------------------------------------------------------------------
24
25; We use:
26;  c - sibcall registers
27;  d - double pair base registers (excludes r0, r30 and r31 which overflow)
28;  t - got address registers (excludes LR (r9) which is clobbered by set_got)
29;  I - constant signed 16-bit
30;  K - constant unsigned 16-bit
31;  M - constant signed 16-bit shifted left 16-bits (l.movhi)
32;  O - constant zero
33
34(define_register_constraint "c" "SIBCALL_REGS"
35  "Registers which can hold a sibling call address")
36
37(define_register_constraint "d" "DOUBLE_REGS"
38  "Registers which can be used for double reg pairs.")
39
40(define_register_constraint "t" "GOT_REGS"
41  "Registers which can be used to store the Global Offset Table (GOT) address.")
42
43;; Immediates
44(define_constraint "I"
45  "A signed 16-bit immediate in the range -32768 to 32767."
46  (and (match_code "const_int")
47       (match_test "IN_RANGE (ival, -32768, 32767)")))
48
49(define_constraint "K"
50  "An unsigned 16-bit immediate in the range 0 to 0xffff."
51  (and (match_code "const_int")
52       (match_test "IN_RANGE (ival, 0, 65535)")))
53
54(define_constraint "M"
55  "A shifted signed 16-bit constant suitable for l.movhi."
56  (and (match_code "const_int")
57       (match_test "(ival & 0xffff) == 0
58		    && (ival >> 31 == -1 || ival >> 31 == 0)")))
59
60(define_constraint "O"
61  "The constant zero"
62  (and (match_code "const_int")
63       (match_test "ival == 0")))
64