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