simplify.inc 6.3 KB

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