From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 7A7393858D33 for ; Fri, 22 Dec 2023 10:56:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A7393858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A7393858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703242577; cv=none; b=d09wQVyB6XtSOfT2LmnvkQFbW27Mlvx3dvk7GPbkRVESvqAOZFIXNl5oRKOlLiPH7yPiGHrH/OTi0jACE2QQc6UDZpZrozvS8MfbI5XqwOdL+n4FKpJXmti0U0n3hSUZaLvzchEdJXNWK054CyT+by6uh3KHN7lYeyII3TpKH7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703242577; c=relaxed/simple; bh=l0j9gRWcWQlAi8zqt758e2KhMc6roKylm4ng++Q8nnE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rZTocaxTEF1iR0Gy8vDDm+G1vMM64lC3HWt5m6JkaQ+yDn5f8NNqVsgOaXv+IOlWdBlTZgw7FLbT1gJ5JGGgWJPG69gh5H0tPeOETd+ZKws/s9/T8da5GMGi0VNTdc8kgvy7cwtuZ5znGe/DeXYCP94jeTB3056u9k4V9ser9Zs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGdCQ-0000QQ-Ff; Fri, 22 Dec 2023 05:56:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=JEzQkyCi32puTIx1O35z3mrC2T4XmgXXG5+oIUi4GHI=; b=Xe7Oh6qUtQM4EitdR3jr gC//Ghb3QnS37vG8sXUrFTpW9HWmQ8rCiksc4kQqJN2Gh9SxPUEY47ct8Lu4K4QdSqKpTY8dgpHHC MIqpH1dRIJBtOPDIw7Of84kTiItJo4Qf0XLOY5oLUZyCVZzkZiW9979J8R3a1kpapUAjoAAxvui73 05AmEAv/HJUJkmi5Gphk3xHSI/aB5sULYupIQXO9dTCtDj7TuuZWMZ61E/OZRfVAYPz2ZSeqoI/Js M7L7oHgG+g0+V8+SGUCOGfJCez/nDXmPkSwneVWVrPRVglumvCsgWZ1624WRz6tTFwK5lL6BIqray dcdpH3xHrD+qLA==; From: "Jose E. Marchesi" To: Mike Frysinger via Cgen Cc: Mike Frysinger Subject: Re: [PATCH] sim: avoid shadowing vars when decoding insns In-Reply-To: <20231222005524.14053-1-vapier@gentoo.org> (Mike Frysinger via Cgen's message of "Thu, 21 Dec 2023 19:55:24 -0500") References: <20231222005524.14053-1-vapier@gentoo.org> Date: Fri, 22 Dec 2023 11:45:00 +0100 Message-ID: <87wmt6plcj.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Mike. > ; Generate switch statement to decode TABLE-GUTS. > -; SWITCH-NUM is for compatibility with the computed goto decoder and > -; isn't used. > +; SWITCH-NUM is for compatibility with the computed goto decoder and tracks the > +; nesting depth. I wonder if it would be better to not mention the "computed goto decoder" at all in the comment block, since AFAIK it doesn't exist. Other than that the patch is OK. Thanks. > ; STARTBIT is the bit offset of the instruction value that C variable `insn' > ; holds (note that this is independent of LSB0?). > ; DECODE-BITSIZE is the number of bits of the insn that `insn' holds. > @@ -1017,7 +1017,8 @@ > table-guts table-guts-thus-far > indent lsb0? invalid-insn fn?) > > - (let ((new-table-guts-thus-far (append table-guts-thus-far (list table-guts)))) > + (let ((new-table-guts-thus-far (append table-guts-thus-far (list table-guts))) > + (varname (string-append "val" (number->string switch-num)))) > > (string-list > indent "{\n" > @@ -1027,19 +1028,19 @@ > (set! startbit (dtable-guts-startbit table-guts)) > (set! decode-bitsize (dtable-guts-bitsize table-guts)) > ;; FIXME: Bits may get fetched again during extraction. > - (string-append indent " unsigned int val;\n" > + (string-append indent " unsigned int " varname ";\n" > indent " /* Must fetch more bits. */\n" > indent " insn = " > (gen-ifetch "pc" startbit decode-bitsize) > ";\n" > - indent " val = ")) > - (string-append indent " unsigned int val = ")) > + indent " " varname " = ")) > + (string-append indent " unsigned int " varname " = ")) > (/gen-decode-bits (dtable-guts-bitnums table-guts) > (dtable-guts-startbit table-guts) > (dtable-guts-bitsize table-guts) > "insn" "entire_insn" lsb0?) > ";\n" > - indent " switch (val)\n" > + indent " switch (" varname ")\n" > indent " {\n" > > ;; The code is more readable, and icache use is improved, if we collapse > @@ -1067,7 +1068,7 @@ > (/gen-decode-expr-entry (car entries) indent invalid-insn fn?)) > ((table) > (/gen-decode-table-entry (car entries) (cdr entries) > - switch-num startbit decode-bitsize > + (+ switch-num 1) startbit decode-bitsize > new-table-guts-thus-far > indent lsb0? invalid-insn fn?)) > ) > @@ -1105,7 +1106,7 @@ > > ; Now print it out. > > - (/gen-decoder-switch "0" 0 decode-bitsize > + (/gen-decoder-switch 0 0 decode-bitsize > table-guts nil > indent lsb0? invalid-insn fn?)) > )