URL
https://opencores.org/ocsvn/scarts/scarts/trunk
Subversion Repositories scarts
[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [opcodes.scm] - Rev 7
Go to most recent revision | Compare with Previous | Blame | View Log
; General cpu info generator support. ; Copyright (C) 2000, 2002, 2005, 2009 Red Hat, Inc. ; This file is part of CGEN. ; Global state variables. ; Specify which application. ; Records the -OPC arg which specifies the path to the .opc file. ".opc file unspecified, missing -OPC argument"; Return #t if the -OPC parameter was specified. ; Boolean indicating if we're to build the operand instance table. ; The default is no, since only the m32r uses it at present. ; ??? Simulator tracing support could use it. ; ??? Might be lazily built at runtime by parsing the semantic code ; (which would be recorded in the insn table). ; String containing copyright text. ; String containing text defining the package we're generating code for. ; Initialize the options. ; Handle an option passed in from the command line. "fsf""redhat""invalid copyright value""binutils""gnusim""cygsim""invalid package value""unknown option"; Instruction fields support code. ; Default type of variable to use to hold ifield value. ; FIXME: Use long for now. "long"; Given field F, return a C definition of a variable big enough to hold ; its value. " "" "";\n"; Return name of function to call to insert the value of <ifield> F ; into an insn. "insert_normal"; Return name of function to call to extract the value of <ifield> F ; into an insn. "extract_normal"; Default routine to emit C code to insert a field in an insn. ; use to also handle operand's `insert' field " {\n"" "" value = "";\n"""" value = ";; NOTE: ENCODE is either, e.g., ;; ((value pc) (sra DI value 1)) ;; or ;; (((<mode> value) (<mode> pc)) (sra DI value 1)) "value""pc"";\n"""" """" errmsg = "" (cd, ""value"", "; We explicitly pass the attributes here rather than look them up ; to give the code more optimization opportunities. ; ??? Maybe when fields are recorded in opc.c, stop doing this, and ; pass a pointer to the recorded attributes instead. ", "", "", "", "", total_length"", buffer"");\n"" }\n"""; Default routine to emit C code to extract a field from an insn. ; use to also handle operand's `extract' field " {\n "" value;\n """" length = "" (cd, ex_info, insn_value, "; We explicitly pass the attributes here rather than look them up ; to give the code more optimization opportunities. ; ??? Maybe when fields are recorded in opc.c, stop doing this, and ; pass a pointer to the recorded attributes instead. ", "", "", "", "", total_length"", pc"", & ""value"");\n"" value = ";; NOTE: DECODE is either, e.g., ;; ((value pc) (sll DI value 1)) ;; or ;; (((<mode> value) (<mode> pc)) (sll DI value 1)) "value""pc"";\n"""" "" = value;\n"" }\n"""; gen-insert of multi-ifields " {\n"" "" = ""pc"";\n"""" "" if (errmsg)\n"" break;\n"" }\n"; gen-insert of derived-operands " abort();\n"; gen-extract of multi-ifields " {\n"" "" if (length <= 0) break;\n"" "" = ""pc"";\n"""" }\n"" abort();\n";(method-make! ; <derived-operand> 'gen-extract ; (lambda (self operand) ; (string-list ; " {\n" ; (string-list-map (lambda (subop) ; (string-list ; " " (send subop 'gen-extract operand) ; " if (length <= 0)\n" ; " break;\n")) ; (elm-get self 'args)) ; " }\n" ; )) ;) ; Hardware index support code. """"; HW-ASM is the base class for supporting hardware elements in the opcode table ; (aka assembler/disassembler). ; Utility to return C code to parse a number of <mode> MODE for an operand. ; RESULT-VAR-NAME is a string containing the variable to store the ; parsed number in. ; PARSE-FN is the name of the function to call or #f to use the default. ; OP-ENUM is the enum of the operand. " errmsg = "; Use operand's special parse function if there is one, otherwise compute ; the function's name from the mode. "cgen_parse_signed_integer""cgen_parse_unsigned_integer""unsupported (as yet) mode for parsing"" (cd, strp, "", "; This is to pacify gcc 4.x which will complain about ; incorrect signed-ness of pointers passed to functions. "(long *)""(unsigned long *)"" (& ""));\n"; Utility to return C code to parse an address. ; RESULT-VAR-NAME is a string containing the variable to store the ; parsed number in. ; PARSE-FN is the name of the function to call or #f to use the default. ; OP-ENUM is the enum of the operand. " {\n"" bfd_vma value = 0;\n"" errmsg = "; Use operand's special parse function if there is one. "cgen_parse_address"" (cd, strp, "", 0, "; opinfo arg "NULL, "; result_type arg (FIXME) " & value);\n"" "" = value;\n"" }\n"; Return C code to parse an expression. "junk"; Default method to emit C code to print a hardware element. "0"" ""print_address""print_normal"; (or (send operand 'gen-function-name 'print) ; (case (obj:name (elm-get self 'mode)) ; ((QI HI SI INT) "print_signed") ; ((BI UQI UHI USI UINT) "print_unsigned") ; (else (error "unsupported (as yet) mode for printing" ; (obj:name (elm-get self 'mode)))))) " (cd, info, "", "; We explicitly pass the attributes here rather than look them up ; to give the code more optimization opportunities. ;(gen-bool-attrs (obj-atlist operand) gen-attr-mask) ", pc, length"");\n"; Keyword support. ; Return C code to parse a keyword. "junk"" errmsg = ""cgen_parse_keyword"" (cd, strp, "", ";(op-enum operand) ", " "& "");\n"; Return C code to print a keyword. "0"" ""print_keyword"" (cd, ""info"; The disassemble_info argument to print_insn. ", "", "", "; We explicitly pass the attributes here rather than look them up ; to give the code more optimization opportunities. ");\n"; Hardware support. ; For registers, use the indices field. Ignore values. ; ??? Not that that will always be the case. ; No such support for memory yet. "gen-parse of memory not supported yet""gen-print of memory not supported yet"; For immediates, use the values field. Ignore indices. ; ??? Not that that will always be the case. ; For addresses, use the values field. Ignore indices. ; Generate the C code for dealing with operands. ; This code is inserted into cgen-{ibld,asm,dis}.in above the insn routines ; so that it can be inlined if desired. ??? Actually this isn't always the ; case but this is minutiae to be dealt with much later. ; Generate the guts of a C switch to handle an operation for all operands. ; WHAT is one of fget/fset/parse/insert/extract/print. ; ; The "f" prefix (e.g. set -> fset) is for "field" to distinguish the ; operations from similar ones in other contexts. ??? I'd prefer to come ; up with better names for fget/fset but I haven't come up with anything ; satisfactory yet. ; OPS is a list of operands with the same name that for whatever reason ; were defined separately. "Processing "" "" ...\n"" case @ARCH@_OPERAND_"" :\n"" break;\n"; FIXME: operand name doesn't get sanitized. " case @ARCH@_OPERAND_"" :\n"; There's more than one operand defined with this name, so we ; have to distinguish them. ; FIXME: Unfinished. " break;\n"; Operand support. ; Return the function name to use for WHAT or #f if there isn't a special one. ; WHAT is one of fget/fset/parse/insert/extract/print. "_"; Interface fns. ; The default is to forward the request onto TYPE. ; OP is a copy of SELF so the method we forward to sees it. ; There is one case in the fget/fset/parse/insert/extract/print ; switches for each operand. ; These are invoked via gen-switch. ; Emit C code to get an operand value from the fields struct. ; Operand values are stored in a struct "indexed" by field name. ; ; The "f" prefix (e.g. set -> fset) is for "field" to distinguish the ; operations from similar ones in other contexts. ??? I'd prefer to come ; up with better names for fget/fset but I haven't come up with anything ; satisfactory yet. " value = "";\n"" value = 0;\n"" abort();\n"; should never be called ; Emit C code to save an operand value in the fields struct. " "" = value;\n"""; ignore " abort();\n"; should never be called ; Need to call op:type to resolve the hardware reference. ;(method-make-forward! <operand> 'type '(gen-parse gen-print)) " abort();\n"; should never be called " abort();\n"; should never be called ; But: <derived-operand> has its own gen-insert / gen-extract. ; Return the value of PC. ; Used by insert/extract fields. "pc"; Opcodes init,finish,analyzer support. ; Initialize any opcodes specific things before loading the .cpu file. ; Finish any opcodes specific things after loading the .cpu file. ; This is separate from analyze-data! as cpu-load performs some ; consistency checks in between. ; Compute various needed globals and assign any computed fields of ; the various objects. This is the standard routine that is called after ; a .cpu file is loaded. ; Initialize the rtl->c translator. ; Only include semantic operands when computing the format tables if we're ; generating operand instance tables. ; ??? Actually, may always be able to exclude the semantic operands. ; Still need to traverse the semantics to derive machine computed attributes. ; include aliases ; Extra target specific code generation. ; Pick out a section from the .opc file. ; The section is delimited with: ; /* -- name ... */ ; ... ; /* -- ... */ ; ; FIXME: This is a pretty involved bit of code. 'twould be nice to split ; it up into manageable chunks. "/* -- ""/* -- ""r"; Extra amount is added to SIZE so substring's to fetch possible ; delim won't fail, even at end of file ; End of file, did we find the text? ""; Check for start delim or end delim? "Unable to open:"""; file doesn't exist "Generating extra cpu.h stuff from "".opc ...\n""cpu.h""Generating extra cpu.c stuff from "".opc ...\n""cpu.c""Generating extra opc.h stuff from "".opc ...\n""opc.h""Generating extra opc.c stuff from "".opc ...\n""opc.c""Generating extra asm.c stuff from "".opc ...\n""asm.c""Generating extra dis.c stuff from "".opc ...\n""dis.c""Generating extra ibld.h stuff from "".opc ...\n""ibld.h""Generating extra ibld.c stuff from "".opc ...\n""ibld.c"; For debugging.
Go to most recent revision | Compare with Previous | Blame | View Log