simplify.inc revision 1.1.1.2 1 1.1 skrll ; Collection of macros, for GNU Binutils .cpu files. -*- Scheme -*-
2 1.1 skrll ;
3 1.1.1.2 christos ; Copyright 2000, 2007, 2009 Free Software Foundation, Inc.
4 1.1 skrll ;
5 1.1 skrll ; Contributed by Red Hat Inc.
6 1.1 skrll ;
7 1.1 skrll ; This file is part of the GNU Binutils.
8 1.1 skrll ;
9 1.1 skrll ; This program is free software; you can redistribute it and/or modify
10 1.1 skrll ; it under the terms of the GNU General Public License as published by
11 1.1 skrll ; the Free Software Foundation; either version 3 of the License, or
12 1.1 skrll ; (at your option) any later version.
13 1.1 skrll ;
14 1.1 skrll ; This program is distributed in the hope that it will be useful,
15 1.1 skrll ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1 skrll ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1 skrll ; GNU General Public License for more details.
18 1.1 skrll ;
19 1.1 skrll ; You should have received a copy of the GNU General Public License
20 1.1 skrll ; along with this program; if not, write to the Free Software
21 1.1 skrll ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 1.1 skrll ; MA 02110-1301, USA.
23 1.1 skrll
24 1.1 skrll ; Enums.
26 1.1 skrll
27 1.1 skrll ; Define a normal enum without using name/value pairs.
28 1.1 skrll ; This is currently the same as define-full-enum but it needn't remain
29 1.1 skrll ; that way (it's define-full-enum that would change).
30 1.1 skrll
31 1.1.1.2 christos (define-pmacro (define-normal-enum name comment attrs prefix vals)
32 1.1 skrll "Define a normal enum, fixed number of arguments."
33 1.1 skrll (define-full-enum name comment attrs prefix vals)
34 1.1 skrll )
35 1.1 skrll
36 1.1 skrll ; Define a normal insn enum.
37 1.1 skrll
38 1.1.1.2 christos (define-pmacro (define-normal-insn-enum name comment attrs prefix fld vals)
39 1.1 skrll "Define a normal instruction opcode enum."
40 1.1 skrll (define-full-insn-enum name comment attrs prefix fld vals)
41 1.1 skrll )
42 1.1 skrll
43 1.1 skrll ; Instruction fields.
45 1.1 skrll
46 1.1 skrll ; Normally, fields are unsigned and have no encode/decode needs.
47 1.1.1.2 christos
48 1.1 skrll (define-pmacro (define-normal-ifield name comment attrs start length)
49 1.1 skrll "Define a normal instruction field."
50 1.1 skrll (define-full-ifield name comment attrs start length UINT #f #f)
51 1.1 skrll )
52 1.1 skrll
53 1.1.1.2 christos ; For those who don't like typing.
54 1.1.1.2 christos
55 1.1.1.2 christos (define-pmacro (df name comment attrs start length mode encode decode)
56 1.1 skrll "Shorthand form of normal fields requiring mode, encode/decode."
57 1.1 skrll (define-full-ifield name comment attrs start length mode encode decode)
58 1.1.1.2 christos )
59 1.1 skrll (define-pmacro dnf
60 1.1 skrll "Shorthand form of define-normal-ifield."
61 1.1 skrll define-normal-ifield
62 1.1 skrll )
63 1.1 skrll
64 1.1 skrll ; Define a normal multi-ifield.
65 1.1 skrll
66 1.1.1.2 christos (define-pmacro (define-normal-multi-ifield name comment attrs
67 1.1 skrll mode subflds insert extract)
68 1.1 skrll "Define a normal multi-part instruction field."
69 1.1 skrll (define-full-multi-ifield name comment attrs mode subflds insert extract)
70 1.1 skrll )
71 1.1 skrll
72 1.1 skrll ; For those who don't like typing.
73 1.1.1.2 christos
74 1.1 skrll (define-pmacro dnmf
75 1.1 skrll "Shorthand form of define-normal-multi-ifield."
76 1.1 skrll define-normal-multi-ifield
77 1.1.1.2 christos )
78 1.1.1.2 christos
79 1.1 skrll ; Simple multi-ifields: mode is UINT, default insert/extract support,
80 1.1 skrll ; default encode/decode support.
81 1.1.1.2 christos
82 1.1 skrll (define-pmacro (dsmf name comment attrs subflds)
83 1.1 skrll "Define a simple multi-part instruction field."
84 1.1 skrll (define-full-multi-ifield name comment attrs UINT subflds #f #f)
85 1.1 skrll )
86 1.1 skrll
87 1.1 skrll ; Hardware.
89 1.1.1.2 christos
90 1.1 skrll ; Simpler version for most hardware elements.
91 1.1 skrll ; Allow special assembler support specification but no semantic-name,
92 1.1 skrll ; getter/setter, or layout specs.
93 1.1.1.2 christos
94 1.1 skrll (define-pmacro (define-normal-hardware name comment attrs type
95 1.1 skrll indices values handlers)
96 1.1 skrll "Define a normal hardware element."
97 1.1 skrll (define-full-hardware name comment attrs name type
98 1.1 skrll indices values handlers () () ())
99 1.1 skrll )
100 1.1 skrll
101 1.1.1.2 christos ; For those who don't like typing.
102 1.1 skrll
103 1.1 skrll (define-pmacro dnh
104 1.1 skrll "Shorthand form of define-normal-hardware."
105 1.1 skrll define-normal-hardware
106 1.1.1.2 christos )
107 1.1 skrll
108 1.1 skrll ; Simpler version of dnh that leaves out the indices, values, handlers,
109 1.1 skrll ; getter/setter, and layout specs.
110 1.1 skrll ; This is useful for 1 bit registers.
111 1.1 skrll ; ??? While dsh and dnh aren't that distinguishable when perusing a .cpu file,
112 1.1 skrll ; they both take a fixed number of positional arguments, and dsh is a proper
113 1.1 skrll ; subset of dnh with all arguments in the same positions, so methinks things
114 1.1.1.2 christos ; are ok.
115 1.1 skrll
116 1.1 skrll (define-pmacro (define-simple-hardware name comment attrs type)
117 1.1 skrll "Define a simple hardware element (usually a scalar register)."
118 1.1 skrll (define-full-hardware name comment attrs name type () () () () () ())
119 1.1.1.2 christos )
120 1.1 skrll
121 1.1 skrll (define-pmacro dsh
122 1.1 skrll "Shorthand form of define-simple-hardware."
123 1.1 skrll define-simple-hardware
124 1.1 skrll )
125 1.1.1.2 christos
126 1.1.1.2 christos ; Operands.
128 1.1.1.2 christos
129 1.1 skrll ; Simpler version for most operands.
130 1.1.1.2 christos ; Allow special assembler support specification but no handlers or
131 1.1 skrll ; getter/setter specs.
132 1.1 skrll
133 1.1 skrll (define-pmacro (define-normal-operand name comment attrs type index)
134 1.1 skrll "Define a normal operand."
135 1.1.1.2 christos (define-full-operand name comment attrs type DFLT index () () ())
136 1.1.1.2 christos )
137 1.1.1.2 christos
138 1.1.1.2 christos ; For those who don't like typing.
139 1.1.1.2 christos
140 1.1.1.2 christos (define-pmacro dno
141 1.1.1.2 christos "Shorthand form of define-normal-operand."
142 1.1 skrll define-normal-operand
143 1.1 skrll )
144 1.1.1.2 christos
145 1.1 skrll ; Deprecated, but still in wide use.
146 1.1 skrll
147 1.1 skrll (define-pmacro dnop
148 1.1 skrll "Shorthand form of define-normal-operand."
149 1.1 skrll define-normal-operand
150 1.1 skrll )
151 1.1 skrll
152 1.1 skrll (define-pmacro (dndo x-name x-mode x-args
153 1.1 skrll x-syntax x-base-ifield x-encoding x-ifield-assertion
154 1.1 skrll x-getter x-setter)
155 1.1 skrll "Define a normal derived operand."
156 1.1 skrll (define-derived-operand
157 1.1 skrll (name x-name)
158 1.1 skrll (mode x-mode)
159 1.1 skrll (args x-args)
160 1.1 skrll (syntax x-syntax)
161 1.1 skrll (base-ifield x-base-ifield)
162 1.1 skrll (encoding x-encoding)
163 1.1 skrll (ifield-assertion x-ifield-assertion)
164 1.1 skrll (getter x-getter)
165 1.1 skrll (setter x-setter)
166 1.1 skrll )
167 1.1 skrll )
168 1.1 skrll
169 1.1 skrll ; Instructions.
171 1.1 skrll
172 1.1.1.2 christos ; Define an instruction object, normal version.
173 1.1 skrll ; At present all fields must be specified.
174 1.1 skrll ; Fields ifield-assertion is absent.
175 1.1 skrll
176 1.1 skrll (define-pmacro (define-normal-insn name comment attrs syntax fmt semantics timing)
177 1.1 skrll "Define a normal instruction."
178 1.1 skrll (define-full-insn name comment attrs syntax fmt () semantics timing)
179 1.1 skrll )
180 1.1 skrll
181 1.1.1.2 christos ; To reduce the amount of typing.
182 1.1 skrll ; Note that this is the same name as the D'ni in MYST. Oooohhhh.....
183 1.1 skrll ; this must be the right way to go. :-)
184 1.1 skrll
185 1.1 skrll (define-pmacro dni
186 1.1 skrll "Shorthand form of define-normal-insn."
187 1.1 skrll define-normal-insn
188 1.1 skrll )
189 1.1 skrll
190 1.1 skrll ; Macro instructions.
192 1.1 skrll
193 1.1 skrll ; Define a macro-insn object, normal version.
194 1.1 skrll ; This only supports expanding to one real insn.
195 1.1 skrll
196 1.1 skrll (define-pmacro (define-normal-macro-insn name comment attrs syntax expansion)
197 1.1 skrll "Define a normal macro instruction."
198 1.1.1.2 christos (define-full-minsn name comment attrs syntax expansion)
199 1.1 skrll )
200 1.1 skrll
201 1.1 skrll ; To reduce the amount of typing.
202 1.1 skrll
203 1.1 skrll (define-pmacro dnmi
204 1.1 skrll "Shorthand form of define-normal-macro-insn."
205 1.1 skrll define-normal-macro-insn
206 1.1 skrll )
207 1.1 skrll
208 1.1 skrll ; Modes.
210 1.1 skrll ; ??? Not currently available for use.
211 1.1 skrll ;
212 1.1 skrll ; Define Normal Mode
213 1.1 skrll ;
214 1.1 skrll ;(define-pmacro (define-normal-mode name comment attrs bits bytes
215 1.1 skrll ; non-mode-c-type printf-type sem-mode ptr-to host?)
216 1.1 skrll ; "Define a normal mode.\n"
217 1.1 skrll ; (define-full-mode name comment attrs bits bytes
218 1.1 skrll ; non-mode-c-type printf-type sem-mode ptr-to host?)
219 ;)
220 ;
221 ; For those who don't like typing.
222 ;(define-pmacro dnm
223 ; "Shorthand form of define-normal-mode.\n"
224 ; define-normal-mode
225 ;)
226