platform.scm 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ;;; Ported from Scheme 48 1.9. See file COPYING for notices and license.
  2. ;;;
  3. ;;; Port Author: Andrew Whatson
  4. ;;;
  5. ;;; Original Authors: Richard Kelsey, Jonathan Rees, Marcus Crestani, David Frese
  6. ;;;
  7. ;;; scheme48-1.9.2/scheme/platform-interfaces.scm
  8. ;;; scheme48-1.9.2/scheme/vm/data/platform-32.scm
  9. ;;; scheme48-1.9.2/scheme/vm/data/platform-64.scm
  10. ;;;
  11. ;;; Essential constants for 32/64-bit platforms.
  12. ;;;
  13. (define-module (prescheme platform)
  14. #:use-module (system base target)
  15. #:export (bytes-per-cell
  16. log-bytes-per-cell
  17. bits-per-byte
  18. bits-per-cell
  19. addressing-units-per-cell
  20. c-useful-bits-per-word
  21. s48-useful-bits-per-word
  22. unused-field-width
  23. tag-field-width
  24. data-field-width
  25. immediate-type-field-width
  26. pre-scheme-integer-size))
  27. ;; Fundamental parameters
  28. (define 64bit? (>= (target-word-size) 8))
  29. (define bytes-per-cell (if 64bit? 8 4))
  30. (define log-bytes-per-cell (if 64bit? 3 2))
  31. (define bits-per-byte 8)
  32. (define bits-per-cell (* bits-per-byte bytes-per-cell))
  33. (define addressing-units-per-cell bytes-per-cell)
  34. ;; This is actually the mimimum for the different PreScheme implementations.
  35. ;; The Scheme version of PreScheme leaves 30 bits for PreScheme's fixnums.
  36. ;; There have to be enough bits to represent the largest fixnum in the system.
  37. ;; USEFUL-BITS-PER-WORD is not written in the image.
  38. (define s48-useful-bits-per-word (if 64bit? 62 30)) ; in Scheme48
  39. (define c-useful-bits-per-word (if 64bit? 64 32)) ; when compiled
  40. ;; Addresses
  41. ;;
  42. ;; An "addressing unit" is the smallest quantum of storage addressed by
  43. ;; an address on a particular machine. On a DEC-20, 3600, or other
  44. ;; word-addressed architecture there is one addressing unit per cell. On
  45. ;; the VAX or 68000, though, the addressing unit is the byte, of which there
  46. ;; are 4 to a cell.
  47. ;;
  48. ;; Note: by a "byte" is meant enough bits to store a bytecode. That
  49. ;; probably means either 7, 8, or 9 bits.
  50. ;;
  51. ;; If the addressing unit is smaller than a cell each address will have some
  52. ;; number of "unused bits" at its low end. On a byte-addressable machine with
  53. ;; 32 bit addresses, there are two.
  54. (define unused-field-width log-bytes-per-cell)
  55. ;; Descriptors
  56. ;; A descriptor describes a Scheme object.
  57. ;; A descriptor is represented as an integer whose low two bits are
  58. ;; tag bits. The high bits contain information whose format and
  59. ;; meaning are dependent on the tag.
  60. (define tag-field-width 2)
  61. (define data-field-width (- bits-per-cell tag-field-width))
  62. ;; Immediates
  63. ;; This streamlines 8-bit-byte-oriented implementations.
  64. (define immediate-type-field-width
  65. (- bits-per-byte tag-field-width))
  66. ;; Pre-Scheme
  67. (define pre-scheme-integer-size bits-per-cell)