From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5351 invoked by alias); 16 Nov 2007 21:00:14 -0000 Received: (qmail 5341 invoked by uid 22791); 16 Nov 2007 21:00:13 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 16 Nov 2007 21:00:11 +0000 Received: (qmail 18563 invoked from network); 16 Nov 2007 21:00:09 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 16 Nov 2007 21:00:09 -0000 Date: Fri, 16 Nov 2007 22:34:00 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: zadeck@naturalbridge.com Subject: [lto] fix reading vector types Message-ID: <20071116210007.GJ24671@codesourcery.com> Mail-Followup-To: gcc-patches@gcc.gnu.org, zadeck@naturalbridge.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg00931.txt.bz2 We added support for reading the DW_AT_GNU_vector attribute a while back; we now add logic for modifying our behaviour based on that attribute. Committed to the LTO branch. -Nathan 2007-11-16 Nathan Froyd * lto.c (lto_read_array_type_DIE): Handle DIEs with DW_AT_GNU_vector set properly by building a VECTOR_TYPE instead of an ARRAY_TYPE. Index: lto.c =================================================================== --- lto.c (revision 130235) +++ lto.c (working copy) @@ -1486,16 +1486,20 @@ lto_read_array_type_DIE (lto_info_fd *fd int ndims; int order = -1; int i, istart, iend; + bool is_vector = false; LTO_BEGIN_READ_ATTRS () { case DW_AT_decl_column: case DW_AT_decl_file: case DW_AT_decl_line: - case DW_AT_GNU_vector: /* Ignore. */ break; + case DW_AT_GNU_vector: + is_vector = true; + break; + case DW_AT_type: type = lto_read_referenced_type_DIE (fd, context, @@ -1536,29 +1540,51 @@ lto_read_array_type_DIE (lto_info_fd *fd dims = lto_collect_child_DIEs (fd, abbrev, context); ndims = VEC_length (tree, dims); - /* Construct and cache the array type object for our caller. */ - if (ndims == 0) - type = build_array_type (type, NULL_TREE); + if (is_vector) + { + /* We should have a lone child DIE describing how many packed + elements this vector type has. The DW_AT_type attribute + describes the type of the vector elements. */ + tree range; + tree upper_bound; + HOST_WIDE_INT count; + + gcc_assert (ndims == 1); + + range = VEC_index (tree, dims, 0); + upper_bound = TYPE_MAX_VALUE (range); + count = TREE_INT_CST_LOW (upper_bound); + + /* RANGE describes the indices of the vector, so we need to add 1 + to find the number of elements. */ + type = build_vector_type (type, (int) count + 1); + } else { - if (order == -1) - { - istart = ndims - 1; - iend = -1; - } + /* Construct and cache the array type object for our caller. */ + if (ndims == 0) + type = build_array_type (type, NULL_TREE); else - { - gcc_assert (order == 1); - istart = 0; - iend = ndims; - } - for (i = istart; i != iend; i += order) - { - tree dim = VEC_index (tree, dims, i); - if (!dim || ! INTEGRAL_TYPE_P (dim)) - lto_file_corrupt_error ((lto_fd *)fd); - type = build_array_type (type, dim); - } + { + if (order == -1) + { + istart = ndims - 1; + iend = -1; + } + else + { + gcc_assert (order == 1); + istart = 0; + iend = ndims; + } + for (i = istart; i != iend; i += order) + { + tree dim = VEC_index (tree, dims, i); + if (!dim || ! INTEGRAL_TYPE_P (dim)) + lto_file_corrupt_error ((lto_fd *)fd); + type = build_array_type (type, dim); + } + } } VEC_free (tree, heap, dims); return type;