2 # Generate mova.md, a file containing patterns that can be implemented
3 # using the h8sx mova instruction.
5 # Copyright (C) 2004-2018 Free Software Foundation, Inc.
7 # This file is part of GCC.
9 # GCC is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3, or (at your option)
14 # GCC is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GCC; see the file COPYING3. If not see
21 # <http://www.gnu.org/licenses/>.
23 echo ";; -*- buffer-read-only: t -*-"
24 echo ";; Generated automatically from genmova.sh"
25 echo ";; Copyright (C) 2004-2018 Free Software Foundation, Inc."
27 echo ";; This file is part of GCC."
29 echo ";; GCC is free software; you can redistribute it and/or modify"
30 echo ";; it under the terms of the GNU General Public License as published by"
31 echo ";; the Free Software Foundation; either version 3, or (at your option)"
32 echo ";; any later version."
34 echo ";; GCC is distributed in the hope that it will be useful,"
35 echo ";; but WITHOUT ANY WARRANTY; without even the implied warranty of"
36 echo ";; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
37 echo ";; GNU General Public License for more details."
39 echo ";; You should have received a copy of the GNU General Public License"
40 echo ";; along with GCC; see the file COPYING3. If not see"
41 echo ";; <http://www.gnu.org/licenses/>."
43 # Loop over modes for the source operand (the index). Only 8-bit and
44 # 16-bit indices are allowed.
47 # Set $src to the operand syntax for this size of index.
53 # A match_operand for the source.
54 operand
="(match_operand:$s 1 \"h8300_dst_operand\" \"0,rQ\")"
56 # Loop over the destination register's mode. The QI and HI versions use
57 # the same instructions as the SI ones, they just ignore the upper bits
61 # If the destination is larger than the source, include a
62 # zero_extend/plus pattern. We could also match zero extensions
63 # of memory without the plus, but it's not any smaller or faster
64 # than separate insns.
66 SI
:QI | SI
:HI | HI
:QI
)
69 [(set (match_operand:$d 0 "register_operand" "=r,r")
70 (plus:$d (zero_extend:$d $operand)
71 (match_operand:$d 2 "immediate_operand" "i,i")))]
73 "mova/b.l @(%o2%C2,$src),%S0"
74 [(set_attr "length_table" "mova")
75 (set_attr "cc" "none")])
81 # Loop over the shift amount.
88 # Calculate the mask of bits that will be nonzero after the source
89 # has been extended and shifted.
97 # There doesn't seem to be a well-established canonical form for
98 # some of the patterns we need. Emit both shift and multiplication
100 for form
in mult ashift
; do
103 ashift
) amount
=$shift;;
107 # If the source and destination are the same size, we can treat
108 # mova as a sort of multiply-add instruction.
112 [(set (match_operand:$d 0 "register_operand" "=r,r")
113 (plus:$d ($form:$d $operand
115 (match_operand:$d 2 "immediate_operand" "i,i")))]
117 "mova/$opsize.l @(%o2%C2,$src),%S0"
118 [(set_attr "length_table" "mova")
119 (set_attr "cc" "none")])
124 # Handle the cases where the source is smaller than the
125 # destination. Sometimes combine will keep the extension,
126 # sometimes it will use an AND.
127 SI
:QI | SI
:HI | HI
:QI
)
129 # Emit the forms that use zero_extend.
132 [(set (match_operand:$d 0 "register_operand" "=r,r")
133 ($form:$d (zero_extend:$d $operand)
134 (const_int $amount)))]
136 "mova/$opsize.l @(0,$src),%S0"
137 [(set_attr "length_table" "mova_zero")
138 (set_attr "cc" "none")])
141 [(set (match_operand:$d 0 "register_operand" "=r,r")
142 (plus:$d ($form:$d (zero_extend:$d $operand)
144 (match_operand:$d 2 "immediate_operand" "i,i")))]
146 "mova/$opsize.l @(%o2%C2,$src),%S0"
147 [(set_attr "length_table" "mova")
148 (set_attr "cc" "none")])
152 # Now emit the forms that use AND. When the index is a register,
153 # these forms are effectively $d-mode operations: the index will
154 # be a $d-mode REG or SUBREG. When the index is a memory
155 # location, we will have a paradoxical subreg such as:
157 # (and:SI (mult:SI (subreg:SI (mem:QI ...) 0)
161 # Match the two case separately: a $d-mode register_operand
162 # or a $d-mode subreg of an $s-mode memory_operand. Match the
163 # memory form first since register_operand accepts mem subregs
165 memory
="(match_operand:$s 1 \"memory_operand\" \"m\")"
166 memory
="(subreg:$d $memory 0)"
167 register
="(match_operand:$d 1 \"register_operand\" \"0\")"
168 for paradoxical
in "$memory" "$register"; do
171 [(set (match_operand:$d 0 "register_operand" "=r")
172 (and:$d ($form:$d $paradoxical
176 "mova/$opsize.l @(0,$src),%S0"
177 [(set_attr "length_table" "mova_zero")
178 (set_attr "cc" "none")])
181 [(set (match_operand:$d 0 "register_operand" "=r")
182 (plus:$d (and:$d ($form:$d $paradoxical
185 (match_operand:$d 2 "immediate_operand" "i")))]
187 "mova/$opsize.l @(%o2%C2,$src),%S0"
188 [(set_attr "length_table" "mova")
189 (set_attr "cc" "none")])