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

Subversion Repositories scarts

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

Compare with Previous | Blame | View Log

; Enums.
; Copyright (C) 2000, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
; Enums having attribute PREFIX have their symbols prepended with
; the enum class' name.
; Member PREFIX is always prepended to the symbol names.
;
; Enum values are looked up with `enum-lookup-val'.  The value to search for
; has PREFIX prepended.
;
; Enums always have mode INT.
; FIXME: this make! method is required by <insn-enum> for some reason.
; Parse a list of enum name/value entries.
; PREFIX is prepended to each name.
; Elements are any of: symbol, (symbol), (symbol value)
; (symbol - attrs), (symbol value attrs), (symbol - attrs comment),
; (symbol value attrs comment).
; The - or #f means "use the next value".
; SYMBOL may be - which means "skip this value".
; The result is the same list, except values are filled in where missing,
; and each symbol is prepended with `prefix'.
; Scan the value list, building up RESULT as we go.
; Each element's value is 1+ the previous, unless there's an explicit value.
; Compute the numeric value the next entry will have.
""; Accessors for the various elements of an enum val.
; Convert the names in the result of parse-enum-vals to uppercase.
; Parse an enum definition.
; Utility of -enum-parse to parse the prefix.
"prefix is not a string"; Prefix must not contain lowercase chars (enforced style rule, sue me).
"prefix must be uppercase"; This is the main routine for building an enum object from a
; description in the .cpu file.
; All arguments are in raw (non-evaluated) form.
"Processing enum "" ...\n";; Pick out name first to augment the error context.
"enum"; Read an enum description
; This is the main routine for analyzing enums in the .cpu file.
; CONTEXT is a <context> object for error messages.
; ARG-LIST is an associative list of field name and field value.
; -enum-parse is invoked to create the `enum' object.
""""; Loop over each element in ARG-LIST, recording what's found.
"invalid enum arg"; Now that we've identified the elements, build the object.
; Define an enum object, name/value pair list version.
"define-enum"; Define an enum object, all arguments specified.
"define-full-enum"; Lookup SYM in all recorded enums.
; The result is (value . enum-obj) or #f if not found.
;(display e) (newline)
; sanity check, ensure the enum has a value
"enum-lookup-val: enum missing value: "; Enums support code.
; Return #t if VALS is a sequential list of enum values.
; VALS is a list of enums.  e.g. ((sym1) (sym2 3) (sym3 - attr1 (attr2 4)))
; FIXME: Doesn't handle gaps in specified values.
; e.g. (sym1 val1) sym2 (sym3 val3)
; Return C code to declare enum SYM with values VALS.
; COMMENT is inserted in "/* Enum declaration for <...>.  */".
; PREFIX is added to each element of VALS.
; All enum symbols are uppercase.
; If the list of vals is sequential beginning at 0, don't output them.
; This simplifies the output and is necessary for sanitized values where
; some values may be cut out.
; VALS may have '- for the value, signifying use the next value as in C.
"Generating enum decl for "" ...\n"; Build result up as a list and then flatten it into a string.
; We could just return a string-list but that seems like too much to ask
; of callers.
"/* Enum declaration for "".  */\n""typedef enum "" {"; `n' is used to track the number of entries per line only
""; reset to beginning of line (but != 0)
"\n"; split string to avoid removal
"/* start-""sanitize-"" */\n"""" """"\n """" "", """" = "; split string to avoid removal
"\n/* end-""sanitize-"" */""""\n} "";\n\n"; Return a list of enum value definitions for gen-enum-decl.
; OBJ-LIST is a list of objects that support obj:name, obj-atlist.
; Return C code that declares[/defines] an enum.
"_"""; Return the C symbol of an enum value named VAL.
; Instruction code enums.
; These associate an enum with an instruction field so that the enum values
; can be used in instruction field lists.
; Same as enum-lookup-val except returned enum must be an insn-enum.
; Define an insn enum, all arguments specified.
"define-full-insn-enum""insn-enum""unknown insn field"; Create enum object and add it to the list of enums.
"\
Define an enum, name/value pair list version.
""\
Define an enum, all arguments specified.
""\
Define an instruction opcode enum, all arguments specified.
"

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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