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