1 ; Collection of macros to simplify .cpu file writing. -*- Scheme -*-
2 ; Copyright (C) 2000, 2009 Red Hat, Inc.
3 ; This file is part of CGEN.
4 ; See file COPYING.CGEN for details.
8 ; Define a normal enum without using name/value pairs.
9 ; This is currently the same as define-full-enum but it needn't remain
10 ; that way (it's define-full-enum that would change).
12 (define-pmacro (define-normal-enum name comment attrs prefix vals)
13 "Define a normal enum, fixed number of arguments."
14 (define-full-enum name comment attrs prefix vals)
17 ; Define a normal insn enum.
19 (define-pmacro (define-normal-insn-enum name comment attrs prefix fld vals)
20 "Define a normal instruction opcode enum."
21 (define-full-insn-enum name comment attrs prefix fld vals)
26 ; Normally, fields are unsigned and have no encode/decode needs.
28 (define-pmacro (define-normal-ifield name comment attrs start length)
29 "Define a normal instruction field."
30 (define-full-ifield name comment attrs start length UINT #f #f)
33 ; For those who don't like typing.
35 (define-pmacro (df name comment attrs start length mode encode decode)
36 "Shorthand form of normal fields requiring mode, encode/decode."
37 (define-full-ifield name comment attrs start length mode encode decode)
40 "Shorthand form of define-normal-ifield."
44 ; Define a normal multi-ifield.
46 (define-pmacro (define-normal-multi-ifield name comment attrs
47 mode subflds insert extract)
48 "Define a normal multi-part instruction field."
49 (define-full-multi-ifield name comment attrs mode subflds insert extract)
52 ; For those who don't like typing.
55 "Shorthand form of define-normal-multi-ifield."
56 define-normal-multi-ifield
59 ; Simple multi-ifields: mode is UINT, default insert/extract support,
60 ; default encode/decode support.
62 (define-pmacro (dsmf name comment attrs subflds)
63 "Define a simple multi-part instruction field."
64 (define-full-multi-ifield name comment attrs UINT subflds #f #f)
69 ; Simpler version for most hardware elements.
70 ; Allow special assembler support specification but no semantic-name,
71 ; getter/setter, or layout specs.
73 (define-pmacro (define-normal-hardware name comment attrs type
74 indices values handlers)
75 "Define a normal hardware element."
76 (define-full-hardware name comment attrs name type
77 indices values handlers () () ())
80 ; For those who don't like typing.
83 "Shorthand form of define-normal-hardware."
84 define-normal-hardware
87 ; Simpler version of dnh that leaves out the indices, values, handlers,
88 ; getter/setter, and layout specs.
89 ; This is useful for 1 bit registers.
90 ; ??? While dsh and dnh aren't that distinguishable when perusing a .cpu file,
91 ; they both take a fixed number of positional arguments, and dsh is a proper
92 ; subset of dnh with all arguments in the same positions, so methinks things
95 (define-pmacro (define-simple-hardware name comment attrs type)
96 "Define a simple hardware element (usually a scalar register)."
97 (define-full-hardware name comment attrs name type () () () () () ())
101 "Shorthand form of define-simple-hardware."
102 define-simple-hardware
107 ; Simpler version for most operands.
108 ; Allow special assembler support specification but no handlers or
109 ; getter/setter specs.
111 (define-pmacro (define-normal-operand name comment attrs type index)
112 "Define a normal operand."
113 (define-full-operand name comment attrs type DFLT index () () ())
116 ; For those who don't like typing.
119 "Shorthand form of define-normal-operand."
120 define-normal-operand
123 ; Deprecated, but still in wide use.
126 "Shorthand form of define-normal-operand."
127 define-normal-operand
130 (define-pmacro (dndo x-name x-mode x-args
131 x-syntax x-base-ifield x-encoding x-ifield-assertion
133 "Define a normal derived operand."
134 (define-derived-operand
139 (base-ifield x-base-ifield)
140 (encoding x-encoding)
141 (ifield-assertion x-ifield-assertion)
149 ; Define an instruction object, normal version.
150 ; At present all fields must be specified.
151 ; Fields ifield-assertion is absent.
153 (define-pmacro (define-normal-insn name comment attrs syntax fmt semantics timing)
154 "Define a normal instruction."
155 (define-full-insn name comment attrs syntax fmt () semantics timing)
158 ; To reduce the amount of typing.
159 ; Note that this is the same name as the D'ni in MYST. Oooohhhh.....
160 ; this must be the right way to go. :-)
163 "Shorthand form of define-normal-insn."
167 ; Macro instructions.
169 ; Define a macro-insn object, normal version.
170 ; This only supports expanding to one real insn.
172 (define-pmacro (define-normal-macro-insn name comment attrs syntax expansion)
173 "Define a normal macro instruction."
174 (define-full-minsn name comment attrs syntax expansion)
177 ; To reduce the amount of typing.
180 "Shorthand form of define-normal-macro-insn."
181 define-normal-macro-insn
185 ; ??? Not currently available for use.
189 ;(define-pmacro (define-normal-mode name comment attrs bits bytes
190 ; non-mode-c-type printf-type sem-mode ptr-to host?)
191 ; "Define a normal mode.\n"
192 ; (define-full-mode name comment attrs bits bytes
193 ; non-mode-c-type printf-type sem-mode ptr-to host?)
196 ; For those who don't like typing.
198 ; "Shorthand form of define-normal-mode.\n"