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 / sparc / instr1.scm < prev    next >
Text File  |  1999-01-02  |  7KB  |  260 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: instr1.scm,v 1.2 1999/01/02 06:06:43 cph Exp $
  4.  
  5. Copyright (c) 1987-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. |#
  21.  
  22. ;;;; MIPS instruction set
  23.  
  24. ;; Branch-tensioned instructions are in instr2.scm
  25. ;; Floating point instructions are in instr3.scm
  26.  
  27. (declare (usual-integrations))
  28.  
  29. (let-syntax
  30.     ((arithmetic-immediate-instruction
  31.       (macro (keyword opcode)
  32.     `(define-instruction ,keyword
  33.        (((? destination) (? source) (? immediate))
  34.         (VARIABLE-WIDTH (evaluated-immediate immediate)
  35.           ((#x-2000 #x1fff)
  36.            (LONG (2 2)
  37.              (5 destination)
  38.              (6 ,opcode)
  39.              (5 source)
  40.              (1 1)
  41.              (13 evaluated-immediate SIGNED)))
  42.           ((() ())
  43.            ;; SETHI $1, top(immediate)
  44.            ;; OR $1, bottom(immediate)
  45.            ;; reg-op  $destination, $source, $1
  46.            (LONG (2 0)
  47.              (5 1)
  48.              (3 4)
  49.              (22 evaluated-immediate)    ; SETHI
  50.              (2 2)
  51.              (5 1)
  52.              (6 2)
  53.              (5 1)
  54.              (1 1)
  55.              (13 evaluated-immediate SIGNED) ; OR
  56.              (2 0)
  57.              (5 destination)
  58.              (6 ,opcode)
  59.              (5 source)
  60.              (1 0)
  61.              (8 0)
  62.              (5 1))))))))) ; reg-op
  63.   (arithmetic-immediate-instruction addi 0)
  64.   (arithmetic-immediate-instruction addcci 16)
  65.   (arithmetic-immediate-instruction addxi 8)
  66.   (arithmetic-immediate-instruction addxcci 24)
  67.   (arithmetic-immediate-instruction andi 1)
  68.   (arithmetic-immediate-instruction andcci 17)
  69.   (arithmetic-immediate-instruction andni 5)
  70.   (arithmetic-immediate-instruction andncci 21)
  71.   (arithmetic-immediate-instruction ori 2)
  72.   (arithmetic-immediate-instruction orcci 18)
  73.   (arithmetic-immediate-instruction orni 6)
  74.   (arithmetic-immediate-instruction orncci 22)
  75.   (arithmetic-immediate-instruction xori 3)
  76.   (arithmetic-immediate-instruction xorcci 19)
  77.   (arithmetic-immediate-instruction xnori 7)
  78.   (arithmetic-immediate-instruction xnorcc 23)
  79.   (arithmetic-immediate-instruction subi 4)
  80.   (arithmetic-immediate-instruction subcci 20)
  81.   (arithmetic-immediate-instruction subxi 12)
  82.   (arithmetic-immediate-instruction subxcci 28)
  83.   (arithmetic-immediate-instruction umuli 10)
  84.   (arithmetic-immediate-instruction smuli 11)
  85.   (arithmetic-immediate-instruction umulcci 26)
  86.   (arithmetic-immediate-instruction smulcci 27)
  87.   (arithmetic-immediate-instruction udivi 14)
  88.   (arithmetic-immediate-instruction sdivi 15)
  89.   (arithmetic-immediate-instruction udivcci 30)
  90.   (arithmetic-immediate-instruction sdivcci 31)
  91.   )
  92.  
  93.  
  94. (define-instruction lui
  95.   (((? destination) (? immediate))
  96.    (LONG (6 15)
  97.      (5 0)
  98.      (5 destination)
  99.      (16 immediate))))
  100.  
  101. (define-instruction li
  102.   (((? destination) (? immediate))
  103.    (VARIABLE-WIDTH (evaluated-immediate immediate)
  104.            ((#x-2000 #x1fff)
  105.             (LONG (2 2)
  106.               (5 destination)
  107.               (6 2)
  108.               (5 0)
  109.               (1 1)
  110.               (13 evaluated-immediate SIGNED)))
  111.            ((() ())
  112.             ;; SETHI $1, top(immediate)
  113.             ;; OR $1, bottom(immediate)
  114.             (LONG (2 0)
  115.               (5 1)
  116.               (3 4)
  117.               (22 (high-bits evaluated-immediate))    ; SETHI
  118.               (2 2)
  119.               (5 1)
  120.               (6 2)
  121.               (5 1)
  122.               (1 1)
  123.               (13 (low-bits evaluated-immediate) SIGNED) ; OR
  124.               )))))
  125.   
  126.  
  127. (let-syntax
  128.     ((3-operand-instruction
  129.       (macro (keyword opcode)
  130.     `(define-instruction ,keyword
  131.        (((? destination) (? source-1) (? source-2))
  132.         (LONG (2 2)
  133.           (5 destination)
  134.           (6 ,opcode)
  135.           (5 source-1)
  136.           (1 0)
  137.           (8 0)
  138.           (5 source-2)
  139.           ))))))
  140.   (3-operand-instruction add 0)
  141.   (3-operand-instruction addcc 16)
  142.   (3-operand-instruction addx 8)
  143.   (3-operand-instruction addxcc 24)
  144.   (3-operand-instruction andr 1)
  145.   (3-operand-instruction andcc 17)
  146.   (3-operand-instruction andn 5)
  147.   (3-operand-instruction andncc 21)
  148.   (3-operand-instruction orr 2)
  149.   (3-operand-instruction orcc 18)
  150.   (3-operand-instruction orn 6)
  151.   (3-operand-instruction orncc 22)
  152.   (3-operand-instruction xorr 3)
  153.   (3-operand-instruction xorcc 19)
  154.   (3-operand-instruction xnor 7)
  155.   (3-operand-instruction xnorcc 23)
  156.   (3-operand-instruction sllv 37)
  157.   (3-operand-instruction srlv 38)
  158.   (3-operand-instruction srav 39)
  159.   (3-operand-instruction subr 4)
  160.   (3-operand-instruction subcc 20)
  161.   (3-operand-instruction subx 12)
  162.   (3-operand-instruction umul 10)
  163.   (3-operand-instruction smul 11)
  164.   (3-operand-instruction umulcc 26)
  165.   (3-operand-instruction smulcc 27)
  166.   (3-operand-instruction udiv 14)
  167.   (3-operand-instruction sdiv 15)
  168.   (3-operand-instruction udivcc 30)
  169.   (3-operand-instruction sdivcc 31)
  170.   )
  171.   
  172.  
  173. (let-syntax
  174.     ((shift-instruction-immediate
  175.       (macro (keyword opcode)
  176.     `(define-instruction ,keyword
  177.        (((? destination) (? source) (? amount))
  178.         (LONG (2 2)
  179.           (5 destination)
  180.           (6 ,opcode)
  181.           (5 source)
  182.           (1 1)
  183.           (8 0)
  184.           (5 amount)
  185.           ))))))
  186.   (shift-instruction-immediate sll 37)
  187.   (shift-instruction-immediate srl 38)
  188.   (shift-instruction-immediate sra 39))
  189.  
  190.  
  191.  
  192. (define-instruction jalr
  193.   (((? destination) (? source))
  194.    (LONG (2 2)
  195.      (5 destination)
  196.      (6 56)
  197.      (5 source)
  198.      (1 0)
  199.      (8 0)
  200.      (5 0))))
  201.  
  202. (define-instruction jr
  203.   (((? source))
  204.    (LONG (2 2)
  205.      (5 0)
  206.      (6 56)
  207.      (5 source)
  208.      (1 0)
  209.      (8 0)
  210.      (5 0))))
  211.  
  212. (define-instruction jmpl
  213.   (((? destination) (? source1) (? source2))
  214.    (LONG (2 2)
  215.      (5 destination)
  216.      (6 56)
  217.      (5 source1)
  218.      (1 0)
  219.      (8 0)
  220.      (5 source2))))
  221.  
  222. (define-instruction call
  223.   (((? offset))
  224.    (LONG (2 1)
  225.      (30 (quotient offset 4) SIGNED))))
  226.  
  227. (define-instruction sethi
  228.   (((? destination) (? bits))
  229.    (LONG (2 0)
  230.      (5 destination)
  231.      (3 4)
  232.      (22 (top-22-bits bits) UNSIGNED))))
  233.     
  234.  
  235. ;;;; Assembler pseudo-ops
  236.  
  237. (define-instruction EXTERNAL-LABEL
  238.   ;; External labels provide the garbage collector with header
  239.   ;; information and the runtime system with type, arity, and
  240.   ;; debugging information.
  241.   (((? format-word) (@PCR (? label)))
  242.    (if (eq? endianness 'LITTLE)
  243.        (LONG (16 label BLOCK-OFFSET)
  244.          (16 format-word UNSIGNED))
  245.        (LONG (16 format-word UNSIGNED)
  246.          (16 label BLOCK-OFFSET)))))
  247.  
  248. (define-instruction NOP
  249.   ;; SETHI $0, 0
  250.   (()
  251.    (LONG (2 0)
  252.      (5 0)
  253.      (3 4)
  254.      (22 0))))
  255.  
  256. (define-instruction LONG
  257.   ((S (? value))
  258.    (LONG (32 value SIGNED)))
  259.   ((U (? value))
  260.    (LONG (32 value UNSIGNED))))