OSDN Git Service

* cpu/play.cpu (add): Use (ifield enum) for one format element.
authordevans <devans>
Tue, 7 Jul 2009 18:44:09 +0000 (18:44 +0000)
committerdevans <devans>
Tue, 7 Jul 2009 18:44:09 +0000 (18:44 +0000)
* 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/ChangeLog
cgen/cpu/play.cpu
cgen/cpu/play.opc [new file with mode: 0644]
cgen/doc/rtl.texi
cgen/insn.scm

index bbc3e5f..00ed930 100644 (file)
@@ -1,5 +1,12 @@
 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.
index 7b25b7e..3f90503 100644 (file)
 (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)))
diff --git a/cgen/cpu/play.opc b/cgen/cpu/play.opc
new file mode 100644 (file)
index 0000000..e9fb6b1
--- /dev/null
@@ -0,0 +1,18 @@
+/* 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"  */
index 0d1d5de..208e67a 100644 (file)
@@ -1867,9 +1867,10 @@ The ordering of the fields is not important.
 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
index e9caa8f..0bb96f9 100644 (file)
     ; ??? 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