From patchwork Fri Jul 13 16:11:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 141927 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp991432ljj; Fri, 13 Jul 2018 09:16:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcx7bzv9V+E5ERIqOyUXyZx95rLUDkoM2KzwOroTqNAKbphePGWRhzVilFnw+Wce9DmCE2Q X-Received: by 2002:a17:902:ba97:: with SMTP id k23-v6mr7028566pls.259.1531498584523; Fri, 13 Jul 2018 09:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531498584; cv=none; d=google.com; s=arc-20160816; b=oUo7Gx/+2UTUa0vMN6iw6XbFOsIgsnF1S7FyplVsak3lJoxBERh7SOCMTY6orLChAH +cwUbFz8nEZ5DkZukAMfqNIzXVyV3p3tY3Ntib+/P3AOR2HUdloqPcfSQZgcDlpOyzgZ cw/GxAnz9eirkslu15FSeU1ICh0C8wb0JYpo9ekEQSRfaW0Yml8sdqBBABPmxoRBNB3b dV1GxOzMx8pPp9CZ40g7meWI5pDA3U9sCLHr2ntz+5DLGmA2DRrhOjy1kgYbze9QD1YW 1zh+LXc4eSnFF8nCl+f6eztJhUdjBNGWIoesBaTrSeFhYE0BnaIGHyF/4XCVcIJNEaDY HaIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=MmasSM1D7rynm/t52+S0Jb+iwGl+Y56QKnG/62VvugI=; b=byBltqk3vbKsmzL8r5ufFuGWJAuGfbEGPCWhhF7uVQr20uWBKCNQyaKbpKAp004Iyh 6Qp90sU80Fiks5jZBRsojr/ylC8mGBu9IvdOQ/RaMsIu/uJ9d4fZGYHG5mFM/8sLfGqU e81rCt+TJLTZFVOfaZc7Q/PvZjGb49kEGWRAjDPYlAvRnz1EYrYAzHdbWD/fkLKjdiTp JTeqTWYNWtKvuG+iGZJYt6qcECAQzCV0CBFChYYqs9VmTEE4ysiFKz31Ii/c6UseVl99 Zuk/wWXEZDnh29LALsrJ0qgxI4QbIs9BM7Hzm03w2XQavjY7aKzjRS14lcQxEPa41Zmw LbCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PlJvtYXl; spf=pass (google.com: domain of gcc-patches-return-481522-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-481522-patch=linaro.org@gcc.gnu.org" Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 91-v6si23757302ply.296.2018.07.13.09.16.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 09:16:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-481522-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PlJvtYXl; spf=pass (google.com: domain of gcc-patches-return-481522-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-481522-patch=linaro.org@gcc.gnu.org" 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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=kpWbYyjZ/CVkdxWMk9SvqetFPToKwSXrvEiD6wqh4ViAFnHMZYIjd Oxkam/OPQnZTZvg9gpYFB+c5tIEH2K/XXMisVljMahUO8CL2ivTLHSJNlGirV2g3 z5WXgmQ8eW/CS41AekujKFMVvi1ikWlhlZHPd4pDL5GVXhBloBLlio= 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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=hSsF4ABO2I0NpqNH2q/fMxx/2Aw=; b=PlJvtYXlTSeBNwkzKAOZ8C6XM/D3 VLffIEkyfFTZVLxyvw3kvsrn7XYiKOwKQSkGze0jdM1/rDygXMoP59hcOxu9SEme OP/e6v/4Xn41dIMhxtKm4pM9orWdk2K1WVL7jdpsAKs4njdDZ44UKFreFMhVELbm d+rYxEbKwtsglaQ= Received: (qmail 32754 invoked by alias); 13 Jul 2018 16:16:08 -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 32619 invoked by uid 89); 13 Jul 2018 16:16:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jul 2018 16:16:05 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6DGEBtj008277; Fri, 13 Jul 2018 18:16:03 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2k6y3vr2mu-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 13 Jul 2018 18:16:03 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 97F7B31; Fri, 13 Jul 2018 16:16:02 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 80184A6BA; Fri, 13 Jul 2018 16:16:02 +0000 (GMT) Received: from gnb.st.com (10.75.127.48) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 13 Jul 2018 18:16:01 +0200 From: To: CC: Subject: [ARM/FDPIC v2 12/21] [ARM] FDPIC: Restore r9 after we call __aeabi_read_tp Date: Fri, 13 Jul 2018 18:11:07 +0200 Message-ID: <20180713161136.29104-13-christophe.lyon@st.com> In-Reply-To: <20180713161136.29104-1-christophe.lyon@st.com> References: <20180713161136.29104-1-christophe.lyon@st.com> MIME-Version: 1.0 X-IsSubscribed: yes From: Christophe Lyon We call __aeabi_read_tp() to get the thread pointer. Since this is a function call, we have to restore the FDPIC register afterwards. 2018-XX-XX Christophe Lyon Mickaël Guêné gcc/ * config/arm/arm.c (arm_load_tp): Add FDPIC support. * config/arm/arm.md (load_tp_soft_fdpic): New pattern. (load_tp_soft): Disable in FDPIC mode. Change-Id: I0a2e3466c9afb869ad8e844083ad178de014658e -- 2.6.3 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5d32f6a..91b000e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -8669,7 +8669,25 @@ arm_load_tp (rtx target) rtx tmp; - emit_insn (gen_load_tp_soft ()); + if (TARGET_FDPIC) + { + rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (3)); + + emit_insn (gen_load_tp_soft_fdpic ()); + + /* Restore r9. */ + XVECEXP (par, 0, 0) + = gen_rtx_UNSPEC (VOIDmode, + gen_rtvec (2, gen_rtx_REG (Pmode, FDPIC_REGNUM), + get_hard_reg_initial_val (Pmode, FDPIC_REGNUM)), + UNSPEC_PIC_RESTORE); + XVECEXP (par, 0, 1) = gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode, FDPIC_REGNUM)); + XVECEXP (par, 0, 2) + = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, FDPIC_REGNUM)); + emit_insn (par); + } + else + emit_insn (gen_load_tp_soft ()); tmp = gen_rtx_REG (SImode, R0_REGNUM); emit_move_insn (target, tmp); diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index a699a60..9259b08 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -11485,12 +11485,25 @@ ) ;; Doesn't clobber R1-R3. Must use r0 for the first operand. +(define_insn "load_tp_soft_fdpic" + [(set (reg:SI 0) (unspec:SI [(const_int 0)] UNSPEC_TLS)) + (clobber (reg:SI 9)) + (clobber (reg:SI LR_REGNUM)) + (clobber (reg:SI IP_REGNUM)) + (clobber (reg:CC CC_REGNUM))] + "TARGET_SOFT_TP && TARGET_FDPIC" + "bl\\t__aeabi_read_tp\\t@ load_tp_soft" + [(set_attr "conds" "clob") + (set_attr "type" "branch")] +) + +;; Doesn't clobber R1-R3. Must use r0 for the first operand. (define_insn "load_tp_soft" [(set (reg:SI 0) (unspec:SI [(const_int 0)] UNSPEC_TLS)) (clobber (reg:SI LR_REGNUM)) (clobber (reg:SI IP_REGNUM)) (clobber (reg:CC CC_REGNUM))] - "TARGET_SOFT_TP" + "TARGET_SOFT_TP && !TARGET_FDPIC" "bl\\t__aeabi_read_tp\\t@ load_tp_soft" [(set_attr "conds" "clob") (set_attr "type" "branch")]