genmova.sh revision 1.1.1.1.4.2 1 1.1.1.1.4.2 yamt #!/bin/sh
2 1.1.1.1.4.2 yamt # Generate mova.md, a file containing patterns that can be implemented
3 1.1.1.1.4.2 yamt # using the h8sx mova instruction.
4 1.1.1.1.4.2 yamt
5 1.1.1.1.4.2 yamt # Copyright (C) 2004, 2009 Free Software Foundation, Inc.
6 1.1.1.1.4.2 yamt #
7 1.1.1.1.4.2 yamt # This file is part of GCC.
8 1.1.1.1.4.2 yamt #
9 1.1.1.1.4.2 yamt # GCC is free software; you can redistribute it and/or modify
10 1.1.1.1.4.2 yamt # it under the terms of the GNU General Public License as published by
11 1.1.1.1.4.2 yamt # the Free Software Foundation; either version 3, or (at your option)
12 1.1.1.1.4.2 yamt # any later version.
13 1.1.1.1.4.2 yamt #
14 1.1.1.1.4.2 yamt # GCC is distributed in the hope that it will be useful,
15 1.1.1.1.4.2 yamt # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1.1.1.4.2 yamt # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1.1.1.4.2 yamt # GNU General Public License for more details.
18 1.1.1.1.4.2 yamt #
19 1.1.1.1.4.2 yamt # You should have received a copy of the GNU General Public License
20 1.1.1.1.4.2 yamt # along with GCC; see the file COPYING3. If not see
21 1.1.1.1.4.2 yamt # <http://www.gnu.org/licenses/>.
22 1.1.1.1.4.2 yamt
23 1.1.1.1.4.2 yamt echo ";; -*- buffer-read-only: t -*-"
24 1.1.1.1.4.2 yamt echo ";; Generated automatically from genmova.sh"
25 1.1.1.1.4.2 yamt echo ";; Copyright (C) 2004, 2009 Free Software Foundation, Inc."
26 1.1.1.1.4.2 yamt echo ";;"
27 1.1.1.1.4.2 yamt echo ";; This file is part of GCC."
28 1.1.1.1.4.2 yamt echo ";;"
29 1.1.1.1.4.2 yamt echo ";; GCC is free software; you can redistribute it and/or modify"
30 1.1.1.1.4.2 yamt echo ";; it under the terms of the GNU General Public License as published by"
31 1.1.1.1.4.2 yamt echo ";; the Free Software Foundation; either version 3, or (at your option)"
32 1.1.1.1.4.2 yamt echo ";; any later version."
33 1.1.1.1.4.2 yamt echo ";;"
34 1.1.1.1.4.2 yamt echo ";; GCC is distributed in the hope that it will be useful,"
35 1.1.1.1.4.2 yamt echo ";; but WITHOUT ANY WARRANTY; without even the implied warranty of"
36 1.1.1.1.4.2 yamt echo ";; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
37 1.1.1.1.4.2 yamt echo ";; GNU General Public License for more details."
38 1.1.1.1.4.2 yamt echo ";;"
39 1.1.1.1.4.2 yamt echo ";; You should have received a copy of the GNU General Public License"
40 1.1.1.1.4.2 yamt echo ";; along with GCC; see the file COPYING3. If not see"
41 1.1.1.1.4.2 yamt echo ";; <http://www.gnu.org/licenses/>."
42 1.1.1.1.4.2 yamt
43 1.1.1.1.4.2 yamt # Loop over modes for the source operand (the index). Only 8-bit and
44 1.1.1.1.4.2 yamt # 16-bit indices are allowed.
45 1.1.1.1.4.2 yamt for s in QI HI; do
46 1.1.1.1.4.2 yamt
47 1.1.1.1.4.2 yamt # Set $src to the operand syntax for this size of index.
48 1.1.1.1.4.2 yamt case $s in
49 1.1.1.1.4.2 yamt QI) src=%X1.b;;
50 1.1.1.1.4.2 yamt HI) src=%T1.w;;
51 1.1.1.1.4.2 yamt esac
52 1.1.1.1.4.2 yamt
53 1.1.1.1.4.2 yamt # A match_operand for the source.
54 1.1.1.1.4.2 yamt operand="(match_operand:$s 1 \"h8300_dst_operand\" \"0,rQ\")"
55 1.1.1.1.4.2 yamt
56 1.1.1.1.4.2 yamt # Loop over the destination register's mode. The QI and HI versions use
57 1.1.1.1.4.2 yamt # the same instructions as the SI ones, they just ignore the upper bits
58 1.1.1.1.4.2 yamt # of the result.
59 1.1.1.1.4.2 yamt for d in QI HI SI; do
60 1.1.1.1.4.2 yamt
61 1.1.1.1.4.2 yamt # If the destination is larger than the source, include a
62 1.1.1.1.4.2 yamt # zero_extend/plus pattern. We could also match zero extensions
63 1.1.1.1.4.2 yamt # of memory without the plus, but it's not any smaller or faster
64 1.1.1.1.4.2 yamt # than separate insns.
65 1.1.1.1.4.2 yamt case $d:$s in
66 1.1.1.1.4.2 yamt SI:QI | SI:HI | HI:QI)
67 1.1.1.1.4.2 yamt cat <<EOF
68 1.1.1.1.4.2 yamt (define_insn ""
69 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r,r")
70 1.1.1.1.4.2 yamt (plus:$d (zero_extend:$d $operand)
71 1.1.1.1.4.2 yamt (match_operand:$d 2 "immediate_operand" "i,i")))]
72 1.1.1.1.4.2 yamt "TARGET_H8300SX"
73 1.1.1.1.4.2 yamt "mova/b.l @(%o2,$src),%S0"
74 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova")
75 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
76 1.1.1.1.4.2 yamt
77 1.1.1.1.4.2 yamt EOF
78 1.1.1.1.4.2 yamt ;;
79 1.1.1.1.4.2 yamt esac
80 1.1.1.1.4.2 yamt
81 1.1.1.1.4.2 yamt # Loop over the shift amount.
82 1.1.1.1.4.2 yamt for shift in 1 2; do
83 1.1.1.1.4.2 yamt case $shift in
84 1.1.1.1.4.2 yamt 1) opsize=w mult=2;;
85 1.1.1.1.4.2 yamt 2) opsize=l mult=4;;
86 1.1.1.1.4.2 yamt esac
87 1.1.1.1.4.2 yamt
88 1.1.1.1.4.2 yamt # Calculate the mask of bits that will be nonzero after the source
89 1.1.1.1.4.2 yamt # has been extended and shifted.
90 1.1.1.1.4.2 yamt case $s:$shift in
91 1.1.1.1.4.2 yamt QI:1) mask=510;;
92 1.1.1.1.4.2 yamt QI:2) mask=1020;;
93 1.1.1.1.4.2 yamt HI:1) mask=131070;;
94 1.1.1.1.4.2 yamt HI:2) mask=262140;;
95 1.1.1.1.4.2 yamt esac
96 1.1.1.1.4.2 yamt
97 1.1.1.1.4.2 yamt # There doesn't seem to be a well-established canonical form for
98 1.1.1.1.4.2 yamt # some of the patterns we need. Emit both shift and multiplication
99 1.1.1.1.4.2 yamt # patterns.
100 1.1.1.1.4.2 yamt for form in mult ashift; do
101 1.1.1.1.4.2 yamt case $form in
102 1.1.1.1.4.2 yamt mult) amount=$mult;;
103 1.1.1.1.4.2 yamt ashift) amount=$shift;;
104 1.1.1.1.4.2 yamt esac
105 1.1.1.1.4.2 yamt
106 1.1.1.1.4.2 yamt case $d:$s in
107 1.1.1.1.4.2 yamt # If the source and destination are the same size, we can treat
108 1.1.1.1.4.2 yamt # mova as a sort of multiply-add instruction.
109 1.1.1.1.4.2 yamt QI:QI | HI:HI)
110 1.1.1.1.4.2 yamt cat <<EOF
111 1.1.1.1.4.2 yamt (define_insn ""
112 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r,r")
113 1.1.1.1.4.2 yamt (plus:$d ($form:$d $operand
114 1.1.1.1.4.2 yamt (const_int $amount))
115 1.1.1.1.4.2 yamt (match_operand:$d 2 "immediate_operand" "i,i")))]
116 1.1.1.1.4.2 yamt "TARGET_H8300SX"
117 1.1.1.1.4.2 yamt "mova/$opsize.l @(%o2,$src),%S0"
118 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova")
119 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
120 1.1.1.1.4.2 yamt
121 1.1.1.1.4.2 yamt EOF
122 1.1.1.1.4.2 yamt ;;
123 1.1.1.1.4.2 yamt
124 1.1.1.1.4.2 yamt # Handle the cases where the source is smaller than the
125 1.1.1.1.4.2 yamt # destination. Sometimes combine will keep the extension,
126 1.1.1.1.4.2 yamt # sometimes it will use an AND.
127 1.1.1.1.4.2 yamt SI:QI | SI:HI | HI:QI)
128 1.1.1.1.4.2 yamt
129 1.1.1.1.4.2 yamt # Emit the forms that use zero_extend.
130 1.1.1.1.4.2 yamt cat <<EOF
131 1.1.1.1.4.2 yamt (define_insn ""
132 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r,r")
133 1.1.1.1.4.2 yamt ($form:$d (zero_extend:$d $operand)
134 1.1.1.1.4.2 yamt (const_int $amount)))]
135 1.1.1.1.4.2 yamt "TARGET_H8300SX"
136 1.1.1.1.4.2 yamt "mova/$opsize.l @(0,$src),%S0"
137 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova_zero")
138 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
139 1.1.1.1.4.2 yamt
140 1.1.1.1.4.2 yamt (define_insn ""
141 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r,r")
142 1.1.1.1.4.2 yamt (plus:$d ($form:$d (zero_extend:$d $operand)
143 1.1.1.1.4.2 yamt (const_int $amount))
144 1.1.1.1.4.2 yamt (match_operand:$d 2 "immediate_operand" "i,i")))]
145 1.1.1.1.4.2 yamt "TARGET_H8300SX"
146 1.1.1.1.4.2 yamt "mova/$opsize.l @(%o2,$src),%S0"
147 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova")
148 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
149 1.1.1.1.4.2 yamt
150 1.1.1.1.4.2 yamt EOF
151 1.1.1.1.4.2 yamt
152 1.1.1.1.4.2 yamt # Now emit the forms that use AND. When the index is a register,
153 1.1.1.1.4.2 yamt # these forms are effectively $d-mode operations: the index will
154 1.1.1.1.4.2 yamt # be a $d-mode REG or SUBREG. When the index is a memory
155 1.1.1.1.4.2 yamt # location, we will have a paradoxical subreg such as:
156 1.1.1.1.4.2 yamt #
157 1.1.1.1.4.2 yamt # (and:SI (mult:SI (subreg:SI (mem:QI ...) 0)
158 1.1.1.1.4.2 yamt # (const_int 4))
159 1.1.1.1.4.2 yamt # (const_int 1020))
160 1.1.1.1.4.2 yamt #
161 1.1.1.1.4.2 yamt # Match the two case separately: a $d-mode register_operand
162 1.1.1.1.4.2 yamt # or a $d-mode subreg of an $s-mode memory_operand. Match the
163 1.1.1.1.4.2 yamt # memory form first since register_operand accepts mem subregs
164 1.1.1.1.4.2 yamt # before reload.
165 1.1.1.1.4.2 yamt memory="(match_operand:$s 1 \"memory_operand\" \"m\")"
166 1.1.1.1.4.2 yamt memory="(subreg:$d $memory 0)"
167 1.1.1.1.4.2 yamt register="(match_operand:$d 1 \"register_operand\" \"0\")"
168 1.1.1.1.4.2 yamt for paradoxical in "$memory" "$register"; do
169 1.1.1.1.4.2 yamt cat <<EOF
170 1.1.1.1.4.2 yamt (define_insn ""
171 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r")
172 1.1.1.1.4.2 yamt (and:$d ($form:$d $paradoxical
173 1.1.1.1.4.2 yamt (const_int $amount))
174 1.1.1.1.4.2 yamt (const_int $mask)))]
175 1.1.1.1.4.2 yamt "TARGET_H8300SX"
176 1.1.1.1.4.2 yamt "mova/$opsize.l @(0,$src),%S0"
177 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova_zero")
178 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
179 1.1.1.1.4.2 yamt
180 1.1.1.1.4.2 yamt (define_insn ""
181 1.1.1.1.4.2 yamt [(set (match_operand:$d 0 "register_operand" "=r")
182 1.1.1.1.4.2 yamt (plus:$d (and:$d ($form:$d $paradoxical
183 1.1.1.1.4.2 yamt (const_int $amount))
184 1.1.1.1.4.2 yamt (const_int $mask))
185 1.1.1.1.4.2 yamt (match_operand:$d 2 "immediate_operand" "i")))]
186 1.1.1.1.4.2 yamt "TARGET_H8300SX"
187 1.1.1.1.4.2 yamt "mova/$opsize.l @(%o2,$src),%S0"
188 1.1.1.1.4.2 yamt [(set_attr "length_table" "mova")
189 1.1.1.1.4.2 yamt (set_attr "cc" "none")])
190 1.1.1.1.4.2 yamt
191 1.1.1.1.4.2 yamt EOF
192 1.1.1.1.4.2 yamt done
193 1.1.1.1.4.2 yamt ;;
194 1.1.1.1.4.2 yamt esac
195 1.1.1.1.4.2 yamt done
196 1.1.1.1.4.2 yamt done
197 1.1.1.1.4.2 yamt done
198 1.1.1.1.4.2 yamt done
199