From patchwork Tue Nov 19 20:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 292570 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A39E62C00BD for ; Wed, 20 Nov 2013 07:46:07 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=VT5g33Gne1AjEqGKx cB9rjpl/I/pwuMv0qFv/pv7HkBf6FxfILM0Kq1unLvxX2iewZQldb4ujZI9gFK8j xg9D0yJJ6iuegNKFFoh8lUW7zW+RD1ibvEIEZkbiEkrajdHi2MsESrHH5Li8eeta 9Ij9iXyGDjHSEXcJSu8HkpOEOY= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=7nFBbPp+vUXqSUQkxl5nZUc Ot1Y=; b=NAkZ6nDwqd6VQCkCJMQrESIHldypnnjqxpEOtDZTw1FKt/1STGSVLLn LGMDisKpOkCON8IP7m7eQbfh/6wCcjBduSd2jY/bV6vmqxy5sIy3ne/3fDfdyAy2 Bc7vZ+06H3i9efK2MzHKtxpfzcsEW1rkw0fCnnMCx/j31sH2M2/U= Received: (qmail 32061 invoked by alias); 19 Nov 2013 20:45:57 -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 32042 invoked by uid 89); 19 Nov 2013 20:45:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.2 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-pb0-f49.google.com Received: from Unknown (HELO mail-pb0-f49.google.com) (209.85.160.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 19 Nov 2013 20:44:42 +0000 Received: by mail-pb0-f49.google.com with SMTP id jt11so4271619pbb.8 for ; Tue, 19 Nov 2013 12:44:34 -0800 (PST) X-Received: by 10.66.219.233 with SMTP id pr9mr28146818pac.45.1384893874728; Tue, 19 Nov 2013 12:44:34 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by mx.google.com with ESMTPSA id fk4sm36900522pab.23.2013.11.19.12.44.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Nov 2013 12:44:33 -0800 (PST) Date: Wed, 20 Nov 2013 00:43:44 +0400 From: Ilya Enkovich To: Uros Bizjak Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH, i386, MPX, 2/X] Pointers Checker [21/25] Size relocation Message-ID: <20131119204344.GU21297@msticlxl57.ims.intel.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 18 Nov 22:00, Uros Bizjak wrote: > Hello! > > > Here is a patch to add size relocation and instruction to obtain object's size in i386 target. > > +(define_insn "move_size_reloc_" > + [(set (match_operand:SWI48 0 "register_operand" "=r") > + (match_operand: 1 "size_relocation" "Z"))] > + "" > +{ > + return "mov{}\t{%1, %0|%0, %1}"; > > Please don't change x86_64_immediate_operand just to use "Z" > constraint The predicate is used in a couple of other places that for > sure don't accept your change. > > Better write this insn in an explicit way (see for example > tls_initial_exec_64_sun). Something like: > > (define_insn "move_size_reloc_" > [(set (match_operand:SWI48 0 "register_operand" "=r") > (unspec:SWI48 > [(match_operand 1 "symbolic_operand" "..." )] > UNSPEC_SIZEOF))] > "" > "mov{}\t{%a1@SIZE, %0|%0, %a1@SIZE}") > > You will probably need to define new operand 1 predicate and constraint. > > Uros. Hi, Uros! Thanks for comments! Here is what I got trying to follow your suggestion. Does it look better? Thanks, Ilya --- 2013-11-19 Ilya Enkovich * config/i386/i386.md (UNSPEC_SIZEOF): New. (move_size_reloc_): New. * gcc/config/i386/constraints.md (TS): New. * config/i386/predicates.md (symbol_operand): New. diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index 7289ae4..1697065 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -241,6 +241,7 @@ ;; s - address with no segment register ;; i - address with no index and no rip ;; b - address with no base and no rip +;; S - symbol reference (define_address_constraint "Tv" "VSIB address operand" @@ -257,3 +258,7 @@ (define_address_constraint "Tb" "MPX address operand without base" (match_operand 0 "address_mpx_no_base_operand")) + +(define_address_constraint "TS" + "Symbol reference" + (match_operand 0 "symbol_operand")) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index e23b3b6..dc7d81a 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -79,6 +79,7 @@ UNSPEC_PLTOFF UNSPEC_MACHOPIC_OFFSET UNSPEC_PCREL + UNSPEC_SIZEOF ;; Prologue support UNSPEC_STACK_ALLOC @@ -18446,6 +18447,14 @@ "bndstx\t{%2, %3|%3, %2}" [(set_attr "type" "mpxst")]) +(define_insn "move_size_reloc_" + [(set (match_operand:SWI48 0 "register_operand" "=r") + (unspec: + [(match_operand: 1 "symbol_operand" "TS")] + UNSPEC_SIZEOF))] + "" + "mov{}\t{$%p1@SIZE, %0|%0, $%p1@SIZE}") + (include "mmx.md") (include "sse.md") (include "sync.md") diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 66ac52f..5c758ab 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -119,6 +119,10 @@ (match_test "TARGET_64BIT") (match_test "REGNO (op) > BX_REG"))) +;; Return true if VALUE is symbol reference +(define_predicate "symbol_operand" + (match_code "symbol_ref")) + ;; Return true if VALUE can be stored in a sign extended immediate field. (define_predicate "x86_64_immediate_operand" (match_code "const_int,symbol_ref,label_ref,const")