compiler.texi 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. @node Invoking the Pre-Scheme compiler
  2. @section Invoking the Pre-Scheme compiler
  3. Richard Kelsey's Pre-Scheme compiler is a whole-program compiler based
  4. on techniques from his research in transformational compilation
  5. [Kelsey 89]. It compiles the restricted dialect of Scheme to efficient
  6. C, and provides facilities for programmer direction in several
  7. optimizations.
  8. @subsection Loading the compiler
  9. There is a script, a Scheme48 @embedref{Command programs, command
  10. program}, that comes with Scheme48 to load the Pre-Scheme compiler,
  11. which is in the file @file{ps-compiler/load-ps-compiler.scm}. It must
  12. be loaded from the @file{ps-compiler/} directory, from Scheme48's main
  13. distribution, into the @code{exec} package, after having loaded
  14. @file{../scheme/prescheme/interface.scm} &
  15. @file{../scheme/prescheme/package-defs.scm} into the @code{config}
  16. package. The Pre-Scheme compiler takes some time to load, so it may be
  17. easier to load it once and dump a heap image of the suspended command
  18. processor after having loaded everything; @pxref{Image-building
  19. commands}.
  20. To load the Pre-Scheme compiler and dump an image to the file
  21. @file{ps-compiler.image} that contains @code{prescheme-compiler} in the
  22. user package, send this sequence of commands to the command processor
  23. while in the @file{ps-compiler/} directory of Scheme48's distribution:
  24. @lisp
  25. ,config ,load ../scheme/prescheme/interface.scm
  26. ,config ,load ../scheme/prescheme/package-defs.scm
  27. ,exec ,load load-ps-compiler.scm
  28. ,in prescheme-compiler prescheme-compiler
  29. ,user (define prescheme-compiler ##)
  30. ,dump ps-compiler.image "(Pre-Scheme)"@end lisp
  31. @subsection Calling the compiler
  32. @stindex prescheme-compiler
  33. After having loaded the Pre-Scheme compiler, the
  34. @code{prescheme-compiler} structure is the front end to the compiler
  35. that exports the @code{prescheme-compiler} procedure.
  36. @deffn procedure prescheme-compiler structure-spec config-filenames init-name c-filename command @dots{}
  37. Invokes the Pre-Scheme compiler. @var{Config-filenames} contain module
  38. descriptions (@pxref{Module system}) for the components of the program.
  39. @var{Structure-spec} may be a symbol or a list of symbols, naming the
  40. important structure or structures. All structures that it relies/they
  41. rely on are traced in the packages' @code{open} clauses. Modules that
  42. are not traced in the dependency graph with root vertices of the given
  43. structure[s] are omitted from the output. @var{C-filename} is a string
  44. naming the file to which the C code generated by the Pre-Scheme
  45. compiler should be emitted. @var{Init-name} is the name for an
  46. initialization routine, generated automatically by the Pre-Scheme
  47. compiler to initialize some top-level variables. The @var{command}
  48. arguments are used to control certain aspects of the compilation. The
  49. following commands are defined:
  50. @table @code
  51. @item (copy (@var{structure} @var{copyable-procedure}) @dots{})
  52. Specifies that each the body of each @var{copyable-procedure} from the
  53. respective @var{structure} (from one of @var{config-filenames}) may be
  54. integrated & duplicated.
  55. @item (no-copy (@var{structure} @var{uncopyable-procedure}) @dots{})
  56. Specifies that the given procedures may not be integrated.
  57. @item (shadow ((@var{proc-structure} @var{procedure}) (@var{var-structure} @var{variable-to-shadow}) @dots{}) @dots{})
  58. Specifies that, in @var{procedure} from @var{proc-structure}, the
  59. global variables @var{variable-to-shadow} from their respective
  60. @var{var-structure}s should be shadowed with local variables, which
  61. are more likely to be kept in registers for faster operation on them.
  62. @item (integrate (@var{client-procedure} @var{integrable-procedure}) @dots{})
  63. Forces @var{integrable-procedure} to be integrated in
  64. @var{client-procedure}.
  65. @strong{Note:} The @code{integrate} command operates on the global
  66. program, not on one particular module; each @var{client-procedure} and
  67. @var{integrable-procedure} is chosen from all variables defined in the
  68. entirety of the program, across all modules. It is advised that there
  69. be only one of each.
  70. @item (header @var{header-line} @dots{})
  71. Each @var{header-line} is added to the top of the generated C file,
  72. after a cpp inclusion of @code{<stdio.h>} and @code{"prescheme.h"}.
  73. @end table
  74. The command arguments to @code{prescheme-compiler} are optional; they
  75. are used only to optimize the compiled program at the programmer's
  76. request.
  77. @end deffn