]> sourceware.org Git - cgen.git/commitdiff
2005-05-18 Dave Brolley <brolley@redhat.com>
authorDave Brolley <brolley@sourceware.org>
Wed, 18 May 2005 21:52:57 +0000 (21:52 +0000)
committerDave Brolley <brolley@sourceware.org>
Wed, 18 May 2005 21:52:57 +0000 (21:52 +0000)
        * utils-sim.scm (-gen-decode-default-entry): New function.
        (-gen-decode-insn-entry): Now takes 'invalid-insn' argument. Generate
        code to check that all opcodes bits match.
        (-gen-decoder-switch): Use -gen-decode-default-entry.

ChangeLog
utils-sim.scm

index 14890c498b05fa935d699669de2c5a24b0d025b6..9250608422191b3707d393c819f83ba246055399 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-05-18  Dave Brolley  <brolley@redhat.com>
+
+       * utils-sim.scm (-gen-decode-default-entry): New function.
+       (-gen-decode-insn-entry): Now takes 'invalid-insn' argument. Generate
+       code to check that all opcodes bits match.
+       (-gen-decoder-switch): Use -gen-decode-default-entry.
+
 2005-05-16  Jim Blandy  <jimb@redhat.com>
 
        * sid.scm (gen-ifetch): Require BITSIZE to be exactly the size
index c6dda9f3a18786321731cd9763dc21d238895c92..aba2b0f8cb23011e323138bfdfa38f97e8715378 100644 (file)
@@ -1,5 +1,5 @@
 ; Generic simulator application utilities.
-; Copyright (C) 2000 Red Hat, Inc.
+; Copyright (C) 2000, 2005 Red Hat, Inc.
 ; This file is part of CGEN.
 ; See file COPYING.CGEN for details.
 
 
 ; Convert decoder table into C code.
 
+; Return code for the default entry of each switch table
+;
+(define (-gen-decode-default-entry indent invalid-insn fn?)
+  (string-append
+   "itype = "
+   (gen-cpu-insn-enum (current-cpu) invalid-insn)
+   ";"
+   (if (with-scache?)
+       (if fn?
+          " @prefix@_extract_sfmt_empty (this, current_cpu, pc, base_insn, entire_insn); goto done;\n"
+          " goto extract_sfmt_empty;\n")
+       " goto done;\n")
+  )
+)
+
 ; Return code for one insn entry.
 ; REST is the remaining entries.
 
-(define (-gen-decode-insn-entry entry rest indent fn?)
+(define (-gen-decode-insn-entry entry rest indent invalid-insn fn?)
   (assert (eq? 'insn (dtable-entry-type entry)))
   (logit 3 "Generating decode insn entry for " (obj:name (dtable-entry-value entry)) " ...\n")
 
 
      (else
       (string-append indent "  case "
-                    (number->string (dtable-entry-index entry)) " : "
-                    "itype = " (gen-cpu-insn-enum (current-cpu) insn) ";"
+                    (number->string (dtable-entry-index entry)) " :\n"
                     ; Compensate for base-insn-size > current-insn-size by adjusting entire_insn.
                     ; Activate this logic only for sid simulators; they are consistent in
                     ; interpreting base-insn-bitsize this way.
                     (if (and (equal? APPLICATION 'SID-SIMULATOR)
                              (> (state-base-insn-bitsize) (insn-length insn)))
                         (string-append
-                         " entire_insn = base_insn >> "
+                         indent "    entire_insn = base_insn >> "
                          (number->string (- (state-base-insn-bitsize) (insn-length insn)))
-                         ";")
+                         ";\n")
                         "")
+                    ; Generate code to check that all of the opcode bits for this insn match
+                    indent "    if ((entire_insn & 0x" (number->hex (insn-base-mask insn)) ") == 0x" (number->hex (insn-value insn)) ")\n" 
+                    indent "      { itype = " (gen-cpu-insn-enum (current-cpu) insn) ";"
                     (if (with-scache?)
                         (if fn?
-                            (string-append " @prefix@_extract_" fmt-name " (this, current_cpu, pc, base_insn, entire_insn); goto done;\n")
-                            (string-append " goto extract_" fmt-name ";\n"))
-                        " goto done;\n")))))
+                            (string-append " @prefix@_extract_" fmt-name " (this, current_cpu, pc, base_insn, entire_insn); goto done;")
+                            (string-append " goto extract_" fmt-name ";"))
+                        " goto done;")
+                    " }\n"
+                    indent "    " (-gen-decode-default-entry indent invalid-insn fn?)))))
 )
 
 ; Subroutine of -decode-expr-ifield-tracking.
          (cdr entries)
          (cons (case (dtable-entry-type (car entries))
                  ((insn)
-                  (-gen-decode-insn-entry (car entries) (cdr entries) indent fn?))
+                  (-gen-decode-insn-entry (car entries) (cdr entries) indent invalid-insn fn?))
                  ((expr)
                   (-gen-decode-expr-entry (car entries) indent invalid-insn fn?))
                  ((table)
                result))))
 
    ; ??? Can delete if all cases are present.
-   indent "  default : itype = "
-   (gen-cpu-insn-enum (current-cpu) invalid-insn)
-   ";"
-   (if (with-scache?)
-       (if fn?
-          " @prefix@_extract_sfmt_empty (this, current_cpu, pc, base_insn, entire_insn);  goto done;\n"
-          " goto extract_sfmt_empty;\n")
-       " goto done;\n")
+   indent "  default : "
+   (-gen-decode-default-entry indent invalid-insn fn?)
    indent "  }\n"
    indent "}\n"
    )
This page took 0.03609 seconds and 5 git commands to generate.