Merge from trunk
[official-gcc.git] / gcc / config / nios2 / constraints.md
blobdbae54320e90a70d6cdf33c9e9dcba2984ab5f28
1 ;; Constraint definitions for Altera Nios II.
2 ;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 ;; Contributed by Chung-Lin Tang <cltang@codesourcery.com>
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.
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.
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/>.
21 ;; We use the following constraint letters for constants
23 ;;  I: -32768 to -32767
24 ;;  J: 0 to 65535
25 ;;  K: $nnnn0000 for some nnnn
26 ;;  L: 0 to 31 (for shift counts)
27 ;;  M: 0
28 ;;  N: 0 to 255 (for custom instruction numbers)
29 ;;  O: 0 to 31 (for control register numbers)
31 ;; We use the following built-in register classes:
33 ;;  r: general purpose register (r0..r31)
34 ;;  m: memory operand
36 ;; Plus, we define the following constraint strings:
38 ;;  S: symbol that is in the "small data" area
40 ;; Register constraints
42 (define_register_constraint "j" "SIB_REGS"
43   "A register suitable for an indirect sibcall.")
45 ;; Integer constraints
47 (define_constraint "I"
48   "A signed 16-bit constant (for arithmetic instructions)."
49   (and (match_code "const_int")
50        (match_test "SMALL_INT (ival)")))
52 (define_constraint "J"
53   "An unsigned 16-bit constant (for logical instructions)."
54   (and (match_code "const_int")
55        (match_test "SMALL_INT_UNSIGNED (ival)")))
57 (define_constraint "K"
58   "An unsigned 16-bit high constant (for logical instructions)."
59   (and (match_code "const_int")
60        (match_test "UPPER16_INT (ival)")))
62 (define_constraint "L"
63   "An unsigned 5-bit constant (for shift counts)."
64   (and (match_code "const_int")
65        (match_test "ival >= 0 && ival <= 31")))
67 (define_constraint "M"
68   "Integer zero."
69   (and (match_code "const_int")
70        (match_test "ival == 0")))
72 (define_constraint "N"
73   "An unsigned 8-bit constant (for custom instruction codes)."
74   (and (match_code "const_int")
75        (match_test "ival >= 0 && ival <= 255")))
77 (define_constraint "O"
78   "An unsigned 5-bit constant (for control register numbers)."
79   (and (match_code "const_int")
80        (match_test "ival >= 0 && ival <= 31")))
82 (define_constraint "S"
83   "An immediate stored in small data, accessible by GP."
84   (and (match_code "symbol_ref")
85        (match_test "nios2_symbol_ref_in_small_data_p (op)")))
87 (define_constraint "T"
88   "A constant unspec offset representing a relocation."
89   (match_test "nios2_unspec_reloc_p (op)"))