* cpu/play.opc: New file.
Allow arbitrary enums in instruction formats, e.g. (f-op1 OP1_4).
* insn.scm (-parse-insn-format-ifield-spec): Recognize (ifield enum).
* doc/rtl.texi (Instructions): Update.
2009-07-07 Doug Evans <dje@sebabeach.org>
+ * cpu/play.cpu (add): Use (ifield enum) for one format element.
+ * cpu/play.opc: New file.
+
+ Allow arbitrary enums in instruction formats, e.g. (f-op1 OP1_4).
+ * insn.scm (-parse-insn-format-ifield-spec): Recognize (ifield enum).
+ * doc/rtl.texi (Instructions): Update.
+
* cgen-opc.scm (-opc-file-path,opc-file-path): Move to opcodes.scm
(opc-arguments, -OPC): Call set-opc-file-path!.
* opcodes.scm (-opc-file-path,opc-file-path): Moved here.
(dni add "add"
()
"add $dr,$sr"
- (+ OP1_4 OP2_0 dr sr)
+ ; Use (f-op1 OP1_4) to exercise it.
+ (+ (f-op1 OP1_4) OP2_0 dr sr)
(sequence ()
(set vbit (add-oflag dr sr (const 0)))
(set cbit (add-cflag dr sr (const 0)))
--- /dev/null
+/* Play opcode support. -*- C -*-
+ Copyright (C) 2009 Red Hat, Inc.
+ This file is part of CGEN. */
+
+/* This file is an addendum to play.cpu. Heavy use of C code isn't
+ appropriate in .cpu files, so it resides here. This especially applies
+ to assembly/disassembly where parsing/printing can be quite involved.
+ Such things aren't really part of the specification of the cpu, per se,
+ so .cpu files provide the general framework and .opc files handle the
+ nitty-gritty details as necessary.
+
+ Each section is delimited with start and end markers.
+
+ <arch>-opc.h additions use: "-- opc.h"
+ <arch>-opc.c additions use: "-- opc.c"
+ <arch>-asm.c additions use: "-- asm.c"
+ <arch>-dis.c additions use: "-- dis.c"
+ <arch>-ibd.h additions use: "-- ibd.h" */
Format elements can be any of:
@itemize @bullet
-@item instruction field specifiers with a value (e.g. @code{(f-r1 14)})
-@item an instruction field enum, as in @code{OP1_4}
-@item an operand
+@item an instruction field name with an integer, e.g. @code{(f-op1 4)}
+@item an instruction field name with an enum, e.g. @code{(f-op1 OP1_4)}
+@item an instruction field enum, e.g. @code{OP1_4}
+@item an operand name, e.g. @code{dr}
@end itemize
@subsection semantics
; ??? This use to allow (ifield-name operand-name). That's how
; `operand-name' elements are handled, but there's no current need
; to handle (ifield-name operand-name).
- (if (not (integer? value))
- (parse-error errtxt "ifield value not an integer" ifld-spec))
- (ifld-new-value ifld value))
+ (cond ((integer? value)
+ (ifld-new-value ifld value))
+ ((symbol? value)
+ (let ((e (enum-lookup-val value)))
+ (if (not e)
+ (parse-error errtxt "symbolic ifield value not an enum" ifld-spec))
+ (ifld-new-value ifld (car e))))
+ (else
+ (parse-error errtxt "ifield value not an integer" ifld-spec))))
)
; Subroutine of -parse-insn-format to parse an