From patchwork Fri Dec 15 03:36:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 82200 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15688384DED8 for ; Fri, 15 Dec 2023 03:36:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id B2BC03864856 for ; Fri, 15 Dec 2023 03:36:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2BC03864856 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B2BC03864856 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702611399; cv=none; b=cpDsZnoXLoss67BG/YAiapP7mMg+1y4+WcV9VNCwcLDXme090Lcj7EDKNkUpDyQnfxTQBEy24Vd8eRnhCNxn7RqSyPrCX8YI2mw2EoVoCoQdeRli9Yu8vhjudGLWTxk5neFGYjsFAUqQNWUWN8f9X3myBJwwsAyMRB5hoSE1fOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702611399; c=relaxed/simple; bh=FCqnWFW6JTrMWmJWkb6eByohvRIBsZVuw8azx7iDJUI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=g9UWdpmu9uH+B6p6cbNa36e9Cv9C5w3L7yX/i5uTn+ofv/ihox67rlqZTvirxIoj67YdciS9JGRnCU9Xs8yU+sTuvQR9AsrH9pNH8kCaBYy5TKOuXinPRxdovd+VDQAXvpM6mdhhYVuOzFSodHpVpoLdrv5R6wd2ihdNOcRLhX8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 17D36335DEB; Fri, 15 Dec 2023 03:36:37 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: igen: do not reindent literal semantics output Date: Thu, 14 Dec 2023 22:36:34 -0500 Message-ID: <20231215033634.15724-1-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org When generating semantics.c from .igen source files, indenting the code makes it more readable, but confuses compiler diagnostics. The latter is a bit more important than the former, so bias towards that. For example, with an introduced error, we can see w/gcc-13: (before this change) CC mn10300/semantics.o ../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’: ../../../sim/mn10300/am33-2.igen:11:5: error: ‘srcreg’ undeclared (first use in this function) 11 | srcreg = translate_rreg (SD_, RN2); | ^~~~~~ (with this change) CC mn10300/semantics.o ../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’: ../../../sim/mn10300/am33-2.igen:11:3: error: ‘srcreg’ undeclared (first use in this function) 11 | srcreg = translate_rreg (SD_, RN2); | ^~~~~~ Reviewed-By: Andrew Burgess --- sim/igen/gen-semantics.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c index 54d83d61eccd..455702973e4b 100644 --- a/sim/igen/gen-semantics.c +++ b/sim/igen/gen-semantics.c @@ -262,10 +262,17 @@ print_semantic_body (lf *file, { /* true code */ lf_printf (file, "{\n"); - lf_indent (file, +2); + /* NB: Do not indent the code. If the .igen source files cause a compiler + warning, the diagnostics can read the line from the original source, + but use column offsets from the generated files, causing columns to be + misaligned. It makes the generated code slightly more difficult to + read, but accurate compiler diagnostics relative to the original source + are more important here. + lf_indent (file, +2); */ lf_print__line_ref (file, instruction->code->line); table_print_code (file, instruction->code); - lf_indent (file, -2); + /* NB: Disabled -- see above. + lf_indent (file, -2); */ lf_printf (file, "}\n"); lf_print__internal_ref (file); }