1; Collection of macros, for GNU Binutils .cpu files. -*- Scheme -*-
2;
3; Copyright 2000, 2007, 2009 Free Software Foundation, Inc.
4;
5; Contributed by Red Hat Inc.
6;
7; This file is part of the GNU Binutils.
8;
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.
13;
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.
18;
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.
23
24; Enums.
25
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).
29
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)
33)
34
35; Define a normal insn enum.
36
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)
40)
41
42; Instruction fields.
43
44; Normally, fields are unsigned and have no encode/decode needs.
45
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)
49)
50
51; For those who don't like typing.
52
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)
56)
57(define-pmacro dnf
58  "Shorthand form of define-normal-ifield."
59  define-normal-ifield
60)
61
62; Define a normal multi-ifield.
63
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)
68)
69
70; For those who don't like typing.
71
72(define-pmacro dnmf
73  "Shorthand form of define-normal-multi-ifield."
74  define-normal-multi-ifield
75)
76
77; Simple multi-ifields: mode is UINT, default insert/extract support,
78; default encode/decode support.
79
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)
83)
84
85; Hardware.
86
87; Simpler version for most hardware elements.
88; Allow special assembler support specification but no semantic-name,
89; getter/setter, or layout specs.
90
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 () () ())
96)
97
98; For those who don't like typing.
99
100(define-pmacro dnh
101  "Shorthand form of define-normal-hardware."
102  define-normal-hardware
103)
104
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.
112
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 () () () () () ())
116)
117
118(define-pmacro dsh
119  "Shorthand form of define-simple-hardware."
120  define-simple-hardware
121)
122
123; Operands.
124
125; Simpler version for most operands.
126; Allow special assembler support specification but no handlers or
127; getter/setter specs.
128
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 () () ())
132)
133
134; For those who don't like typing.
135
136(define-pmacro dno
137  "Shorthand form of define-normal-operand."
138  define-normal-operand
139)
140
141; Deprecated, but still in wide use.
142
143(define-pmacro dnop
144  "Shorthand form of define-normal-operand."
145  define-normal-operand
146)
147
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    )
163)
164
165; Instructions.
166
167; Define an instruction object, normal version.
168; At present all fields must be specified.
169; Fields ifield-assertion is absent.
170
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)
174)
175
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. :-)
179
180(define-pmacro dni
181  "Shorthand form of define-normal-insn."
182  define-normal-insn
183)
184
185; Macro instructions.
186
187; Define a macro-insn object, normal version.
188; This only supports expanding to one real insn.
189
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)
193)
194
195; To reduce the amount of typing.
196
197(define-pmacro dnmi
198  "Shorthand form of define-normal-macro-insn."
199  define-normal-macro-insn
200)
201
202; Modes.
203; ??? Not currently available for use.
204;
205; Define Normal Mode
206;
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?)
212;)
213;
214; For those who don't like typing.
215;(define-pmacro dnm
216;  "Shorthand form of define-normal-mode.\n"
217;  define-normal-mode
218;)
219