From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14862 invoked by alias); 23 Mar 2007 08:40:31 -0000 Received: (qmail 14853 invoked by uid 22791); 23 Mar 2007 08:40:31 -0000 X-Spam-Check-By: sourceware.org Received: from ug-out-1314.google.com (HELO ug-out-1314.google.com) (66.249.92.170) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 23 Mar 2007 08:40:26 +0000 Received: by ug-out-1314.google.com with SMTP id 75so956176ugb for ; Fri, 23 Mar 2007 01:40:24 -0700 (PDT) Received: by 10.114.166.1 with SMTP id o1mr1077262wae.1174639222727; Fri, 23 Mar 2007 01:40:22 -0700 (PDT) Received: by 10.114.255.13 with HTTP; Fri, 23 Mar 2007 01:40:22 -0700 (PDT) Message-ID: Date: Fri, 23 Mar 2007 08:40:00 -0000 From: "Chuan-Hua Chang" To: cgen@sourceware.org Subject: generated decoder code question MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2007-q1/txt/msg00066.txt.bz2 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.