From patchwork Thu Oct 2 13:51:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 395956 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 EE9EC140188 for ; Thu, 2 Oct 2014 23:52:13 +1000 (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=mkQ0pStWM3Cr3g3En jmZOXpi8YwBt+sJ8uap4p1rGzmwrfos23kTlRDF2jTL3wlQK5pv4YXftCyOEY4IR XItiPGQX/wWPw2y8g/RUAwqaH7qMxr1uMoIELjhhLNyXpRFTdhMFASCNKFiG2b70 XgMyKFv+Jahb/7JjzTmCWcGUro= 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=O6ibw9+4Daecp+aD+6AobpM z8h4=; b=mUZoXBYBq0RYOEKbXQkrNDay9L49DtlRwgyf4dDb7hu710Kj61egfKp wIgeiF3QNnySmncSR3/C5fzqW76w6M4272Yb0EbUUkVdEEuOx1mILNOwJhz9qlTc uekZDTcrWRBhtVH8qmsKZiwcG8TnXzILWnbHnjIYF59bEIhfF1f0= Received: (qmail 26061 invoked by alias); 2 Oct 2014 13:52:07 -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 26037 invoked by uid 89); 2 Oct 2014 13:52:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 02 Oct 2014 13:52:04 +0000 Received: by mail-pa0-f51.google.com with SMTP id lj1so2417110pab.24 for ; Thu, 02 Oct 2014 06:52:02 -0700 (PDT) X-Received: by 10.69.17.234 with SMTP id gh10mr5128411pbd.0.1412257922726; Thu, 02 Oct 2014 06:52:02 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.42]) by mx.google.com with ESMTPSA id ps7sm3629601pbb.73.2014.10.02.06.52.00 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Oct 2014 06:52:02 -0700 (PDT) Date: Thu, 2 Oct 2014 17:51:56 +0400 From: Ilya Enkovich To: Uros Bizjak Cc: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH, i386, Pointer Bounds Checker 30/x] Size relocation Message-ID: <20141002135156.GE28697@msticlxl57.ims.intel.com> References: <20140917183534.GD3628@msticlxl57.ims.intel.com> <20140918140033.GB50194@msticlxl57.ims.intel.com> <20141002082330.GB28697@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 02 Oct 11:49, Uros Bizjak wrote: > On Thu, Oct 2, 2014 at 10:23 AM, Ilya Enkovich wrote: > > > 2014-10-01 Ilya Enkovich > > > > * config/i386/i386.md (UNSPEC_SIZEOF): New. > > (move_size_reloc_): New. > > * config/i386/predicates.md (symbol_operand): New. > > (x86_64_immediate_size_operand): New. > > OK with a trivial adjustment. > > Thanks, > Uros. > > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > index 65990b1..1901023 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 > > @@ -18789,6 +18790,21 @@ > > "bndstx\t{%2, %3|%3, %2}" > > [(set_attr "type" "mpxst")]) > > > > +(define_insn "move_size_reloc_" > > + [(set (match_operand:SWI48 0 "register_operand" "=r") > > + (unspec:SWI48 > > + [(match_operand:SWI48 1 "symbol_operand")] > > + UNSPEC_SIZEOF))] > > + "TARGET_MPX" > > +{ > > + if (x86_64_immediate_size_operand (operands[1], VOIDmode)) > > + return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}"; > > + else > > + return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}"; > > +} > > + [(set_attr "type" "imov") > > + (set_attr "mode" "")]) > > + > > (include "mmx.md") > > (include "sse.md") > > (include "sync.md") > > diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md > > index fea7754..1875339 100644 > > --- a/gcc/config/i386/predicates.md > > +++ b/gcc/config/i386/predicates.md > > @@ -124,6 +124,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") > > @@ -336,6 +340,14 @@ > > return false; > > }) > > > > +;; Return true if size of VALUE can be stored in a sign > > +;; extended immediate field. > > +(define_predicate "x86_64_immediate_size_operand" > > + (and (match_code "symbol_ref") > > + (ior (not (match_test "TARGET_64BIT")) > > + (ior (match_test ("ix86_cmodel == CM_SMALL")) > > + (match_test ("ix86_cmodel == CM_KERNEL")))))) > > Uh yes, I did a trivial thinko. Please note that above (ior) can be > rewritten with a multiple arguments: > > (define_predicate "x86_64_immediate_size_operand" > (and (match_code "symbol_ref") > (ior (not (match_test "TARGET_64BIT")) > (match_test "ix86_cmodel == CM_SMALL") > (match_test "ix86_cmodel == CM_KERNEL")))) > > Also, there were unneded parenthesis for match_test removed. > > > ;; Return true if OP is general operand representable on x86_64. > > (define_predicate "x86_64_general_operand" > > (if_then_else (match_test "TARGET_64BIT") Thanks for comments! Here is adjusted version. Ilya --- 2014-10-02 Ilya Enkovich * config/i386/i386.md (UNSPEC_SIZEOF): New. (move_size_reloc_): New. * config/i386/predicates.md (symbol_operand): New. (x86_64_immediate_size_operand): New. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 65990b1..1901023 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 @@ -18789,6 +18790,21 @@ "bndstx\t{%2, %3|%3, %2}" [(set_attr "type" "mpxst")]) +(define_insn "move_size_reloc_" + [(set (match_operand:SWI48 0 "register_operand" "=r") + (unspec:SWI48 + [(match_operand:SWI48 1 "symbol_operand")] + UNSPEC_SIZEOF))] + "TARGET_MPX" +{ + if (x86_64_immediate_size_operand (operands[1], VOIDmode)) + return "mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE}"; + else + return "movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE}"; +} + [(set_attr "type" "imov") + (set_attr "mode" "")]) + (include "mmx.md") (include "sse.md") (include "sync.md") diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index fea7754..3aebe2b 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -124,6 +124,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") @@ -336,6 +340,14 @@ return false; }) +;; Return true if size of VALUE can be stored in a sign +;; extended immediate field. +(define_predicate "x86_64_immediate_size_operand" + (and (match_code "symbol_ref") + (ior (not (match_test "TARGET_64BIT")) + (match_test "ix86_cmodel == CM_SMALL") + (match_test "ix86_cmodel == CM_KERNEL")))) + ;; Return true if OP is general operand representable on x86_64. (define_predicate "x86_64_general_operand" (if_then_else (match_test "TARGET_64BIT")