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