package-defs.scm 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Mike Sperber
  3. ; The intermediate language (node tree)
  4. ; The structures VARIABLE and PRIMOP are contained in NODE. They are used
  5. ; in client language code where the NODE- names conflict.
  6. (define-structures ((node node-interface)
  7. (variable variable-interface)
  8. (primop primop-interface))
  9. (open scheme
  10. (modify big-scheme (hide table->entry-list))
  11. comp-util arch parameters
  12. defrecord)
  13. (for-syntax (open scheme big-scheme let-nodes))
  14. (begin
  15. (define-syntax let-nodes
  16. (lambda (form rename compare)
  17. (expand-let-nodes form rename compare)))
  18. (define-syntax new-lambda
  19. (lambda (form rename compare)
  20. (expand-new-lambda form rename compare)))
  21. (define-syntax new-call
  22. (lambda (form rename compare)
  23. (expand-new-call form rename compare))))
  24. (files (node node) ; variable and node data structures
  25. (node primop) ; primop data structure
  26. (node node-util) ; various small utilities
  27. (node node-equal))) ; node equality
  28. ;(define node
  29. ; (let ()
  30. ; (define-structure let-nodes (export expand-let-nodes)
  31. ; (open scheme big-scheme arch)
  32. ; (files (node let-nodes)))
  33. ; (define-structures ((node node-interface)
  34. ; (variable variable-interface)
  35. ; (primop primop-interface))
  36. ; (open scheme big-scheme comp-util arch parameters)
  37. ; (for-syntax (open scheme big-scheme let-nodes))
  38. ; (begin
  39. ; (define-syntax let-nodes
  40. ; (lambda (form rename compare)
  41. ; (expand-let-nodes form rename compare))))
  42. ; (files (node node) ; variable and node data structures
  43. ; (node primop) ; primop data structure
  44. ; (node node-util) ; various small utilities
  45. ; (node node-equal) ; node equality
  46. ; (node leftovers))) ; more node utilities
  47. ; node))
  48. ; Pretty printer
  49. (define-structure pp-cps (export pp-cps)
  50. (open scheme
  51. (modify big-scheme (hide table->entry-list))
  52. comp-util
  53. node structure-refs)
  54. (access i/o) ; force-output
  55. (files (node pp-cps)))
  56. ; Expander for LET-NODES, a macro for creating interconnected nodes.
  57. (define-structure let-nodes (export expand-let-nodes
  58. expand-new-lambda
  59. expand-new-call)
  60. (open scheme big-scheme arch)
  61. (files (node let-nodes)))
  62. ; Checker for node integrity
  63. (define-structure check-nodes (export check-node)
  64. (open scheme
  65. exceptions
  66. node
  67. comp-util)
  68. (files (node node-check)))
  69. ; Compiler Parameters
  70. ; This allows client languages to supply parameters to the compiler
  71. ; without introducing circular module dependencies.
  72. (define-structures ((parameters parameter-interface)
  73. (set-parameters (export set-compiler-parameter!)))
  74. (open scheme big-scheme)
  75. (files param))
  76. ; An enumerated type defining the standard primops.
  77. (define-structure arch (export (primop :syntax) primop-count)
  78. (open scheme enumerated)
  79. (files (node arch)))
  80. ; linearizing node trees for later reuse
  81. (define-structure node-vector (export node->vector
  82. vector->node
  83. vector->leaf-node)
  84. (open scheme
  85. (modify big-scheme (hide table->entry-list))
  86. comp-util node parameters
  87. defrecord)
  88. (files (node vector)))
  89. ; Translating the input forms into simplified node trees
  90. (define-structures ((front front-interface)
  91. (front-debug front-debug-interface))
  92. (open scheme
  93. (modify big-scheme (hide table->entry-list))
  94. comp-util node simplify parameters jump
  95. remove-cells flow-values)
  96. (files (front top))) ; main entry points and debugging utilities
  97. (define-structure cps-util (export cps-call cps-sequence)
  98. (open scheme
  99. (modify big-scheme (hide table->entry-list))
  100. comp-util node
  101. define-record-types)
  102. (files (front cps)))
  103. ; Converting tail-recursive calls to jumps
  104. (define-structure jump (export integrate-jump-procs!
  105. find-jump-procs
  106. procs->jumps)
  107. (open scheme
  108. (modify big-scheme (hide table->entry-list))
  109. comp-util
  110. (modify node (hide node?)) ; we have our own node?
  111. parameters ssa
  112. define-record-types)
  113. (files (front jump)))
  114. ; Program simplification and partial evaluation
  115. (define-structures ((simplify (export simplify-node))
  116. (simplify-internal simplify-internal-interface))
  117. (open scheme
  118. (modify big-scheme (hide table->entry-list))
  119. comp-util node parameters node-vector)
  120. (for-syntax (open scheme big-scheme simp-patterns))
  121. (begin
  122. (define-syntax pattern-simplifier
  123. (lambda (form rename compare)
  124. (make-pattern-simplifier (cdr form) rename compare))))
  125. (files (simp simplify) ; main entry point and driver
  126. (simp call))) ; simplifiers for some of the standard primops
  127. ; Simplifying calls to lambda nodes
  128. (define-structure simplify-let (export simplify-let)
  129. (open scheme
  130. (modify big-scheme (hide table->entry-list))
  131. comp-util node parameters
  132. simplify-join simplify-internal)
  133. (files (simp let)))
  134. ; Substituting lambda nodes that are bound by calls to lambda nodes,
  135. ; trying to maximize the further simplification opportunites while
  136. ; minimizing code expansion.
  137. (define-structure simplify-join (export substitute-join-arguments)
  138. (open scheme
  139. (modify big-scheme (hide table->entry-list))
  140. comp-util node)
  141. (files (simp join)))
  142. ; The expander for PATTERN-SIMPLIFIER, a macro for writing algebraic
  143. ; transformations.
  144. (define-structure simp-patterns (export make-pattern-simplifier)
  145. (open scheme big-scheme defrecord fluids)
  146. (files (simp pattern)))
  147. ; Replacing cells with values passed as parameters, currently empty
  148. ; and unused (the code has not been made compatible with the current
  149. ; version of the compiler).
  150. (define-structure remove-cells (export remove-cells-from-tree)
  151. (open scheme big-scheme)
  152. (begin
  153. (define (remove-cells-from-tree . stuff)
  154. (error "REMOVE-CELLS-FROM-TREE is undefined"))))
  155. ; Flow analysis, also currently empty and unused for the same reason.
  156. (define-structure flow-values (export flow-values)
  157. (open scheme big-scheme)
  158. (begin
  159. (define (flow-values . stuff)
  160. (error "FLOW-VALUES is undefined"))))
  161. ; A random collection of utilities.
  162. (define-structure comp-util utilities-interface
  163. (open scheme
  164. (modify big-scheme (hide table->entry-list))
  165. (modify defrecord (prefix rk:))
  166. define-record-types
  167. structure-refs expanding-vectors)
  168. (for-syntax (open scheme big-scheme))
  169. (access primitives features)
  170. (files (util syntax) ; macro for defining subrecords
  171. (util util))) ; random utilities
  172. (define-structure expanding-vectors (export make-xvector
  173. xvector-length
  174. xvector-ref
  175. xvector-set!
  176. xvector-length
  177. xvector->vector)
  178. (open scheme define-record-types)
  179. (files (util expand-vec)))
  180. (define-interface transitive-interface
  181. (export make-graph-from-predecessors
  182. make-graph-from-successors
  183. transitive-or! transitive-or-with-kill! transitive-or-with-pass!
  184. transitive-and! transitive-and-with-kill! transitive-and-with-pass!))
  185. (define-structure transitive transitive-interface
  186. (open scheme big-scheme integer-sets defrecord)
  187. (optimize auto-integrate)
  188. (files (util transitive)))
  189. (define-interface integer-set-interface
  190. (export make-empty-integer-set
  191. add-to-integer-set
  192. integer-set-not
  193. integer-set-ior
  194. integer-set-and
  195. integer-set-subtract
  196. integer-set-equal?
  197. map-over-integer-set))
  198. (define-structure integer-sets integer-set-interface
  199. (open scheme bitwise bigbit)
  200. (optimize auto-integrate)
  201. (files (util z-set)))
  202. (define-structure strongly-connected (export strongly-connected-components)
  203. (open scheme big-scheme defrecord)
  204. (optimize auto-integrate)
  205. (files (util strong)))
  206. (define-structure dominators (export find-dominators!)
  207. (open scheme
  208. (modify big-scheme (hide table->entry-list))
  209. comp-util
  210. define-record-types)
  211. (optimize auto-integrate)
  212. (files (util dominators)))
  213. (define-structure ssa (export graph->ssa-graph! find-joins)
  214. (open scheme big-scheme dominators
  215. define-record-types)
  216. (optimize auto-integrate)
  217. (files (util ssa)))
  218. ; Vectors of bytes, a renaming of Scheme 48's code vectors.
  219. (define-structure compiler-byte-vectors compiler-byte-vector-interface
  220. (open scheme byte-vectors bitwise signals)
  221. (optimize auto-integrate)
  222. (files (util byte-vector)))
  223. ; A version of READ that annotates pairs with source file, line, and
  224. ; column information.
  225. (define-structure annotated-read annotated-read-interface
  226. ; this is correct for linking, but doesn't work when loading
  227. ;(open defrecord extended-ports primitives scheme assembler)
  228. (open scheme big-scheme primitives fluids assembler)
  229. (files (prescheme track-read)))