home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / compiler / machines / spectrum / rules2.scm < prev    next >
Encoding:
Text File  |  1999-01-02  |  3.4 KB  |  94 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: rules2.scm,v 4.15 1999/01/02 06:06:43 cph Exp $
  4. $MC68020-Header: rules2.scm,v 4.12 90/01/18 22:44:04 GMT cph Exp $
  5.  
  6. Copyright (c) 1988-1999 Massachusetts Institute of Technology
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or (at
  11. your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful, but
  14. WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. |#
  22.  
  23. ;;;; LAP Generation Rules: Predicates
  24.  
  25. (declare (usual-integrations))
  26.  
  27. (define-rule predicate
  28.   ;; test for two registers EQ?
  29.   (EQ-TEST (REGISTER (? source1)) (REGISTER (? source2)))
  30.   (compare '= (standard-source! source1) (standard-source! source2)))
  31.  
  32. (define-rule predicate
  33.   (EQ-TEST (MACHINE-CONSTANT 0) (REGISTER (? register)))
  34.   (compare-immediate '= 0 (standard-source! register)))
  35.  
  36. (define-rule predicate
  37.   (EQ-TEST (REGISTER (? register)) (MACHINE-CONSTANT 0))
  38.   (compare-immediate '= 0 (standard-source! register)))
  39.  
  40. (define-rule predicate
  41.   ;; test for register EQ? to constant
  42.   (EQ-TEST (CONSTANT (? constant)) (REGISTER (? register)))
  43.   (eq-test/constant*register constant register))
  44.  
  45. (define-rule predicate
  46.   ;; test for register EQ? to constant
  47.   (EQ-TEST (REGISTER (? register)) (CONSTANT (? constant)))
  48.   (eq-test/constant*register constant register))
  49.  
  50. (define (eq-test/constant*register constant source)
  51.   (let ((source (standard-source! source)))
  52.     (if (non-pointer-object? constant)
  53.     (compare-immediate '= (non-pointer->literal constant) source)
  54.     (let ((temp (standard-temporary!)))
  55.       (LAP ,@(load-constant constant temp)
  56.            ,@(compare '= temp source))))))
  57.  
  58. (define-rule predicate
  59.   ;; test for register EQ? to synthesized constant
  60.   (EQ-TEST (CONS-POINTER (MACHINE-CONSTANT (? type))
  61.              (MACHINE-CONSTANT (? datum)))
  62.        (REGISTER (? register)))
  63.   (eq-test/synthesized-constant*register type datum register))
  64.  
  65. (define-rule predicate
  66.   ;; test for register EQ? to synthesized constant
  67.   (EQ-TEST (REGISTER (? register))
  68.        (CONS-POINTER (MACHINE-CONSTANT (? type))
  69.              (MACHINE-CONSTANT (? datum))))
  70.   (eq-test/synthesized-constant*register type datum register))
  71.  
  72. (define (eq-test/synthesized-constant*register type datum source)
  73.   (compare-immediate '=
  74.              (make-non-pointer-literal type datum)
  75.              (standard-source! source)))
  76.  
  77. (define-rule predicate
  78.   ;; Branch if virtual register contains the specified type number
  79.   (TYPE-TEST (REGISTER (? register)) (? type))
  80.   (compare-immediate '= type (standard-source! register)))
  81.  
  82.  
  83. ;; Combine tests for fixnum and non-negative by extracting the type
  84. ;; bits and the sign bit.
  85.  
  86. (define-rule predicate
  87.   (PRED-1-ARG INDEX-FIXNUM?
  88.           (REGISTER (? source)))
  89.   (let ((src (standard-source! source)))
  90.     (let ((temp (standard-temporary!)))
  91.       (LAP (EXTRU () ,src ,(- scheme-type-width 0) ,(+ scheme-type-width 1)
  92.           ,temp)
  93.        ,@(compare-immediate '= (* 2 (ucode-type fixnum)) temp)))))
  94.