OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [cpu/] [sh.cpu] - Diff between revs 156 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 156 Rev 816
; Hitachi SH architecture description.  -*- Scheme -*-
; Hitachi SH architecture description.  -*- Scheme -*-
;
;
; Copyright 2000, 2001, 2007 Free Software Foundation, Inc.
; Copyright 2000, 2001, 2007 Free Software Foundation, Inc.
;
;
; Contributed by Red Hat Inc; developed under contract from Hitachi
; Contributed by Red Hat Inc; developed under contract from Hitachi
; Semiconductor (America) Inc.
; Semiconductor (America) Inc.
;
;
; This file is part of the GNU Binutils.
; This file is part of the GNU Binutils.
;
;
; This program is free software; you can redistribute it and/or modify
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 3 of the License, or
; the Free Software Foundation; either version 3 of the License, or
; (at your option) any later version.
; (at your option) any later version.
;
;
; This program is distributed in the hope that it will be useful,
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
; GNU General Public License for more details.
;
;
; You should have received a copy of the GNU General Public License
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
; MA 02110-1301, USA.
; MA 02110-1301, USA.
(include "simplify.inc")
(include "simplify.inc")
(define-arch
(define-arch
  (name sh)
  (name sh)
  (comment "Hitachi SuperH (SH)")
  (comment "Hitachi SuperH (SH)")
  (insn-lsb0? #t)
  (insn-lsb0? #t)
  (machs sh2 sh3 sh3e sh4 sh5)
  (machs sh2 sh3 sh3e sh4 sh5)
  (isas compact media)
  (isas compact media)
)
)


; Instruction sets.
; Instruction sets.
(define-isa
(define-isa
  (name media)
  (name media)
  (comment "SHmedia 32-bit instruction set")
  (comment "SHmedia 32-bit instruction set")
  (base-insn-bitsize 32)
  (base-insn-bitsize 32)
)
)
(define-isa
(define-isa
  (name compact)
  (name compact)
  (comment "SHcompact 16-bit instruction set")
  (comment "SHcompact 16-bit instruction set")
  (base-insn-bitsize 16)
  (base-insn-bitsize 16)
)
)


; CPU family.
; CPU family.
(define-cpu
(define-cpu
  (name sh64)
  (name sh64)
  (comment "SH 64-bit family")
  (comment "SH 64-bit family")
  (endian either)
  (endian either)
  (word-bitsize 32)
  (word-bitsize 32)
)
)


(define-mach
(define-mach
  (name sh2)
  (name sh2)
  (comment "SH-2 CPU core")
  (comment "SH-2 CPU core")
  (cpu sh64)
  (cpu sh64)
  (isas compact)
  (isas compact)
)
)
(define-mach
(define-mach
  (name sh3)
  (name sh3)
  (comment "SH-3 CPU core")
  (comment "SH-3 CPU core")
  (cpu sh64)
  (cpu sh64)
  (isas compact)
  (isas compact)
)
)
(define-mach
(define-mach
  (name sh3e)
  (name sh3e)
  (comment "SH-3e CPU core")
  (comment "SH-3e CPU core")
  (cpu sh64)
  (cpu sh64)
  (isas compact)
  (isas compact)
)
)
(define-mach
(define-mach
  (name sh4)
  (name sh4)
  (comment "SH-4 CPU core")
  (comment "SH-4 CPU core")
  (cpu sh64)
  (cpu sh64)
  (isas compact)
  (isas compact)
)
)
(define-mach
(define-mach
  (name sh5)
  (name sh5)
  (comment "SH-5 CPU core")
  (comment "SH-5 CPU core")
  (cpu sh64)
  (cpu sh64)
  (isas compact media)
  (isas compact media)
)
)
(define-model
(define-model
  (name sh5)
  (name sh5)
  (comment "SH-5 reference implementation")
  (comment "SH-5 reference implementation")
  (mach sh5)
  (mach sh5)
  (unit u-exec "Execution unit" ()
  (unit u-exec "Execution unit" ()
        1 1 ; issue done
        1 1 ; issue done
        () () () ())
        () () () ())
)
)


; Hardware elements.
; Hardware elements.
(define-hardware
(define-hardware
  (name h-pc)
  (name h-pc)
  (comment "Program counter")
  (comment "Program counter")
  (attrs PC (ISA compact,media))
  (attrs PC (ISA compact,media))
  (type pc UDI)
  (type pc UDI)
  (get () (raw-reg h-pc))
  (get () (raw-reg h-pc))
  (set (newval) (sequence ()
  (set (newval) (sequence ()
                          (set (raw-reg h-ism) (and newval 1))
                          (set (raw-reg h-ism) (and newval 1))
                          (set (raw-reg h-pc) (and newval (inv UDI 1)))))
                          (set (raw-reg h-pc) (and newval (inv UDI 1)))))
)
)
(define-pmacro (-build-greg-name n) ((.sym r n) n))
(define-pmacro (-build-greg-name n) ((.sym r n) n))
(define-hardware
(define-hardware
  (name h-gr)
  (name h-gr)
  (comment "General purpose integer registers")
  (comment "General purpose integer registers")
  (attrs (ISA media,compact))
  (attrs (ISA media,compact))
  (type register DI (64))
  (type register DI (64))
  (indices keyword "" (.map -build-greg-name (.iota 64)))
  (indices keyword "" (.map -build-greg-name (.iota 64)))
  (get (index)
  (get (index)
       (if DI (eq index 63)
       (if DI (eq index 63)
           (const 0)
           (const 0)
           (raw-reg h-gr index)))
           (raw-reg h-gr index)))
  (set (index newval)
  (set (index newval)
       (if (ne index 63)
       (if (ne index 63)
           (set (raw-reg h-gr index) newval)
           (set (raw-reg h-gr index) newval)
           (nop)))
           (nop)))
)
)
(define-hardware
(define-hardware
  (name h-grc)
  (name h-grc)
  (comment "General purpose integer registers (SHcompact view)")
  (comment "General purpose integer registers (SHcompact view)")
  (attrs VIRTUAL (ISA compact))
  (attrs VIRTUAL (ISA compact))
  (type register SI (16))
  (type register SI (16))
  (indices keyword "" (.map -build-greg-name (.iota 16)))
  (indices keyword "" (.map -build-greg-name (.iota 16)))
  (get (index)
  (get (index)
        (and (raw-reg h-gr index) (zext DI #xFFFFFFFF)))
        (and (raw-reg h-gr index) (zext DI #xFFFFFFFF)))
  (set (index newval)
  (set (index newval)
       (set (raw-reg h-gr index) (ext DI newval)))
       (set (raw-reg h-gr index) (ext DI newval)))
)
)
(define-pmacro (-build-creg-name n) ((.sym cr n) n))
(define-pmacro (-build-creg-name n) ((.sym cr n) n))
(define-hardware
(define-hardware
  (name h-cr)
  (name h-cr)
  (comment "Control registers")
  (comment "Control registers")
  (attrs (ISA media))
  (attrs (ISA media))
  (type register DI (64))
  (type register DI (64))
  (indices keyword "" (.map -build-creg-name (.iota 64)))
  (indices keyword "" (.map -build-creg-name (.iota 64)))
  (get (index)
  (get (index)
       (if DI (eq index 0)
       (if DI (eq index 0)
           (zext DI (reg h-sr))
           (zext DI (reg h-sr))
           (raw-reg h-cr index)))
           (raw-reg h-cr index)))
  (set (index newval)
  (set (index newval)
       (if (eq index 0)
       (if (eq index 0)
           (set (reg h-sr) newval)
           (set (reg h-sr) newval)
           (set (raw-reg h-cr index) newval)))
           (set (raw-reg h-cr index) newval)))
)
)
(define-hardware
(define-hardware
  (name h-sr)
  (name h-sr)
  (comment "Status register")
  (comment "Status register")
  (attrs (ISA compact,media))
  (attrs (ISA compact,media))
  (type register SI)
  (type register SI)
)
)
(define-hardware
(define-hardware
  (name h-fpscr)
  (name h-fpscr)
  (comment "Floating point status and control register")
  (comment "Floating point status and control register")
  (attrs (ISA compact,media))
  (attrs (ISA compact,media))
  (type register SI)
  (type register SI)
)
)
(define-hardware
(define-hardware
  (name h-frbit)
  (name h-frbit)
  (comment "Floating point register file bit")
  (comment "Floating point register file bit")
  (attrs (ISA media,compact) VIRTUAL)
  (attrs (ISA media,compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 14) 1))
  (get () (and (srl (reg h-sr) 14) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 14))) (sll SI newvalue 14))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 14))) (sll SI newvalue 14))))
)
)
(define-hardware
(define-hardware
  (name h-szbit)
  (name h-szbit)
  (comment "Floating point transfer size bit")
  (comment "Floating point transfer size bit")
  (attrs (ISA media,compact) VIRTUAL)
  (attrs (ISA media,compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 13) 1))
  (get () (and (srl (reg h-sr) 13) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 13))) (sll SI newvalue 13))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 13))) (sll SI newvalue 13))))
)
)
(define-hardware
(define-hardware
  (name h-prbit)
  (name h-prbit)
  (comment "Floating point precision bit")
  (comment "Floating point precision bit")
  (attrs (ISA media,compact) VIRTUAL)
  (attrs (ISA media,compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 12) 1))
  (get () (and (srl (reg h-sr) 12) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 12))) (sll SI newvalue 12))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 12))) (sll SI newvalue 12))))
)
)
(define-hardware
(define-hardware
  (name h-sbit)
  (name h-sbit)
  (comment "Multiply-accumulate saturation flag")
  (comment "Multiply-accumulate saturation flag")
  (attrs (ISA compact) VIRTUAL)
  (attrs (ISA compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 1) 1))
  (get () (and (srl (reg h-sr) 1) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv 2)) (sll SI newvalue 1))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv 2)) (sll SI newvalue 1))))
)
)
(define-hardware
(define-hardware
  (name h-mbit)
  (name h-mbit)
  (comment "Divide-step M flag")
  (comment "Divide-step M flag")
  (attrs (ISA compact) VIRTUAL)
  (attrs (ISA compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 9) 1))
  (get () (and (srl (reg h-sr) 9) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 9))) (sll SI newvalue 9))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 9))) (sll SI newvalue 9))))
)
)
(define-hardware
(define-hardware
  (name h-qbit)
  (name h-qbit)
  (comment "Divide-step Q flag")
  (comment "Divide-step Q flag")
  (attrs (ISA compact) VIRTUAL)
  (attrs (ISA compact) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (and (srl (reg h-sr) 8) 1))
  (get () (and (srl (reg h-sr) 8) 1))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 8))) (sll SI newvalue 8))))
  (set (newvalue) (set (reg h-sr) (or (and (reg h-sr) (inv (sll 1 8))) (sll SI newvalue 8))))
)
)
(define-pmacro (-build-freg-name n) ((.sym fr n) n))
(define-pmacro (-build-freg-name n) ((.sym fr n) n))
(define-hardware
(define-hardware
  (name h-fr)
  (name h-fr)
  (comment "Single precision floating point registers")
  (comment "Single precision floating point registers")
  (attrs (ISA media,compact))
  (attrs (ISA media,compact))
  (type register SF (64))
  (type register SF (64))
  (indices keyword "" (.map -build-freg-name (.iota 64)))
  (indices keyword "" (.map -build-freg-name (.iota 64)))
)
)
(define-pmacro (-build-fpair-name n) ((.sym fp n) n))
(define-pmacro (-build-fpair-name n) ((.sym fp n) n))
(define-hardware
(define-hardware
  (name h-fp)
  (name h-fp)
  (comment "Single precision floating point register pairs")
  (comment "Single precision floating point register pairs")
  (attrs (ISA media,compact))
  (attrs (ISA media,compact))
  (type register DF (32))
  (type register DF (32))
  (indices keyword "" (.map -build-fpair-name (.iota 32)))
  (indices keyword "" (.map -build-fpair-name (.iota 32)))
)
)
(define-pmacro (-build-fvec-name n) ((.sym fv n) n))
(define-pmacro (-build-fvec-name n) ((.sym fv n) n))
(define-hardware
(define-hardware
  (name h-fv)
  (name h-fv)
  (comment "Single precision floating point vectors")
  (comment "Single precision floating point vectors")
  (attrs VIRTUAL (ISA media,compact))
  (attrs VIRTUAL (ISA media,compact))
  (type register SF (16))
  (type register SF (16))
  (indices keyword "" (.map -build-fvec-name (.iota 16)))
  (indices keyword "" (.map -build-fvec-name (.iota 16)))
  ; Mask with $F to ensure 0 <= index < 15.
  ; Mask with $F to ensure 0 <= index < 15.
  (get (index) (reg h-fr (mul (and UQI index 15) 4)))
  (get (index) (reg h-fr (mul (and UQI index 15) 4)))
  (set (index newval) (set (reg h-fr (mul (and UQI index 15) 4)) newval))
  (set (index newval) (set (reg h-fr (mul (and UQI index 15) 4)) newval))
)
)
(define-hardware
(define-hardware
  (name h-fmtx)
  (name h-fmtx)
  (comment "Single precision floating point matrices")
  (comment "Single precision floating point matrices")
  (attrs VIRTUAL (ISA media))
  (attrs VIRTUAL (ISA media))
  (type register SF (4))
  (type register SF (4))
  (indices keyword "" ((mtrx0 0) (mtrx1 1) (mtrx2 2) (mtrx3 3)))
  (indices keyword "" ((mtrx0 0) (mtrx1 1) (mtrx2 2) (mtrx3 3)))
  ; Mask with $3 to ensure 0 <= index < 4.
  ; Mask with $3 to ensure 0 <= index < 4.
  (get (index) (reg h-fr (mul (and UQI index 3) 16)))
  (get (index) (reg h-fr (mul (and UQI index 3) 16)))
  (set (index newval) (set (reg h-fr (mul (and UQI index 3) 16)) newval))
  (set (index newval) (set (reg h-fr (mul (and UQI index 3) 16)) newval))
)
)
(define-pmacro (-build-dreg-name n) ((.sym dr n) n))
(define-pmacro (-build-dreg-name n) ((.sym dr n) n))
(define-hardware
(define-hardware
  (name h-dr)
  (name h-dr)
  (comment "Double precision floating point registers")
  (comment "Double precision floating point registers")
  (attrs (ISA media,compact) VIRTUAL)
  (attrs (ISA media,compact) VIRTUAL)
  (type register DF (32))
  (type register DF (32))
  (indices keyword "" (.map -build-dreg-name (.iota 64)))
  (indices keyword "" (.map -build-dreg-name (.iota 64)))
  (get (index)
  (get (index)
       (subword DF
       (subword DF
                (or
                (or
                 (sll DI (zext DI (subword SI (reg h-fr index) 0)) 32)
                 (sll DI (zext DI (subword SI (reg h-fr index) 0)) 32)
                 (zext DI (subword SI (reg h-fr (add index 1)) 0))) 0))
                 (zext DI (subword SI (reg h-fr (add index 1)) 0))) 0))
  (set (index newval)
  (set (index newval)
       (sequence ()
       (sequence ()
                 (set (reg h-fr index)
                 (set (reg h-fr index)
                      (subword SF (subword SI newval 0) 0))
                      (subword SF (subword SI newval 0) 0))
                 (set (reg h-fr (add index 1))
                 (set (reg h-fr (add index 1))
                      (subword SF (subword SI newval 1) 0))))
                      (subword SF (subword SI newval 1) 0))))
)
)
(define-hardware
(define-hardware
  (name h-tr)
  (name h-tr)
  (comment "Branch target registers")
  (comment "Branch target registers")
  (attrs (ISA media))
  (attrs (ISA media))
  (type register DI (8))
  (type register DI (8))
  (indices keyword "" ((tr0 0) (tr1 1) (tr2 2) (tr3 3) (tr4 4) (tr5 5) (tr6 6) (tr7 7)))
  (indices keyword "" ((tr0 0) (tr1 1) (tr2 2) (tr3 3) (tr4 4) (tr5 5) (tr6 6) (tr7 7)))
)
)
(define-hardware
(define-hardware
  (name h-endian)
  (name h-endian)
  (comment "Current endian mode")
  (comment "Current endian mode")
  (attrs (ISA compact,media) VIRTUAL)
  (attrs (ISA compact,media) VIRTUAL)
  (type register BI)
  (type register BI)
  (get () (c-call BI "sh64_endian"))
  (get () (c-call BI "sh64_endian"))
  (set (newval) (error "cannot alter target byte order mid-program"))
  (set (newval) (error "cannot alter target byte order mid-program"))
)
)
(define-hardware
(define-hardware
  (name h-ism)
  (name h-ism)
  (comment "Current instruction set mode")
  (comment "Current instruction set mode")
  (attrs (ISA compact,media))
  (attrs (ISA compact,media))
  (type register BI)
  (type register BI)
  (get () (raw-reg h-ism))
  (get () (raw-reg h-ism))
  (set (newval) (error "cannot set ism directly"))
  (set (newval) (error "cannot set ism directly"))
)
)


; Operands.
; Operands.
(dnop endian "Endian mode" ((ISA compact,media)) h-endian f-nil)
(dnop endian "Endian mode" ((ISA compact,media)) h-endian f-nil)
(dnop ism    "Instruction set mode" ((ISA compact,media)) h-ism f-nil)
(dnop ism    "Instruction set mode" ((ISA compact,media)) h-ism f-nil)
; Universally useful macros.
; Universally useful macros.
; A pmacro for use in semantic bodies of unimplemented insns.
; A pmacro for use in semantic bodies of unimplemented insns.
(define-pmacro (unimp mnemonic) (nop))
(define-pmacro (unimp mnemonic) (nop))
; Join 2 ints together in natural bit order.
; Join 2 ints together in natural bit order.
(define-pmacro (-join-si s1 s0)
(define-pmacro (-join-si s1 s0)
  (or (sll (zext DI s1) 32)
  (or (sll (zext DI s1) 32)
      (zext DI s0)))
      (zext DI s0)))
; Join 4 half-ints together in natural bit order.
; Join 4 half-ints together in natural bit order.
(define-pmacro (-join-hi h3 h2 h1 h0)
(define-pmacro (-join-hi h3 h2 h1 h0)
  (or (sll (zext DI h3) 48)
  (or (sll (zext DI h3) 48)
      (or (sll (zext DI h2) 32)
      (or (sll (zext DI h2) 32)
          (or (sll (zext DI h1) 16)
          (or (sll (zext DI h1) 16)
              (zext DI h0)))))
              (zext DI h0)))))
; Join 8 quarter-ints together in natural bit order.
; Join 8 quarter-ints together in natural bit order.
(define-pmacro (-join-qi b7 b6 b5 b4 b3 b2 b1 b0)
(define-pmacro (-join-qi b7 b6 b5 b4 b3 b2 b1 b0)
  (or (sll (zext DI b7) 56)
  (or (sll (zext DI b7) 56)
      (or (sll (zext DI b6) 48)
      (or (sll (zext DI b6) 48)
          (or (sll (zext DI b5) 40)
          (or (sll (zext DI b5) 40)
              (or (sll (zext DI b4) 32)
              (or (sll (zext DI b4) 32)
                  (or (sll (zext DI b3) 24)
                  (or (sll (zext DI b3) 24)
                      (or (sll (zext DI b2) 16)
                      (or (sll (zext DI b2) 16)
                          (or (sll (zext DI b1) 8)
                          (or (sll (zext DI b1) 8)
                              (zext DI b0)))))))))
                              (zext DI b0)))))))))


; Include the two instruction set descriptions from their respective
; Include the two instruction set descriptions from their respective
; source files.
; source files.
(if (keep-isa? (compact))
(if (keep-isa? (compact))
    (include "sh64-compact.cpu"))
    (include "sh64-compact.cpu"))
(if (keep-isa? (media))
(if (keep-isa? (media))
    (include "sh64-media.cpu"))
    (include "sh64-media.cpu"))
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.