From patchwork Thu Aug 22 11:44:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 1151529 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-507508-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kJYnODpy"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hfMd12my"; 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 46DjP34rRgz9sML for ; Thu, 22 Aug 2019 21:44:21 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=riWUr/oWXV4tUA3d ZoEEfCqrlmytDoEaZ8CD+THhpStNnRLuZrw88mP/VQCcNBm46ayXKHbLsN7aIeFU 74vnMRGzxPnVz0ZJTX2hrQMsk0oSTPgFTJP0uhyi/KlH2U2jWL6XFxIg7Lx15pQ1 zTkv7Ez0ux+goPaiHHnboLfQiAI= 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:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=yyyDnQNFPznQ1JY568v9pC FPH14=; b=kJYnODpyF+wsLJ1K/TR0odU53xbjoJhQCFC1FoTIZWfg/laWQ2LbAJ j6JBZvVy4/HWmADOjfe7JpsrsLgDmQuQ0RWYlg8Hrb8+i8jfsEbf5YMYWfX1e4GS EB/jbx4i5tJT38kuGusHPPaBXqIigBBTHhrDCFcp0UlvTi76oQSn8= Received: (qmail 2807 invoked by alias); 22 Aug 2019 11:44:13 -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 2794 invoked by uid 89); 22 Aug 2019 11:44:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=2026, HX-Spam-Relays-External:209.85.210.195, H*RU:209.85.210.195, H*r:sk:mail-pf X-HELO: mail-pf1-f195.google.com Received: from mail-pf1-f195.google.com (HELO mail-pf1-f195.google.com) (209.85.210.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Aug 2019 11:44:11 +0000 Received: by mail-pf1-f195.google.com with SMTP id 196so3782413pfz.8 for ; Thu, 22 Aug 2019 04:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=L0G+utkjBR3O+0L+Oin/w/vPeqfyZ8dIZAi0rtCsjbg=; b=hfMd12mykaGZP5RizXJVPlfpSE57fufTUCmUn3ioYT/4j2bz69RX8VpQrMFCvAChGO 4tyzEs6k+haxwncqHrasOKkI2dmzvEsOmxSUUevRnQjGMDkiRGAbbEDO05fSqEUOCSYi 26v/4XmK9kloM7nbZ8ZmCc/s7gxRfGKGAThMqoBo0BXcUx/uxDREPatzJ/lvy7fBhQae BmkgNkDbsHY8RwSYyJ6gdcV29N2Av3C+uesh+k+gPIJBhr5HI4jlKfzP0KJ8sfPqP7/U IellAWlX3UEJ25acafhBXvC5vECP0Ff/x0tRLQSXKdBvY+4NnTXZfXaGLZ1DiUxEd48I Sc9A== Received: from localhost (g75.222-224-160.ppp.wakwak.ne.jp. [222.224.160.75]) by smtp.gmail.com with ESMTPSA id a12sm22382606pgv.48.2019.08.22.04.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 04:44:09 -0700 (PDT) From: Stafford Horne To: GCC patches Cc: Openrisc , Richard Henderson , Stafford Horne Subject: [PATCH] or1k: Fix issue with set_got clobbering r9 Date: Thu, 22 Aug 2019 20:44:04 +0900 Message-Id: <20190822114404.1318-1-shorne@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes When compiling glibc we found that the GOT register was being allocated r9 when the instruction was still set_got_tmp. That caused set_got to clobber r9. We cannot simply say set_got_tmp clobbers r9 as this is the reason for having the temporary set_got_tmp. Fix by using a register class constraint that does not allow r9 during register allocation. gcc/ChangeLog: * config/or1k/constraints.md (t): New constraint. * config/or1k/or1k.h (GOT_REGS): New register class. * config/or1k/or1k.md (set_got_tmp, set_got): Use t contraint. --- gcc/config/or1k/constraints.md | 4 ++++ gcc/config/or1k/or1k.h | 3 +++ gcc/config/or1k/or1k.md | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/config/or1k/constraints.md b/gcc/config/or1k/constraints.md index 8cac7eb5329..ba330c6b8c2 100644 --- a/gcc/config/or1k/constraints.md +++ b/gcc/config/or1k/constraints.md @@ -25,6 +25,7 @@ ; We use: ; c - sibcall registers ; d - double pair base registers (excludes r0, r30 and r31 which overflow) +; t - got address registers (excludes r9 is clobbered by set_got) ; I - constant signed 16-bit ; K - constant unsigned 16-bit ; M - constant signed 16-bit shifted left 16-bits (l.movhi) @@ -36,6 +37,9 @@ (define_register_constraint "d" "DOUBLE_REGS" "Registers which can be used for double reg pairs.") +(define_register_constraint "t" "GOT_REGS" + "Registers which can be used to store the Global Offset Table (GOT) address.") + ;; Immediates (define_constraint "I" "A signed 16-bit immediate in the range -32768 to 32767." diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h index 2b29e62fdd3..4c32607bac1 100644 --- a/gcc/config/or1k/or1k.h +++ b/gcc/config/or1k/or1k.h @@ -190,6 +190,7 @@ enum reg_class NO_REGS, SIBCALL_REGS, DOUBLE_REGS, + GOT_REGS, GENERAL_REGS, FLAG_REGS, ALL_REGS, @@ -202,6 +203,7 @@ enum reg_class "NO_REGS", \ "SIBCALL_REGS", \ "DOUBLE_REGS", \ + "GOT_REGS", \ "GENERAL_REGS", \ "FLAG_REGS", \ "ALL_REGS" } @@ -215,6 +217,7 @@ enum reg_class { { 0x00000000, 0x00000000 }, \ { SIBCALL_REGS_MASK, 0 }, \ { 0x7f7ffffe, 0x00000000 }, \ + { 0xfffffdff, 0x00000000 }, \ { 0xffffffff, 0x00000003 }, \ { 0x00000000, 0x00000004 }, \ { 0xffffffff, 0x00000007 } \ diff --git a/gcc/config/or1k/or1k.md b/gcc/config/or1k/or1k.md index cee11d078cc..36bcee336ab 100644 --- a/gcc/config/or1k/or1k.md +++ b/gcc/config/or1k/or1k.md @@ -706,7 +706,7 @@ ;; set_got pattern below. This works because the set_got_tmp insn is the ;; first insn in the stream and that it isn't moved during RA. (define_insn "set_got_tmp" - [(set (match_operand:SI 0 "register_operand" "=r") + [(set (match_operand:SI 0 "register_operand" "=t") (unspec_volatile:SI [(const_int 0)] UNSPECV_SET_GOT))] "" { @@ -715,7 +715,7 @@ ;; The insn to initialize the GOT. (define_insn "set_got" - [(set (match_operand:SI 0 "register_operand" "=r") + [(set (match_operand:SI 0 "register_operand" "=t") (unspec:SI [(const_int 0)] UNSPEC_SET_GOT)) (clobber (reg:SI LR_REGNUM))] ""