Back to index

cell-binutils  2.17cvs20070401
simplify.inc
Go to the documentation of this file.
00001 ; Collection of macros, for GNU Binutils .cpu files. -*- Scheme -*-
00002 ;
00003 ; Copyright 2000 Free Software Foundation, Inc.
00004 ;
00005 ; Contributed by Red Hat Inc.
00006 ;
00007 ; This file is part of the GNU Binutils.
00008 ;
00009 ; This program is free software; you can redistribute it and/or modify
00010 ; it under the terms of the GNU General Public License as published by
00011 ; the Free Software Foundation; either version 2 of the License, or
00012 ; (at your option) any later version.
00013 ;
00014 ; This program is distributed in the hope that it will be useful,
00015 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 ; GNU General Public License for more details.
00018 ;
00019 ; You should have received a copy of the GNU General Public License
00020 ; along with this program; if not, write to the Free Software
00021 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
00022 
00023 ; Enums.
00024 
00025 ; Define a normal enum without using name/value pairs.
00026 ; This is currently the same as define-full-enum but it needn't remain
00027 ; that way (it's define-full-enum that would change).
00028 
00029 (define-pmacro (define-normal-enum name comment attrs prefix vals)
00030   "\
00031 Define a normal enum, fixed number of arguments.
00032 "
00033   (define-full-enum name comment attrs prefix vals)
00034 )
00035 
00036 ; Define a normal insn enum.
00037 
00038 (define-pmacro (define-normal-insn-enum name comment attrs prefix fld vals)
00039   "\
00040 Define a normal instruction opcode enum.
00041 "
00042   (define-full-insn-enum name comment attrs prefix fld vals)
00043 )
00044 
00045 ; Instruction fields.
00046 
00047 ; Normally, fields are unsigned have no encode/decode needs.
00048 
00049 (define-pmacro (define-normal-ifield name comment attrs start length)
00050   "Define a normal instruction field.\n"
00051   (define-full-ifield name comment attrs start length UINT #f #f)
00052 )
00053 
00054 ; For those who don't like typing.
00055 
00056 (define-pmacro df
00057   "Shorthand form of define-full-ifield.\n"
00058   define-full-ifield
00059 )
00060 (define-pmacro dnf
00061   "Shorthand form of define-normal-ifield.\n"
00062   define-normal-ifield
00063 )
00064 
00065 ; Define a normal multi-ifield.
00066 ; FIXME: The define-normal version for ifields doesn't include the mode.
00067 
00068 (define-pmacro (define-normal-multi-ifield name comment attrs
00069                mode subflds insert extract)
00070   "Define a normal multi-part instruction field.\n"
00071   (define-full-multi-ifield name comment attrs mode subflds insert extract)
00072 )
00073 
00074 ; For those who don't like typing.
00075 
00076 (define-pmacro dnmf
00077   "Shorthand form of define-normal-multi-ifield.\n"
00078   define-normal-multi-ifield
00079 )
00080 
00081 ; Simple multi-ifields: mode is UINT, default insert/extract support.
00082 
00083 (define-pmacro (dsmf name comment attrs subflds)
00084   "Define a simple multi-part instruction field.\n"
00085   (define-full-multi-ifield name comment attrs UINT subflds #f #f)
00086 )
00087 
00088 ; Hardware.
00089 
00090 ; Simpler version for most hardware elements.
00091 ; Allow special assembler support specification but no semantic-name or
00092 ; get/set specs.
00093 
00094 (define-pmacro (define-normal-hardware name comment attrs type
00095                indices values handlers)
00096   "\
00097 Define a normal hardware element.
00098 "
00099   (define-full-hardware name comment attrs name type
00100     indices values handlers () () ())
00101 )
00102 
00103 ; For those who don't like typing.
00104 
00105 (define-pmacro dnh
00106   "Shorthand form of define-normal-hardware.\n"
00107   define-normal-hardware
00108 )
00109 
00110 ; Simpler version of dnh that leaves out the indices, values, handlers,
00111 ; get, set, and layout specs.
00112 ; This is useful for 1 bit registers.
00113 ; ??? While dsh and dnh aren't that distinguishable when perusing a .cpu file,
00114 ; they both take a fixed number of positional arguments, and dsh is a proper
00115 ; subset of dnh with all arguments in the same positions, so methinks things
00116 ; are ok.
00117 
00118 (define-pmacro (define-simple-hardware name comment attrs type)
00119   "\
00120 Define a simple hardware element (usually a scalar register).
00121 "
00122   (define-full-hardware name comment attrs name type () () () () () ())
00123 )
00124 
00125 (define-pmacro dsh
00126   "Shorthand form of define-simple-hardware.\n"
00127   define-simple-hardware
00128 )
00129 
00130 ; Operands.
00131 
00132 (define-pmacro (define-normal-operand name comment attrs type index)
00133   "Define a normal operand.\n"
00134   (define-full-operand name comment attrs type DFLT index () () ())
00135 )
00136 
00137 ; For those who don't like typing.
00138 ; FIXME: dno?
00139 
00140 (define-pmacro dnop
00141   "Shorthand form of define-normal-operand.\n"
00142   define-normal-operand
00143 )
00144 
00145 (define-pmacro (dndo x-name x-mode x-args
00146                    x-syntax x-base-ifield x-encoding x-ifield-assertion
00147                    x-getter x-setter)
00148   "Define a normal derived operand."
00149   (define-derived-operand
00150     (name x-name)
00151     (mode x-mode)
00152     (args x-args)
00153     (syntax x-syntax)
00154     (base-ifield x-base-ifield)
00155     (encoding x-encoding)
00156     (ifield-assertion x-ifield-assertion)
00157     (getter x-getter)
00158     (setter x-setter)
00159     )
00160 )
00161 
00162 ; Instructions.
00163 
00164 ; Define an instruction object, normal version.
00165 ; At present all fields must be specified.
00166 ; Fields ifield-assertion is absent.
00167 
00168 (define-pmacro (define-normal-insn name comment attrs syntax fmt semantics timing)
00169   "Define a normal instruction.\n"
00170   (define-full-insn name comment attrs syntax fmt () semantics timing)
00171 )
00172 
00173 ; To reduce the amount of typing.
00174 ; Note that this is the same name as the D'ni in MYST.  Oooohhhh.....
00175 ; this must be the right way to go. :-)
00176 
00177 (define-pmacro dni
00178   "Shorthand form of define-normal-insn.\n"
00179   define-normal-insn
00180 )
00181 
00182 ; Macro instructions.
00183 
00184 ; Define a macro-insn object, normal version.
00185 ; This only supports expanding to one real insn.
00186 
00187 (define-pmacro (define-normal-macro-insn name comment attrs syntax expansion)
00188   "Define a normal macro instruction.\n"
00189   (define-full-minsn name comment attrs syntax expansion)
00190 )
00191 
00192 ; To reduce the amount of typing.
00193 
00194 (define-pmacro dnmi
00195   "Shorthand form of define-normal-macro-insn.\n"
00196   define-normal-macro-insn
00197 )
00198 
00199 ; Modes.
00200 ; ??? Not currently available for use.
00201 ;
00202 ; Define Normal Mode
00203 ;
00204 ;(define-pmacro (define-normal-mode name comment attrs bits bytes
00205 ;              non-mode-c-type printf-type sem-mode ptr-to host?)
00206 ;  "Define a normal mode.\n"
00207 ;  (define-full-mode name comment attrs bits bytes
00208 ;    non-mode-c-type printf-type sem-mode ptr-to host?)
00209 ;)
00210 ;
00211 ; For those who don't like typing.
00212 ;(define-pmacro dnm
00213 ;  "Shorthand form of define-normal-mode.\n"
00214 ;  define-normal-mode
00215 ;)