From patchwork Thu Jun 2 16:32:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 632773 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 3rQRp04bmgz9s0M for ; Fri, 10 Jun 2016 00:02:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nKyo2ltb; 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= yQFDqdW6M8SH3m+plLUgVHwkWnHwMtucTDK8Y2dWab8kxY+v0VFvRz3Ggiz7sW97 4aMoZmpNrdsYqc+K4iHJ0/i0DMaL+vyVZxlNXUwkB0cIRyIch1nNlxf9braKsINf Je+8IvSwVPApUQYI/xGHOTeSQK4OqUtuHpsTBDVhvIw= 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=Cnv/ PLs30pwJBB7zQWNn+up9cuk=; b=nKyo2ltbaziQN9ZNmezD9BZQZaMSbZ4q/GkP e9hhRM/aJ+rrZlw3C9sqvaqy/jRwFVLue0hs8C/biDSLX+LftFS2wc9Ly1R86vBI OCUgWs0HzPzMtv4sIBEnRDhJ5hNQl4PZ0IcL30bIIeJ3cxsbK7RHrvvGWe9hBesH eXZVzEY= Received: (qmail 89106 invoked by alias); 9 Jun 2016 14:01:19 -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 88880 invoked by uid 89); 9 Jun 2016 14:01:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1445, moments X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 09 Jun 2016 14:01:03 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A8772ADC2 for ; Thu, 9 Jun 2016 14:01:00 +0000 (UTC) Resent-From: Martin Jambor Resent-Date: Thu, 9 Jun 2016 16:01:00 +0200 Resent-Message-ID: <20160609140100.GC15281@virgil.suse.cz> Resent-To: GCC Patches Message-Id: <6d712c697c72d0d6359fd9e57f1b8e012565686e.1465479214.git.mjambor@suse.cz> In-Reply-To: References: From: Martin Jambor Date: Thu, 2 Jun 2016 18:32:39 +0200 Subject: [hsa-branch 2/5] Make emit_insn_operands handle zero operands To: GCC Patches X-IsSubscribed: yes Hi, the patch below allows emit_insn_operands to instructions with no operands gracefully. Apparently so far we have not produced any. I'll commit this to the hsa branch in a few moments and then to trunk at some point in summer. Martin 2016-06-02 Martin Jambor * hsa-brig.c (emit_insn_operands): Cope with zero operands in an instruction. --- gcc/hsa-brig.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c index 9c74b9a..471533c 100644 --- a/gcc/hsa-brig.c +++ b/gcc/hsa-brig.c @@ -1236,20 +1236,20 @@ emit_insn_operands (hsa_insn_basic *insn) operand_offsets; unsigned l = insn->operand_count (); - operand_offsets.safe_grow (l); - - for (unsigned i = 0; i < l; i++) - operand_offsets[i] = lendian32 (enqueue_op (insn->get_op (i))); /* We have N operands so use 4 * N for the byte_count. */ uint32_t byte_count = lendian32 (4 * l); - unsigned offset = brig_data.add (&byte_count, sizeof (byte_count)); - brig_data.add (operand_offsets.address (), - l * sizeof (BrigOperandOffset32_t)); + if (l > 0) + { + operand_offsets.safe_grow (l); + for (unsigned i = 0; i < l; i++) + operand_offsets[i] = lendian32 (enqueue_op (insn->get_op (i))); + brig_data.add (operand_offsets.address (), + l * sizeof (BrigOperandOffset32_t)); + } brig_data.round_size_up (4); - return offset; }