From patchwork Thu Aug 4 04:12:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 73235 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1187253qga; Wed, 3 Aug 2016 21:13:37 -0700 (PDT) X-Received: by 10.98.206.129 with SMTP id y123mr122169780pfg.7.1470284017348; Wed, 03 Aug 2016 21:13:37 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id xv4si12369525pab.153.2016.08.03.21.13.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Aug 2016 21:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-433142-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; spf=pass (google.com: domain of gcc-patches-return-433142-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-433142-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.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:subject:message-id:date:mime-version:content-type; q=dns; s= default; b=FUmeZMRAdEs5oF4HmUItwDFxDvjq3171Z4+28JNl8H3Zvq2wzov/W tzGEJY2OrPs/GsoIg/dacTv5/U2fPUvQyPISowEAT3Q9zzzdnlCjUFxbNNi6fTSa zkEJcmJkwakzSbU/tUZfDUQrwD0I7H58kuO91VoVpy4VHBs16qY8KI= 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:message-id:date:mime-version:content-type; s= default; bh=gVihjIKbJyt3m7YQzn4uaJB7V30=; b=Kh7Bn1ym5fXk8T2aoJP3 zN71yDl43W1kGb5gpRMEIuqPQmt6aPfqQ8j5+cnFHXFKZRU6gtq442ndqg0uva8g xZsc3MoLHwKIkKDwJUtOkdKqWGu8Ly1+xAr2If2NlEzyIU8lVg51/cPiQUUtY0M4 kN5OEmjM+0okoXAFgq8NX6o= Received: (qmail 78551 invoked by alias); 4 Aug 2016 04:13:25 -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 78535 invoked by uid 89); 4 Aug 2016 04:13:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=streaming, sk:stream_, sk:streame, data_in X-HELO: mail-pf0-f181.google.com Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 04 Aug 2016 04:13:14 +0000 Received: by mail-pf0-f181.google.com with SMTP id x72so83510155pfd.2 for ; Wed, 03 Aug 2016 21:13:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version; bh=GEy+lKOYub3SzjEQXKRJYq2MuB+Bh7Guz6jO/yN/bY8=; b=NG0cxXpr4FVyYuV5waXPkmPA9NEQ1Ik5ByL15aMGJWm10psmdg67BzcyIDrz2HyUvA JlbNKqEA5V7F73bn9byXGxZtzMulNtsIvPjN0OnXmQQWIpnP+u8EFgcChTF5RziQfnlD Em/PArX7F8HwzM+r5b20RXIsLr0NO/F2OjRIVIuN5jETlY/6MBryxlswNllusOZoX0vd 8BWty9uesY/x3J9E3O2ZX6VcykcXsSY8dGnR+ahelGGvgtzN9OVJMNULJcu2zEDWyvUz SXai3Mt+hGtDIaQu1vvgbBKTZa1O2bhK2WfW8q/UWsmBfA6dvIGrod67xA1Xwai68h+O uLVw== X-Gm-Message-State: AEkoouu84TvmT9BkMUj+FjjAAevfeVbqnviFwoBJ6/ol+mDMdaSUiY3TJkHCSFnioeBVwE2P X-Received: by 10.98.102.221 with SMTP id s90mr121605957pfj.69.1470283992759; Wed, 03 Aug 2016 21:13:12 -0700 (PDT) Received: from [10.1.1.4] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id sk4sm15999844pac.16.2016.08.03.21.13.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Aug 2016 21:13:11 -0700 (PDT) From: kugan To: "gcc-patches@gcc.gnu.org" , Jan Hubicka , Richard Biener Subject: [LTO] Add wide_int streaming support Message-ID: Date: Thu, 4 Aug 2016 14:12:54 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, During IPA-VRP implementation, I realized that we don't support streaming wide_int in LTO. Attached patch does this. Tested with IPA-VRP. Is this OK for trunk if bootstrap and regression testing is fine. Thanks, Kugan gcc/ChangeLog: 2016-08-04 Kugan Vivekanandarajah * lto-streamer-in.c (lto_input_wide_int): New. * lto-streamer-out.c (lto_output_wide_int): Likewise. * lto-streamer.c (lto_streamer_hooks_init): Init write_wide_int and read_wide_int. * lto-streamer.h: Declare lto_input_wide_int and lto_output_wide_int. * streamer-hooks.h (struct streamer_hooks): Add write_wide_int and read_wide_int. (stream_write_wide_int): New macro. (stream_read_wide_int): Likewise. >From b3ae44f373dfb53e44e7e6bfd88a3cce3a3675a9 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Thu, 4 Aug 2016 11:54:00 +1000 Subject: [PATCH 6/8] Add wide_int streaming support --- gcc/lto-streamer-in.c | 14 ++++++++++++++ gcc/lto-streamer-out.c | 12 ++++++++++++ gcc/lto-streamer.c | 2 ++ gcc/lto-streamer.h | 2 ++ gcc/streamer-hooks.h | 9 +++++++++ 5 files changed, 39 insertions(+) diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 1d56d21..16ae1c1 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -1456,6 +1456,20 @@ lto_input_tree (struct lto_input_block *ib, struct data_in *data_in) return lto_input_tree_1 (ib, data_in, tag, 0); } +/* Read the physical representation of a wide_int val from + input block IB. */ + +wide_int +lto_input_wide_int (struct lto_input_block *ib) +{ + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; + int prec = streamer_read_uhwi (ib); + int len = streamer_read_uhwi (ib); + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + return wide_int_storage::from_array (a, len, prec); +} /* Input toplevel asms. */ diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index aa6b589..a563b77 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1553,6 +1553,18 @@ DFS::DFS_write_tree (struct output_block *ob, sccs *from_state, worklist_vec.safe_push (w); } +/* Emit the physical representation of wide_int VAL to output block OB. */ + +void +lto_output_wide_int (struct output_block *ob, const wide_int &val) +{ + int len = val.get_len (); + + streamer_write_uhwi (ob, val.get_precision ()); + streamer_write_uhwi (ob, len); + for (int i = 0; i < len; i++) + streamer_write_hwi (ob, val.elt (i)); +} /* Emit the physical representation of tree node EXPR to output block OB. If THIS_REF_P is true, the leaves of EXPR are emitted as references via diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index bfde1fe..e07a6f9 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -396,6 +396,8 @@ lto_streamer_hooks_init (void) streamer_hooks_init (); streamer_hooks.write_tree = lto_output_tree; streamer_hooks.read_tree = lto_input_tree; + streamer_hooks.write_wide_int = lto_output_wide_int; + streamer_hooks.read_wide_int = lto_input_wide_int; streamer_hooks.input_location = lto_input_location; streamer_hooks.output_location = lto_output_location; } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index ecc1e5d..b664342 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -874,6 +874,7 @@ hashval_t lto_input_scc (struct lto_input_block *, struct data_in *, tree lto_input_tree_1 (struct lto_input_block *, struct data_in *, enum LTO_tags, hashval_t hash); tree lto_input_tree (struct lto_input_block *, struct data_in *); +wide_int lto_input_wide_int (struct lto_input_block *); /* In lto-streamer-out.c */ @@ -892,6 +893,7 @@ void lto_output_decl_state_refs (struct output_block *, struct lto_out_decl_state *); void lto_output_location (struct output_block *, struct bitpack_d *, location_t); void lto_output_init_mode_table (void); +void lto_output_wide_int (struct output_block *, const wide_int &); /* In lto-cgraph.c */ diff --git a/gcc/streamer-hooks.h b/gcc/streamer-hooks.h index 0727048..7fc3078 100644 --- a/gcc/streamer-hooks.h +++ b/gcc/streamer-hooks.h @@ -51,6 +51,9 @@ struct streamer_hooks { tree instantiated from the stream. */ tree (*read_tree) (struct lto_input_block *, struct data_in *); + wide_int (*read_wide_int) (struct lto_input_block *); + void (*write_wide_int) (struct output_block *, const wide_int &); + /* [REQ] Called by every streaming routine that needs to read a location. */ void (*input_location) (location_t *, struct bitpack_d *, struct data_in *); @@ -73,6 +76,12 @@ struct streamer_hooks { #define stream_output_location(OB, BP, LOC) \ streamer_hooks.output_location (OB, BP, LOC) +#define stream_write_wide_int(OB, EXPR) \ + streamer_hooks.write_wide_int (OB, EXPR) + +#define stream_read_wide_int(IB, DATA_IN) \ + streamer_hooks.read_wide_int (IB, DATA_IN) + /* Streamer hooks. */ extern struct streamer_hooks streamer_hooks; -- 1.9.1