This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
generated decoder code question
- From: "Chuan-Hua Chang" <chuanhua dot chang at gmail dot com>
- To: cgen at sourceware dot org
- Date: Fri, 23 Mar 2007 16:40:22 +0800
- Subject: generated decoder code question
In the utils-sim.scm file, the "-gen-decode-insn-entry" function has
the following lines:
; Generate code to check that all of the opcode bits for this insn match
indent " if (("
(if (adata-integral-insn? CURRENT-ARCH) "entire_insn" "base_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;")
(string-append " goto extract_" fmt-name ";"))
" goto done;")
" }\n"
indent " " (-gen-decode-default-entry indent invalid-insn fn?)))))
)
It generates an IF-statement to check the opcode again inside the case
statement before doing the real extraction. This seems really
redundant and make the decoder inefficient.
I am wondering why this is needed here. Could someone help to explain
the reasoning?
When looking at the M32R decode function, the IF-statement is absent
from the decoder code. This lets me wonder that if there is a way to
remove this redundant IF-statement check in the CGEN flow.
Thanks.