OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / config / nios2 / constraints.md
1 ;; Constraint definitions for Altera Nios II.
2 ;; Copyright (C) 2012 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.
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 ;; We use the following constraint letters for constants
22 ;;
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)
30 ;;
31 ;; We use the following built-in register classes:
32 ;;
33 ;;  r: general purpose register (r0..r31)
34 ;;  m: memory operand
35 ;;
36 ;; Plus, we define the following constraint strings:
37 ;;
38 ;;  S: symbol that is in the "small data" area
39 ;;  Dnn: Dnn_REG (just rnn)
40
41 ;; Register constraints
42
43 (define_register_constraint "j" "SIB_REGS"
44   "A register suitable for an indirect sibcall.")
45
46 ;; These are documented for use in inline asm.
47 (define_register_constraint "D00" "D00_REG" "Hard register 0.")
48 (define_register_constraint "D01" "D01_REG" "Hard register 1.")
49 (define_register_constraint "D02" "D02_REG" "Hard register 2.")
50 (define_register_constraint "D03" "D03_REG" "Hard register 3.")
51 (define_register_constraint "D04" "D04_REG" "Hard register 4.")
52 (define_register_constraint "D05" "D05_REG" "Hard register 5.")
53 (define_register_constraint "D06" "D06_REG" "Hard register 6.")
54 (define_register_constraint "D07" "D07_REG" "Hard register 7.")
55 (define_register_constraint "D08" "D08_REG" "Hard register 8.")
56 (define_register_constraint "D09" "D09_REG" "Hard register 9.")
57 (define_register_constraint "D10" "D10_REG" "Hard register 10.")
58 (define_register_constraint "D11" "D11_REG" "Hard register 11.")
59 (define_register_constraint "D12" "D12_REG" "Hard register 12.")
60 (define_register_constraint "D13" "D13_REG" "Hard register 13.")
61 (define_register_constraint "D14" "D14_REG" "Hard register 14.")
62 (define_register_constraint "D15" "D15_REG" "Hard register 15.")
63 (define_register_constraint "D16" "D16_REG" "Hard register 16.")
64 (define_register_constraint "D17" "D17_REG" "Hard register 17.")
65 (define_register_constraint "D18" "D18_REG" "Hard register 18.")
66 (define_register_constraint "D19" "D19_REG" "Hard register 19.")
67 (define_register_constraint "D20" "D20_REG" "Hard register 20.")
68 (define_register_constraint "D21" "D21_REG" "Hard register 21.")
69 (define_register_constraint "D22" "D22_REG" "Hard register 22.")
70 (define_register_constraint "D23" "D23_REG" "Hard register 23.")
71 (define_register_constraint "D24" "D24_REG" "Hard register 24.")
72 (define_register_constraint "D25" "D25_REG" "Hard register 25.")
73 (define_register_constraint "D26" "D26_REG" "Hard register 26.")
74 (define_register_constraint "D27" "D27_REG" "Hard register 27.")
75 (define_register_constraint "D28" "D28_REG" "Hard register 28.")
76 (define_register_constraint "D29" "D29_REG" "Hard register 29.")
77 (define_register_constraint "D30" "D30_REG" "Hard register 30.")
78 (define_register_constraint "D31" "D31_REG" "Hard register 31.")
79
80 ;; Integer constraints
81
82 (define_constraint "I"
83   "A signed 16-bit constant (for arithmetic instructions)."
84   (and (match_code "const_int")
85        (match_test "SMALL_INT (ival)")))
86
87 (define_constraint "J"
88   "An unsigned 16-bit constant (for logical instructions)."
89   (and (match_code "const_int")
90        (match_test "SMALL_INT_UNSIGNED (ival)")))
91
92 (define_constraint "K"
93   "An unsigned 16-bit high constant (for logical instructions)."
94   (and (match_code "const_int")
95        (match_test "UPPER16_INT (ival)")))
96
97 (define_constraint "L"
98   "An unsigned 5-bit constant (for shift counts)."
99   (and (match_code "const_int")
100        (match_test "ival >= 0 && ival <= 31")))
101
102 (define_constraint "M"
103   "Integer zero."
104   (and (match_code "const_int")
105        (match_test "ival == 0")))
106
107 (define_constraint "N"
108   "An unsigned 8-bit constant (for custom instruction codes)."
109   (and (match_code "const_int")
110        (match_test "ival >= 0 && ival <= 255")))
111
112 (define_constraint "O"
113   "An unsigned 5-bit constant (for control register numbers)."
114   (and (match_code "const_int")
115        (match_test "ival >= 0 && ival <= 31")))
116
117 (define_constraint "S"
118   "An immediate stored in small data, accessible by GP."
119   (and (match_code "symbol_ref")
120        (match_test "SYMBOL_REF_IN_NIOS2_SMALL_DATA_P (op)")))