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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [types.scm] - Rev 6

Compare with Previous | Blame | View Log

; Type system.
; This provides the low level classes for describing data, except for
; the actual type (confusingly enough) which is described in mode.scm.
; Copyright (C) 2000, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
; Array type.
; DIMENSIONS has a suitable initial value so (new <scalar>) to works.
; Return number of elements in array.
; Return mode of the array.
; Return the rank of the array (number of dimensions).
; Return shape of array
; Return #t if X is an array.
; Scalar type.
; Return #t if X is a scalar.
; Return number of bits in an element of TYPE.
; Integers.
; These are like scalars but are specified in bits.
; BITS is the size in bits.
; ATTRS contains !UNSIGNED [or nothing] or UNSIGNED.
;
; A mode is needed so we know how big a field is needed to record the value.
; It might be more appropriate to use a host mode though.
;
; FIXME: Need to separate rank from type.  scalar/array are not types.
;
;(define <integer> (class-make '<integer> nil '(attrs bits) nil))
;
;(method-make! <integer> 'get-atlist (lambda (self) (elm-get self 'attrs)))
;
;(method-make!
; <integer> 'get-mode 
; (lambda (self)
;   (mode-find (elm-get self 'bits)
;	      (if (has-attr? self 'UNSIGNED) 'UINT 'INT))
;   )
;)
;
; FIXME: Quick hack.  Revisit.
;
;(method-make! <integer> 'get-rank (lambda (self) 0))
; Structures.
; FIXME: Unfinished.
; Parse a type spec.
; TYPE-SPEC is: (mode [(dimensions ...)])
;           or: ((mode bits) [(dimensions ...)])
; Preliminary error checking.
", expected (mode [(dimensions)]) or ((mode bits) [(dimensions)])""invalid type spec""invalid type spec"; Validate the mode spec.
; ok
"invalid mode in type spec""invalid mode in type spec""invalid #bits in type spec""invalid mode in type spec"; Validate the dimension list if present.
"invalid dimension spec in type spec"; Pick out the arguments.
; Look up the mode and create the mode object.
"wrong number of bits for mode"; All done, create the <array> object.
; ??? Special casing scalars is a concession for apps that think
; scalars aren't arrays.  Not sure it should stay.
; Bit ranges.
; ??? Perhaps this should live in a different source file, but for now
; it's here.
;
; Endianness is not recorded with the bitrange.
; Values are operated on a "word" at a time.
; This is to handle bi-endian systems: we don't want two copies of
; every bitrange.
;
; Instruction word sizes are based on the "base insn length" which is the
; number of bytes the cpu first looks at to decode an insn.  In cases where
; the total length is longer than the base insn length, the word length
; for the rest of the insn is the base insn length replicated as many times
; as necessary.  The trailing part [last few bytes] of the insn may not fill
; the entire word, in which case the numbering is adjusted for it.
; ??? Might need to have an insn-base-length and an insn-word-length.
;
; Instructions that have words of one endianness and sub-words of a different
; endianness are handled at a higher level.
;
; Bit numbering examples:
; [each byte is represented MSB to LSB, low address to high address]
;
; lsb0? = #f
; insn-word-length = 2
; endian = little
; | 8 ... 15 | 0 ... 7 | 24 ... 31 | 16 ... 23 | 40 ... 47 | 32 ... 39 |
;
; lsb0? = #t
; insn-word-length = 2
; endian = little
; [note that this is the little endian canonical form (*)
;  - word length is irrelevant]
; | 7 ... 0 | 15 ... 8 | 23 ... 16 | 31 ... 24 | 39 ... 32 | 47 ... 40 |
;
; lsb0? = #f
; insn-word-length = 2
; endian = big
; [note that this is the big endian canonical form (*)
;  - word length is irrelevant]
; | 0 ... 7 | 8 ... 15 | 16 ... 23 | 24 ... 31 | 32 ... 39 | 40 ... 47 |
;
; lsb0? = #t
; insn-word-length = 2
; endian = big
; | 15 ... 8 | 7 ... 0 | 31 ... 24 | 23 ... 16 | 47 ... 40 | 39 ... 32 |
;
; (*) NOTE: This canonical form should not be confused with what might be
; called the canonical form when writing .cpu ifield descriptions: lsb0? = #f.
; The ifield canonical form is lsb0? = #f because the starting bit number of
; ifields is defined to be the MSB.
; ---
; At the bitrange level, insns with different sized words is supported.
; This is because each <bitrange> contains the specs of the word it resides in.
; For example a 48 bit insn with a 16 bit opcode and a 32 bit immediate value
; might [but not necessarily] consist of one 16 bit "word" and one 32 bit
; "word".
;
; Examples:
;
; lsb0? = #f
; insn-word-length = 2, 4
; endian = little
; | 8 ... 15 | 0 ... 7 | 40 ... 47 | 32 ... 39 | 24 ... 31 | 16 ... 23 |
;
; lsb0? = #t
; insn-word-length = 2, 4
; endian = little
; | 7 ... 0 | 15 ... 8 | 23 ... 16 | 31 ... 24 | 39 ... 32 | 47 ... 40 |
;
; lsb0? = #f
; insn-word-length = 2, 4
; endian = big
; | 0 ... 7 | 8 ... 15 | 16 ... 23 | 24 ... 31 | 32 ... 39 | 40 ... 47 |
;
; lsb0? = #t
; insn-word-length = 2, 4
; endian = big
; | 15 ... 8 | 7 ... 0 | 47 ... 40 | 39 ... 32 | 31 ... 24 | 23 ... 16 |
; offset in bits from the start of the insn of the word
; in which the value resides [must be divisible by 8]
; [this allows the bitrange to be independent of the lengths
; of words preceding this one]
; starting bit number within the word,
; this is the MSB of the bitrange within the word
; [externally, = word-offset + start]
; number of bits in the value
; length of word in which the value resides
; lsb = bit number 0?
; Accessor fns.
; lsb0? left out on purpose: not sure changing it should be allowed
; Return a boolean indicating if two bitranges overlap.
;
; lsb0? = #t: 31 ...  0
; lsb0? = #f: 0  ... 31
; Return a boolean indicating if BITPOS is beyond bitrange START,LEN.
; ??? This needs more thought.
; Return the offset of the word after <bitrange> br.
; ??? revisit
; Initialize/finalize support.
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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