From patchwork Thu Nov 2 16:03:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 833409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-465769-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WlMNLUv8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ySVL75R1Sz9t2r for ; Fri, 3 Nov 2017 03:05:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:date:message-id:cc:from:to; q=dns; s=default; b=BgY0wdI PdwFMeABpPoLo8FlJLbTM9vlOVMYY3TFItRFOCd+yhdNalfz0GA3KMOEfOt7voLe Q6F5YDrXAqLldVRbJ26LIRAkZLl3WlCtAQSnfkU+WK/2vi4JijyP0K2U+14y/ZGG GL6DYli7MMzdoFpBnHClgInsYO+oli7x12Tc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:date:message-id:cc:from:to; s=default; bh=YLLE8SvzBy3YG j+5S6vQFh+ne+g=; b=WlMNLUv8icrZV0oSHqGYpujHNDBh/mTcQEMJOyymtf+YX sXvpLS/UQlMa97ZB6FzIYOmez8IxFI9UFC1/vWnqTUtMXVgQSogLwbXdzZQRukN7 WngQ8YPnhbgcZ2tjCcsOAAgrTX5eknDxFDN4NJCvHHoCsxPVeZZ34R6MkN+2uQ= Received: (qmail 51291 invoked by alias); 2 Nov 2017 16:05:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 51279 invoked by uid 89); 2 Nov 2017 16:05:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=(unknown), Cheng, cheng X-HELO: mail-pg0-f46.google.com Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 16:05:25 +0000 Received: by mail-pg0-f46.google.com with SMTP id r25so7522pgn.4 for ; Thu, 02 Nov 2017 09:05:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:cc:from:to; bh=7EzR4rN5Bog/esjV1Y0MjkVdvGusXbzs5JDfhvBrsac=; b=THH6Qq+yLk9L5fuupJLr7TdOvSBbD4xn6l804hGAfkx51p8QizkSQ2P0UqZKq/+BKi Kjac5QCPkKiIhn6qOk1xWVdUgLwcDOl0eGfG8sGwGex/kR9TD/3/AOGmS5wioXIKzhiV D21y3TEGIYWf1RQBFLuo+a2N+YPPuRApL7a0Du44GM0R03gGhdzzRSOLbsqs+FzLJDjO FjWryhW5iBlmLYwUFUagIbIbNSUp3E9DcK8gFcH9M6u6ZiAtW4INfNiuohwIUIAP4yGN dp+eimq6MO13ajcn8KtDOChTv8yD+Bhx5uf48NhZwUZWoKAEzFjE8j3bxy2sYYtjAfg3 dswQ== X-Gm-Message-State: AMCzsaXoTpIjLLbyPzVFwdK7nqm9jGsF2orXRWzHGyO62gobIr6Vfuol D2hEVEq2xIl4SrmVCpX7GEqV/g== X-Google-Smtp-Source: ABhQp+ShpbmU9sjiSDD1kTo3DWaPSaaLEWCZtRmI2S5OS+SLYc3fwMBNVxsLYWKg+qjntH5IDe8qGA== X-Received: by 10.98.133.28 with SMTP id u28mr4283811pfd.241.1509638723494; Thu, 02 Nov 2017 09:05:23 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id t18sm7392899pfi.98.2017.11.02.09.05.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 09:05:22 -0700 (PDT) Subject: [PATCH] RISC-V: Handle non-legitimate address in riscv_legitimize_move Date: Thu, 2 Nov 2017 09:03:19 -0700 Message-Id: <20171102160319.3834-1-palmer@dabbelt.com> Cc: patches@groups.riscv.org, Kito Cheng From: Palmer Dabbelt To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes From: Kito Cheng GCC may generate non-legitimate address due to we allow some load/store with non-legitimate address in pic.md. gcc/ChangeLog 2017-11-02 Kito Cheng * config/riscv/riscv.c (riscv_legitimize_move): Handle non-legitimate address. --- gcc/config/riscv/riscv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index c34468e018d6..b81a2d29fbfd 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -1332,6 +1332,22 @@ riscv_legitimize_move (machine_mode mode, rtx dest, rtx src) return true; } + /* RISC-V GCC may generate non-legitimate address due to we provide some + pattern for optimize access PIC local symbol and it's make GCC generate + unrecognizable instruction during optmizing. */ + + if (MEM_P (dest) && !riscv_legitimate_address_p (mode, XEXP (dest, 0), + reload_completed)) + { + XEXP (dest, 0) = riscv_force_address (XEXP (dest, 0), mode); + } + + if (MEM_P (src) && !riscv_legitimate_address_p (mode, XEXP (src, 0), + reload_completed)) + { + XEXP (src, 0) = riscv_force_address (XEXP (src, 0), mode); + } + return false; }