home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / t3_1 / risc_src.lha / risc_sources / comp / back_end / mipsbookkeep.t < prev    next >
Encoding:
Text File  |  1989-10-27  |  3.8 KB  |  135 lines

  1. (herald mipsbookkeep); (env t (orbit_top defs)))
  2.  
  3. ;;; Copyright (c) 1985 Yale University
  4. ;;;     Authors: N Adams, R Kelsey, D Kranz, J Philbin, J Rees.
  5. ;;; This material was developed by the T Project at the Yale University Computer 
  6. ;;; Science Department.  Permission to copy this software, to redistribute it, 
  7. ;;; and to use it for any purpose is granted, subject to the following restric-
  8. ;;; tions and understandings.
  9. ;;; 1. Any copy made of this software must include this copyright notice in full.
  10. ;;; 2. Users of this software agree to make their best efforts (a) to return
  11. ;;;    to the T Project at Yale any improvements or extensions that they make,
  12. ;;;    so that these may be included in future releases; and (b) to inform
  13. ;;;    the T Project of noteworthy uses of this software.
  14. ;;; 3. All materials developed as a consequence of the use of this software
  15. ;;;    shall duly acknowledge such use, in accordance with the usual standards
  16. ;;;    of acknowledging credit in academic research.
  17. ;;; 4. Yale has made no warrantee or representation that the operation of
  18. ;;;    this software will be error-free, and Yale is under no obligation to
  19. ;;;    provide any services, by way of maintenance, update, or otherwise.
  20. ;;; 5. In conjunction with products arising from the use of this material,
  21. ;;;    there shall be no use of the name of the Yale University nor of any
  22. ;;;    adaptation thereof in any advertising, promotional, or sales literature
  23. ;;;    without prior written consent from Yale in each case.
  24. ;;;
  25.  
  26.  
  27. (define *stack-registers* 0)
  28. (define *real-registers*
  29.   (+ *argument-registers* *stack-registers* 3)) ;an,p,an+1
  30. (define *first-stack-register* (+ *argument-registers* 3))
  31. (define AN (fx+ *argument-registers* 1))
  32. (define AN-1 (fx- AN 1))
  33. (define AN+1 (fx+ AN 1))
  34. (define *virtual-registers* 128)
  35.  
  36. (define P 0)
  37. (define A1 1)
  38. (define A2 2)
  39. (define A3 3)
  40. (define A4 4)
  41. (define A5 5)
  42. (define A6 6)
  43. (define A7 7)
  44. (define A8 8)
  45. (define A9 9)
  46. (define A10 10)
  47. (define A11 11)
  48. (define A12 12)
  49.  
  50. (define zero -1)
  51. (define extra-args -2)
  52. (define EXTRA -3)
  53. (define scratch -4)
  54. (define nil-reg -5) 
  55. (define parassign-extra -6) 
  56. (define VECTOR -7)
  57. (define t-reg -8)
  58. (define sp -9)
  59. (define link-reg -10)
  60. (define ass-reg -11)
  61. (define crit-reg -12)
  62. (define ssp -13)
  63. (define nargs scratch)
  64.  
  65. (define ($ x) (error "used $"))
  66.  
  67. (define-integrable (reg-offset x y) (cons x y))
  68.  
  69. (define (machine-true-value) t-reg)
  70.  
  71. (define (representable-fixnum? x op)                 
  72.   (and (fixnum? x)
  73.        (case op
  74.      ((move)
  75.       (and (fx>= x #x-2000)        ;will use add, 15 bits signed -2
  76.            (fx<= x #x3fff)))    ;will use or, 16 bits unsigned -2
  77.      ((and or xor)
  78.       (and (fx>= x 0)
  79.            (fx<= x #x3fff)))    ;16 bits unsigned -2
  80.      ((sub)
  81.       (and (fx> x #x-2000)        ;> not >= , may need to do add
  82.            (fx< x #x2000)))
  83.      (else
  84.       (and (fx>= x #x-2000)
  85.            (fx< x #x2000))))))
  86.  
  87. (define *max-displ* #x7fff)
  88.  
  89. (define *max-extend-displ* (- #x7fff 2))
  90.  
  91. (define (addressable? value)
  92.   (or (target-fixnum? value)
  93.       (char? value)
  94.       (eq? value '#t)
  95.       (eq? value '#F)))
  96.  
  97. (define-constant target-fixnum? fixnum?)
  98.  
  99. (define-integrable (machine-num x)
  100.   (if (fx= x 0) zero (cons 'lit x)))
  101. (define-integrable (unsigned-num x) (cons 'unsigned x))
  102.  
  103. (define (reference-addressable node x)
  104.   (xcond ((representable-fixnum? x 'move)
  105.       (machine-num (* x 4)))
  106.          ((or (fixnum? x) (char? x))
  107.       (let ((reg (get-register node)))
  108.         (generate-move-addressable x reg)
  109.         (mark x reg)
  110.         reg))
  111.      ((not x) nil-reg)
  112.      ((eq? x '#t) (machine-true-value))))
  113.  
  114.  
  115. (define-integrable (register? x)
  116.   (and (fixnum? x) (fx< x *real-registers*)))
  117.  
  118.  
  119. (define (allowed-mode? x)
  120.   (or (register? x)
  121.       (and (pair? x)
  122.        (eq? (car x) 'lit))))
  123.  
  124.  
  125. (define (arith->addressable node var op)
  126.   (cond ((representable-fixnum? var op)
  127.      (case op
  128.        ((and or xor)
  129.         (unsigned-num (fx* var 4)))
  130.        (else
  131.         (machine-num (fx* var 4)))))
  132.     (else
  133.      (->register node var))))
  134.  
  135.