Bug gas/213
[binutils.git] / cpu / simplify.inc
blob12b05b7981f6c5a98254cd4dfb9a5f69fe2688de
1 ; Collection of macros, for GNU Binutils .cpu files. -*- Scheme -*-
3 ; Copyright 2000 Free Software Foundation, Inc.
5 ; Contributed by Red Hat Inc.
7 ; This file is part of the GNU Binutils.
9 ; This program 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 2 of the License, or
12 ; (at your option) any later version.
14 ; This program 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 this program; if not, write to the Free Software
21 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 ; Enums.
25 ; Define a normal enum without using name/value pairs.
26 ; This is currently the same as define-full-enum but it needn't remain
27 ; that way (it's define-full-enum that would change).
29 (define-pmacro (define-normal-enum name comment attrs prefix vals)
30   "\
31 Define a normal enum, fixed number of arguments.
33   (define-full-enum name comment attrs prefix vals)
36 ; Define a normal insn enum.
38 (define-pmacro (define-normal-insn-enum name comment attrs prefix fld vals)
39   "\
40 Define a normal instruction opcode enum.
42   (define-full-insn-enum name comment attrs prefix fld vals)
45 ; Instruction fields.
47 ; Normally, fields are unsigned have no encode/decode needs.
49 (define-pmacro (define-normal-ifield name comment attrs start length)
50   "Define a normal instruction field.\n"
51   (define-full-ifield name comment attrs start length UINT #f #f)
54 ; For those who don't like typing.
56 (define-pmacro df
57   "Shorthand form of define-full-ifield.\n"
58   define-full-ifield
60 (define-pmacro dnf
61   "Shorthand form of define-normal-ifield.\n"
62   define-normal-ifield
65 ; Define a normal multi-ifield.
66 ; FIXME: The define-normal version for ifields doesn't include the mode.
68 (define-pmacro (define-normal-multi-ifield name comment attrs
69                  mode subflds insert extract)
70   "Define a normal multi-part instruction field.\n"
71   (define-full-multi-ifield name comment attrs mode subflds insert extract)
74 ; For those who don't like typing.
76 (define-pmacro dnmf
77   "Shorthand form of define-normal-multi-ifield.\n"
78   define-normal-multi-ifield
81 ; Simple multi-ifields: mode is UINT, default insert/extract support.
83 (define-pmacro (dsmf name comment attrs subflds)
84   "Define a simple multi-part instruction field.\n"
85   (define-full-multi-ifield name comment attrs UINT subflds #f #f)
88 ; Hardware.
90 ; Simpler version for most hardware elements.
91 ; Allow special assembler support specification but no semantic-name or
92 ; get/set specs.
94 (define-pmacro (define-normal-hardware name comment attrs type
95                  indices values handlers)
96   "\
97 Define a normal hardware element.
99   (define-full-hardware name comment attrs name type
100     indices values handlers () () ())
103 ; For those who don't like typing.
105 (define-pmacro dnh
106   "Shorthand form of define-normal-hardware.\n"
107   define-normal-hardware
110 ; Simpler version of dnh that leaves out the indices, values, handlers,
111 ; get, set, and layout specs.
112 ; This is useful for 1 bit registers.
113 ; ??? While dsh and dnh aren't that distinguishable when perusing a .cpu file,
114 ; they both take a fixed number of positional arguments, and dsh is a proper
115 ; subset of dnh with all arguments in the same positions, so methinks things
116 ; are ok.
118 (define-pmacro (define-simple-hardware name comment attrs type)
119   "\
120 Define a simple hardware element (usually a scalar register).
122   (define-full-hardware name comment attrs name type () () () () () ())
125 (define-pmacro dsh
126   "Shorthand form of define-simple-hardware.\n"
127   define-simple-hardware
130 ; Operands.
132 (define-pmacro (define-normal-operand name comment attrs type index)
133   "Define a normal operand.\n"
134   (define-full-operand name comment attrs type DFLT index () () ())
137 ; For those who don't like typing.
138 ; FIXME: dno?
140 (define-pmacro dnop
141   "Shorthand form of define-normal-operand.\n"
142   define-normal-operand
145 (define-pmacro (dndo x-name x-mode x-args
146                      x-syntax x-base-ifield x-encoding x-ifield-assertion
147                      x-getter x-setter)
148   "Define a normal derived operand."
149   (define-derived-operand
150     (name x-name)
151     (mode x-mode)
152     (args x-args)
153     (syntax x-syntax)
154     (base-ifield x-base-ifield)
155     (encoding x-encoding)
156     (ifield-assertion x-ifield-assertion)
157     (getter x-getter)
158     (setter x-setter)
159     )
162 ; Instructions.
164 ; Define an instruction object, normal version.
165 ; At present all fields must be specified.
166 ; Fields ifield-assertion is absent.
168 (define-pmacro (define-normal-insn name comment attrs syntax fmt semantics timing)
169   "Define a normal instruction.\n"
170   (define-full-insn name comment attrs syntax fmt () semantics timing)
173 ; To reduce the amount of typing.
174 ; Note that this is the same name as the D'ni in MYST.  Oooohhhh.....
175 ; this must be the right way to go. :-)
177 (define-pmacro dni
178   "Shorthand form of define-normal-insn.\n"
179   define-normal-insn
182 ; Macro instructions.
184 ; Define a macro-insn object, normal version.
185 ; This only supports expanding to one real insn.
187 (define-pmacro (define-normal-macro-insn name comment attrs syntax expansion)
188   "Define a normal macro instruction.\n"
189   (define-full-minsn name comment attrs syntax expansion)
192 ; To reduce the amount of typing.
194 (define-pmacro dnmi
195   "Shorthand form of define-normal-macro-insn.\n"
196   define-normal-macro-insn
199 ; Modes.
200 ; ??? Not currently available for use.
202 ; Define Normal Mode
204 ;(define-pmacro (define-normal-mode name comment attrs bits bytes
205 ;                non-mode-c-type printf-type sem-mode ptr-to host?)
206 ;  "Define a normal mode.\n"
207 ;  (define-full-mode name comment attrs bits bytes
208 ;    non-mode-c-type printf-type sem-mode ptr-to host?)
211 ; For those who don't like typing.
212 ;(define-pmacro dnm
213 ;  "Shorthand form of define-normal-mode.\n"
214 ;  define-normal-mode