* bucomm.c (make_tempname): Stop memory leak.
[binutils.git] / cpu / simplify.inc
blob808018dc83ddae2ef47eeed6818d78b176b8f524
1 ; Collection of macros, for GNU Binutils .cpu files. -*- Scheme -*-
3 ; Copyright 2000, 2007, 2009 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
22 ; MA 02110-1301, USA.
24 ; Enums.
26 ; Define a normal enum without using name/value pairs.
27 ; This is currently the same as define-full-enum but it needn't remain
28 ; that way (it's define-full-enum that would change).
30 (define-pmacro (define-normal-enum name comment attrs prefix vals)
31   "Define a normal enum, fixed number of arguments."
32   (define-full-enum name comment attrs prefix vals)
35 ; Define a normal insn enum.
37 (define-pmacro (define-normal-insn-enum name comment attrs prefix fld vals)
38   "Define a normal instruction opcode enum."
39   (define-full-insn-enum name comment attrs prefix fld vals)
42 ; Instruction fields.
44 ; Normally, fields are unsigned and have no encode/decode needs.
46 (define-pmacro (define-normal-ifield name comment attrs start length)
47   "Define a normal instruction field."
48   (define-full-ifield name comment attrs start length UINT #f #f)
51 ; For those who don't like typing.
53 (define-pmacro (df name comment attrs start length mode encode decode)
54   "Shorthand form of normal fields requiring mode, encode/decode."
55   (define-full-ifield name comment attrs start length mode encode decode)
57 (define-pmacro dnf
58   "Shorthand form of define-normal-ifield."
59   define-normal-ifield
62 ; Define a normal multi-ifield.
64 (define-pmacro (define-normal-multi-ifield name comment attrs
65                  mode subflds insert extract)
66   "Define a normal multi-part instruction field."
67   (define-full-multi-ifield name comment attrs mode subflds insert extract)
70 ; For those who don't like typing.
72 (define-pmacro dnmf
73   "Shorthand form of define-normal-multi-ifield."
74   define-normal-multi-ifield
77 ; Simple multi-ifields: mode is UINT, default insert/extract support,
78 ; default encode/decode support.
80 (define-pmacro (dsmf name comment attrs subflds)
81   "Define a simple multi-part instruction field."
82   (define-full-multi-ifield name comment attrs UINT subflds #f #f)
85 ; Hardware.
87 ; Simpler version for most hardware elements.
88 ; Allow special assembler support specification but no semantic-name,
89 ; getter/setter, or layout specs.
91 (define-pmacro (define-normal-hardware name comment attrs type
92                  indices values handlers)
93   "Define a normal hardware element."
94   (define-full-hardware name comment attrs name type
95     indices values handlers () () ())
98 ; For those who don't like typing.
100 (define-pmacro dnh
101   "Shorthand form of define-normal-hardware."
102   define-normal-hardware
105 ; Simpler version of dnh that leaves out the indices, values, handlers,
106 ; getter/setter, and layout specs.
107 ; This is useful for 1 bit registers.
108 ; ??? While dsh and dnh aren't that distinguishable when perusing a .cpu file,
109 ; they both take a fixed number of positional arguments, and dsh is a proper
110 ; subset of dnh with all arguments in the same positions, so methinks things
111 ; are ok.
113 (define-pmacro (define-simple-hardware name comment attrs type)
114   "Define a simple hardware element (usually a scalar register)."
115   (define-full-hardware name comment attrs name type () () () () () ())
118 (define-pmacro dsh
119   "Shorthand form of define-simple-hardware."
120   define-simple-hardware
123 ; Operands.
125 ; Simpler version for most operands.
126 ; Allow special assembler support specification but no handlers or
127 ; getter/setter specs.
129 (define-pmacro (define-normal-operand name comment attrs type index)
130   "Define a normal operand."
131   (define-full-operand name comment attrs type DFLT index () () ())
134 ; For those who don't like typing.
136 (define-pmacro dno
137   "Shorthand form of define-normal-operand."
138   define-normal-operand
141 ; Deprecated, but still in wide use.
143 (define-pmacro dnop
144   "Shorthand form of define-normal-operand."
145   define-normal-operand
148 (define-pmacro (dndo x-name x-mode x-args
149                      x-syntax x-base-ifield x-encoding x-ifield-assertion
150                      x-getter x-setter)
151   "Define a normal derived operand."
152   (define-derived-operand
153     (name x-name)
154     (mode x-mode)
155     (args x-args)
156     (syntax x-syntax)
157     (base-ifield x-base-ifield)
158     (encoding x-encoding)
159     (ifield-assertion x-ifield-assertion)
160     (getter x-getter)
161     (setter x-setter)
162     )
165 ; Instructions.
167 ; Define an instruction object, normal version.
168 ; At present all fields must be specified.
169 ; Fields ifield-assertion is absent.
171 (define-pmacro (define-normal-insn name comment attrs syntax fmt semantics timing)
172   "Define a normal instruction."
173   (define-full-insn name comment attrs syntax fmt () semantics timing)
176 ; To reduce the amount of typing.
177 ; Note that this is the same name as the D'ni in MYST.  Oooohhhh.....
178 ; this must be the right way to go. :-)
180 (define-pmacro dni
181   "Shorthand form of define-normal-insn."
182   define-normal-insn
185 ; Macro instructions.
187 ; Define a macro-insn object, normal version.
188 ; This only supports expanding to one real insn.
190 (define-pmacro (define-normal-macro-insn name comment attrs syntax expansion)
191   "Define a normal macro instruction."
192   (define-full-minsn name comment attrs syntax expansion)
195 ; To reduce the amount of typing.
197 (define-pmacro dnmi
198   "Shorthand form of define-normal-macro-insn."
199   define-normal-macro-insn
202 ; Modes.
203 ; ??? Not currently available for use.
205 ; Define Normal Mode
207 ;(define-pmacro (define-normal-mode name comment attrs bits bytes
208 ;                non-mode-c-type printf-type sem-mode ptr-to host?)
209 ;  "Define a normal mode.\n"
210 ;  (define-full-mode name comment attrs bits bytes
211 ;    non-mode-c-type printf-type sem-mode ptr-to host?)
214 ; For those who don't like typing.
215 ;(define-pmacro dnm
216 ;  "Shorthand form of define-normal-mode.\n"
217 ;  define-normal-mode