This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sid-related patch: 16/32-bit insn set support


Hi -

The patch below, about to be committed, aims to correct the problems
reported by bje regarding 16/32-bit insn decoding and extraction.
The utils-sim.scm change is conditional on SID only, to avoid
interference with the m32r sim, which has its own interesting ideas
about how 16/32-bit instruction sets might be handled.


2001-07-11  Frank Ch. Eigler  <fche@redhat.com>
 
	* sid-cpu.scm (-gen-mach-params): New proc to emit ...CHUNK_BITSIZE...
	(cgen-desc.h): Call it.
	* sid-decode.scm (-gen-decode-fn): Use base-insn-bitsize as
	decode-size.
	* utils-sim.scm (-gen-decode-insn-entry): For SID only, prepare
	entire_insn for extraction, if it's shorter than base-insn-bitsize.

Index: sid-cpu.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-cpu.scm,v
retrieving revision 1.3
diff -u -r1.3 sid-cpu.scm
--- sid-cpu.scm	2001/04/02 21:18:27	1.3
+++ sid-cpu.scm	2001/07/12 02:51:03
@@ -57,6 +57,17 @@
       ))
 )
 
+
+; Emit a macro that specifies the word-bitsize for each machine.
+(define (-gen-mach-params)
+  (string-map (lambda (mach) 
+		(string-append
+		 "#define MACH_" (string-upcase (gen-sym mach)) "_INSN_CHUNK_BITSIZE "
+		 (number->string (cpu-insn-chunk-bitsize (mach-cpu mach))) "\n"))
+	      (current-mach-list))
+)
+
+
 ; Generate <cpu>-desc.h.
 
 (define (cgen-desc.h)
@@ -77,6 +88,7 @@
 
    -gen-attr-decls
    -gen-insn-attr-decls
+   -gen-mach-params
 
    "
 } // end @arch@ namespace
Index: sid-decode.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-decode.scm,v
retrieving revision 1.4
diff -u -r1.4 sid-decode.scm
--- sid-decode.scm	2001/04/02 21:18:27	1.4
+++ sid-decode.scm	2001/07/12 02:51:03
@@ -629,7 +629,7 @@
   ; of the instruction.
   ; ??? Make this a parameter later but only if necessary.
 
-  (let ((decode-bitsize (apply min (map insn-base-mask-length insn-list))))
+  (let ((decode-bitsize (state-base-insn-bitsize)))
 
     ; Compute INITIAL-BITNUMS if not supplied.
     ; 0 is passed for the start bit (it is independent of lsb0?)
Index: utils-sim.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils-sim.scm,v
retrieving revision 1.5
diff -u -r1.5 utils-sim.scm
--- utils-sim.scm	2000/12/04 18:34:45	1.5
+++ utils-sim.scm	2001/07/12 02:51:04
@@ -589,14 +589,22 @@
 
      (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)) " : "
+		     "itype = " (gen-cpu-insn-enum (current-cpu) insn) ";"
+		     ; 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 >> "
+			  (number->string (- (state-base-insn-bitsize) (insn-length 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 ";"))
+			     (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")))))
 )
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]