From patchwork Thu Oct 8 04:59:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 527603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 D36B31402A8 for ; Thu, 8 Oct 2015 16:02:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ymL5VkFB; dkim-atps=neutral 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:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=evdIQLL1IqXeygvoPci162Rn+1j6ZgVX5ICK0F3fV8ojmnyMf3qJV FD7Gw8ISeXdDTPoGGBM/kYPNAa6boCDjZI4O+NuwkgUbYBWY9BVCI3NSJdcuc/ZK 7b6yCaCsNGlxDWN+gsqFRUubfyhevRoFXG218FBQs11N1GEhafSnJg= 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:subject:date:message-id:in-reply-to:references; s=default; bh=kSZHKYZufikStLB2DS/K6RWTA74=; b=ymL5VkFBsFDyBzKI8bOqR2RHlDM8 dxCpzuWoFp93wEPHBwgZ1V2tsS0F0cWE+kUcZGLyZMTCczWH+HYVa1kvNP90c/ih ToLcibdR3lpCsAt1pyUzc9sG4+wo06iNPH9Wvm9AtX0mPcHkq3RFxiEjWVFOfRoa feM7JZCuvUQpj6U= Received: (qmail 68954 invoked by alias); 8 Oct 2015 05:00:47 -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 68671 invoked by uid 89); 8 Oct 2015 05:00:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f53.google.com Received: from mail-pa0-f53.google.com (HELO mail-pa0-f53.google.com) (209.85.220.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 08 Oct 2015 05:00:35 +0000 Received: by pablk4 with SMTP id lk4so42707518pab.3 for ; Wed, 07 Oct 2015 22:00:33 -0700 (PDT) X-Received: by 10.67.16.15 with SMTP id fs15mr5800404pad.82.1444280433201; Wed, 07 Oct 2015 22:00:33 -0700 (PDT) Received: from bigtime.com ([1.144.5.178]) by smtp.gmail.com with ESMTPSA id a17sm42581270pbu.55.2015.10.07.22.00.32 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Oct 2015 22:00:32 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Subject: [PATCH 7/9] i386: Add address space for tls Date: Thu, 8 Oct 2015 15:59:33 +1100 Message-Id: <1444280375-20866-8-git-send-email-rth@redhat.com> In-Reply-To: <1444280375-20866-1-git-send-email-rth@redhat.com> References: <1444280375-20866-1-git-send-email-rth@redhat.com> X-IsSubscribed: yes * config/i386/i386-protos.h (ADDR_SPACE_SEG_TLS): New. * config/i386/i386-c.c (ix86_target_macros): Define __SEG_TLS. (ix86_register_pragmas): Register __seg_tls. * config/i386/i386.c (ix86_print_operand_address_as): Handle ADDR_SPACE_SEG_TLS. (ix86_addr_space_subset_p): New. (TARGET_ADDR_SPACE_SUBSET_P): New. (ix86_addr_space_convert): New. (TARGET_ADDR_SPACE_CONVERT): New. --- gcc/config/i386/i386-c.c | 2 ++ gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/i386.c | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c index e21b947..71c12de 100644 --- a/gcc/config/i386/i386-c.c +++ b/gcc/config/i386/i386-c.c @@ -595,6 +595,7 @@ ix86_target_macros (void) cpp_define (parse_in, "__SEG_FS"); cpp_define (parse_in, "__SEG_GS"); + cpp_define (parse_in, "__SEG_TLS"); } @@ -611,6 +612,7 @@ ix86_register_pragmas (void) c_register_addr_space ("__seg_fs", ADDR_SPACE_SEG_FS); c_register_addr_space ("__seg_gs", ADDR_SPACE_SEG_GS); + c_register_addr_space ("__seg_tls", ADDR_SPACE_SEG_TLS); #ifdef REGISTER_SUBTARGET_PRAGMAS REGISTER_SUBTARGET_PRAGMAS (); diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 4e6d9ad..026b778 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -328,3 +328,4 @@ struct ix86_first_cycle_multipass_data_ const addr_space_t ADDR_SPACE_SEG_FS = 1; const addr_space_t ADDR_SPACE_SEG_GS = 2; +const addr_space_t ADDR_SPACE_SEG_TLS = 3; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index f5a0b8f..f7abb00 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -17296,6 +17296,8 @@ ix86_print_operand_address_as (FILE *file, rtx addr, addr_space_t as) { const char *string; + if (as == ADDR_SPACE_SEG_TLS) + as = DEFAULT_TLS_SEG_REG; if (as == ADDR_SPACE_SEG_FS) string = (ASSEMBLER_DIALECT == ASM_ATT ? "%fs:" : "fs:"); else if (as == ADDR_SPACE_SEG_GS) @@ -53629,8 +53631,43 @@ ix86_operands_ok_for_move_multiple (rtx *operands, bool load, without resorting to a system call, we cannot convert a non-default address space to a default address space. Therefore we do not claim %fs or %gs are subsets of generic. + (e) However, __seg_tls uses UNSPEC_TP as the base (which itself is + stored at __seg_tls:0) so we can map between tls and generic. */ - Therefore, we need not override any of the address space hooks. */ +static bool +ix86_addr_space_subset_p (addr_space_t subset, addr_space_t superset) +{ + return (subset == superset + || (superset == ADDR_SPACE_GENERIC + && subset == ADDR_SPACE_SEG_TLS)); +} +#undef TARGET_ADDR_SPACE_SUBSET_P +#define TARGET_ADDR_SPACE_SUBSET_P ix86_addr_space_subset_p + +static rtx +ix86_addr_space_convert (rtx op, tree from_type, tree to_type) +{ + addr_space_t from_as = TYPE_ADDR_SPACE (TREE_TYPE (from_type)); + addr_space_t to_as = TYPE_ADDR_SPACE (TREE_TYPE (to_type)); + + /* Conversion between SEG_TLS and GENERIC is handled by adding or + subtracting the thread pointer. */ + if ((from_as == ADDR_SPACE_GENERIC && to_as == ADDR_SPACE_SEG_TLS) + || (from_as == ADDR_SPACE_SEG_TLS && to_as == ADDR_SPACE_GENERIC)) + { + machine_mode mode = GET_MODE (op); + if (mode == VOIDmode) + mode = ptr_mode; + rtx tp = get_thread_pointer (mode, optimize || mode != ptr_mode); + return expand_binop (mode, (to_as == ADDR_SPACE_GENERIC + ? add_optab : sub_optab), + op, tp, NULL, 1, OPTAB_WIDEN); + } + + return op; +} +#undef TARGET_ADDR_SPACE_CONVERT +#define TARGET_ADDR_SPACE_CONVERT ix86_addr_space_convert /* Initialize the GCC target structure. */ #undef TARGET_RETURN_IN_MEMORY