From patchwork Tue Aug 9 14:27:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 657284 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 3s7xW84t68z9sBM for ; Wed, 10 Aug 2016 00:29:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=C3OaIOp6; 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:from:date :subject:to:message-id; q=dns; s=default; b=HTa8jFO/7Gyy7LmW1q/O gx7vAWLMjMHL8CTIbqmFhHojg6R2glESjfADdJ9tezOYD5WkHXDxOMLw8qho0ceb 6oQKu6Jp/2SY077AfoCNyA9oT3X8Tq1RpRDJkfJTn+nXzVwR1PLke2zNNT2czDte XfGOKUcgqAiB6aTkQt14M5o= 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:from:date :subject:to:message-id; s=default; bh=374K/jQS2HXBezr+WY7PLOQurl Q=; b=C3OaIOp6JmjJ84CAWYL+zAUTErjJrsCSaY+mZVM6f+cwKs9+BPZyJU9hO1 JnegVe2+94e+07EXY13iiJkUIVy2A73zVJukIO99Md2UwtKs9AxAsRE0thnXp2g0 VEUR6CMmoFLykpRqGJWwmbPZhoFqKChl1XK+55WqmARVPDdlA= Received: (qmail 58191 invoked by alias); 9 Aug 2016 14:28:36 -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 57950 invoked by uid 89); 9 Aug 2016 14:28:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=BAYES_05, FILL_THIS_FORM, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=03, 2016-08-04, 1509, 6, 15096 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 09 Aug 2016 14:28:31 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bX814-0004wd-Md for gcc-patches@gcc.gnu.org; Tue, 09 Aug 2016 10:28:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:47644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX814-0004w3-C0 for gcc-patches@gcc.gnu.org; Tue, 09 Aug 2016 10:28:26 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D7611ACFD for ; Tue, 9 Aug 2016 14:28:22 +0000 (UTC) Resent-From: Martin Jambor Resent-Date: Tue, 9 Aug 2016 16:28:22 +0200 Resent-Message-ID: <20160809142822.s4ocqlg4ia6c4otb@virgil.suse.cz> Resent-To: GCC Patches From: Martin Jambor Date: Tue, 9 Aug 2016 16:27:04 +0200 Subject: [hsa-branch] Remove unnecessary operators To: GCC Patches X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] Message-ID: X-Received-From: 195.135.220.15 X-IsSubscribed: yes Hi, since the HSA branch switched to a simple obstack from alloc-pools, it is not necessary to have a separate new operator for each instruction kind and it is enough if the common ancestor has one. Therefore, this patch removes them. Similarly, I learned that it is enough to make the delete operator private in the ancestor to make inaccessible in the descendants so I removed those as well. Unlike instructions, not all operand kinds use obstacks, so we have to have the operands in those that do. But at least there are fewer operand kinds than instruction kinds. Thanks, Martin 2016-08-04 Martin Jambor * hsa.h (hsa_insn_phi): Removed new and delete operators. (hsa_insn_br): Likewise. (hsa_insn_cbr): Likewise. (hsa_insn_sbr): Likewise. (hsa_insn_cmp): Likewise. (hsa_insn_mem): Likewise. (hsa_insn_atomic): Likewise. (hsa_insn_signal): Likewise. (hsa_insn_seg): Likewise. (hsa_insn_call): Likewise. (hsa_insn_arg_block): Likewise. (hsa_insn_comment): Likewise. (hsa_insn_srctype): Likewise. (hsa_insn_packed): Likewise. (hsa_insn_cvt): Likewise. (hsa_insn_alloca): Likewise. * hsa-gen.c (hsa_insn_phi::operator new): Removed. (hsa_insn_br::operator new): Likewise. (hsa_insn_cbr::operator new): Likewise. (hsa_insn_sbr::operator new): Likewise. (hsa_insn_cmp::operator new): Likewise. (hsa_insn_mem::operator new): Likewise. (hsa_insn_atomic::operator new): Likewise. (hsa_insn_signal::operator new): Likewise. (hsa_insn_seg::operator new): Likewise. (hsa_insn_call::operator new): Likewise. (hsa_insn_arg_block::operator new): Likewise. (hsa_insn_comment::operator new): Likewise. (hsa_insn_srctype::operator new): Likewise. (hsa_insn_packed::operator new): Likewise. (hsa_insn_cvt::operator new): Likewise. (hsa_insn_alloca::operator new): Likewise. --- gcc/hsa-gen.c | 128 ---------------------------------------------------------- gcc/hsa.h | 70 -------------------------------- 2 files changed, 198 deletions(-) diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index c578294..a9f4a8f 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -1452,14 +1452,6 @@ hsa_insn_phi::hsa_insn_phi (unsigned nops, hsa_op_reg *dst) dst->set_definition (this); } -/* New operator to allocate PHI instruction from obstack. */ - -void * -hsa_insn_phi::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing instructions for control flow and sychronization, */ @@ -1472,14 +1464,6 @@ hsa_insn_br::hsa_insn_br (unsigned nops, int opc, BrigType16_t t, { } -/* New operator to allocate branch instruction from obstack. */ - -void * -hsa_insn_br::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing instruction for conditional jump, CTRL is the control register determining whether the jump will be carried out, the new instruction is automatically added to its uses list. */ @@ -1489,14 +1473,6 @@ hsa_insn_cbr::hsa_insn_cbr (hsa_op_reg *ctrl) { } -/* New operator to allocate branch instruction from obstack. */ - -void * -hsa_insn_cbr::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing instruction for switch jump, CTRL is the index register. */ @@ -1507,14 +1483,6 @@ hsa_insn_sbr::hsa_insn_sbr (hsa_op_reg *index, unsigned jump_count) { } -/* New operator to allocate switch branch instruction from obstack. */ - -void * -hsa_insn_sbr::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Replace all occurrences of OLD_BB with NEW_BB in the statements jump table. */ @@ -1541,14 +1509,6 @@ hsa_insn_cmp::hsa_insn_cmp (BrigCompareOperation8_t cmp, BrigType16_t t, { } -/* New operator to allocate compare instruction from obstack. */ - -void * -hsa_insn_cmp::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of classes representing memory accesses. OPC is the opcode (must be BRIG_OPCODE_ST or BRIG_OPCODE_LD) and T is the type. The instruction operands are provided as ARG0 and ARG1. */ @@ -1574,14 +1534,6 @@ hsa_insn_mem::hsa_insn_mem (unsigned nops, int opc, BrigType16_t t, { } -/* New operator to allocate memory instruction from obstack. */ - -void * -hsa_insn_mem::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing atomic instructions. OPC is the principal opcode, AOP is the specific atomic operation opcode. T is the type of the instruction. The instruction operands are provided as ARG[0-3]. */ @@ -1602,14 +1554,6 @@ hsa_insn_atomic::hsa_insn_atomic (int nops, int opc, opc == BRIG_OPCODE_SIGNALNORET); } -/* New operator to allocate signal instruction from obstack. */ - -void * -hsa_insn_atomic::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing signal instructions. OPC is the prinicpal opcode, SOP is the specific signal operation opcode. T is the type of the instruction. The instruction operands are provided as ARG[0-3]. */ @@ -1624,14 +1568,6 @@ hsa_insn_signal::hsa_insn_signal (int nops, int opc, { } -/* New operator to allocate signal instruction from obstack. */ - -void * -hsa_insn_signal::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing segment conversion instructions. OPC is the opcode which must be either BRIG_OPCODE_STOF or BRIG_OPCODE_FTOS. DEST and SRCT are destination and source types respectively, SEG is the segment @@ -1647,14 +1583,6 @@ hsa_insn_seg::hsa_insn_seg (int opc, BrigType16_t dest, BrigType16_t srct, gcc_checking_assert (opc == BRIG_OPCODE_STOF || opc == BRIG_OPCODE_FTOS); } -/* New operator to allocate address conversion instruction from obstack. */ - -void * -hsa_insn_seg::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing a call instruction. CALLEE is the tree representation of the function being called. */ @@ -1671,14 +1599,6 @@ hsa_insn_call::hsa_insn_call (hsa_internal_fn *fn) { } -/* New operator to allocate call instruction from obstack. */ - -void * -hsa_insn_call::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - hsa_insn_call::~hsa_insn_call () { for (unsigned i = 0; i < m_input_args.length (); i++) @@ -1699,14 +1619,6 @@ hsa_insn_arg_block::hsa_insn_arg_block (BrigKind brig_kind, { } -/* New operator to allocate argument block instruction from obstack. */ - -void * -hsa_insn_arg_block::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - hsa_insn_comment::hsa_insn_comment (const char *s) : hsa_insn_basic (0, BRIG_KIND_DIRECTIVE_COMMENT) { @@ -1718,14 +1630,6 @@ hsa_insn_comment::hsa_insn_comment (const char *s) m_comment = buf; } -/* New operator to allocate comment instruction from obstack. */ - -void * -hsa_insn_comment::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - hsa_insn_comment::~hsa_insn_comment () { gcc_checking_assert (m_comment); @@ -1744,14 +1648,6 @@ hsa_insn_queue::hsa_insn_queue (int nops, int opcode, BrigSegment segment, { } -/* New operator to allocate source type instruction from obstack. */ - -void * -hsa_insn_srctype::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing the source type instruction in HSAIL. */ hsa_insn_srctype::hsa_insn_srctype (int nops, BrigOpcode opcode, @@ -1762,14 +1658,6 @@ hsa_insn_srctype::hsa_insn_srctype (int nops, BrigOpcode opcode, m_source_type (srct) {} -/* New operator to allocate packed instruction from obstack. */ - -void * -hsa_insn_packed::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing the packed instruction in HSAIL. */ hsa_insn_packed::hsa_insn_packed (int nops, BrigOpcode opcode, @@ -1781,14 +1669,6 @@ hsa_insn_packed::hsa_insn_packed (int nops, BrigOpcode opcode, m_operand_list = new hsa_op_operand_list (nops - 1); } -/* New operator to allocate convert instruction from obstack. */ - -void * -hsa_insn_cvt::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing the convert instruction in HSAIL. */ hsa_insn_cvt::hsa_insn_cvt (hsa_op_with_type *dest, hsa_op_with_type *src) @@ -1796,14 +1676,6 @@ hsa_insn_cvt::hsa_insn_cvt (hsa_op_with_type *dest, hsa_op_with_type *src) { } -/* New operator to allocate alloca from obstack. */ - -void * -hsa_insn_alloca::operator new (size_t size) -{ - return obstack_alloc (&hsa_obstack, size); -} - /* Constructor of class representing the alloca in HSAIL. */ hsa_insn_alloca::hsa_insn_alloca (hsa_op_with_type *dest, diff --git a/gcc/hsa.h b/gcc/hsa.h index 242103c..588c85a 100644 --- a/gcc/hsa.h +++ b/gcc/hsa.h @@ -487,17 +487,12 @@ class hsa_insn_phi : public hsa_insn_basic public: hsa_insn_phi (unsigned nops, hsa_op_reg *dst); - void *operator new (size_t); - /* Destination. */ hsa_op_reg *m_dest; private: /* Make the default constructor inaccessible. */ hsa_insn_phi () : hsa_insn_basic (1, HSA_OPCODE_PHI) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a PHI node. */ @@ -518,17 +513,12 @@ public: hsa_op_base *arg0 = NULL, hsa_op_base *arg1 = NULL, hsa_op_base *arg2 = NULL, hsa_op_base *arg3 = NULL); - void *operator new (size_t); - /* Number of work-items affected in the same way by the instruction. */ BrigWidth8_t m_width; private: /* Make the default constructor inaccessible. */ hsa_insn_br () : hsa_insn_basic (0, BRIG_OPCODE_BR) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Return true if P is a branching/synchronization instruction. */ @@ -551,15 +541,10 @@ class hsa_insn_cbr : public hsa_insn_br public: hsa_insn_cbr (hsa_op_reg *ctrl); - void *operator new (size_t); - private: /* Make the default constructor inaccessible. */ hsa_insn_cbr () : hsa_insn_br (0, BRIG_OPCODE_CBR, BRIG_TYPE_B1, BRIG_WIDTH_1) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether P is a contitional branching instruction. */ @@ -582,8 +567,6 @@ public: /* Default destructor. */ ~hsa_insn_sbr (); - void *operator new (size_t); - void replace_all_labels (basic_block old_bb, basic_block new_bb); /* Width as described in HSA documentation. */ @@ -598,9 +581,6 @@ public: private: /* Make the default constructor inaccessible. */ hsa_insn_sbr () : hsa_insn_basic (1, BRIG_OPCODE_SBR) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether P is a switch branching instruction. */ @@ -622,8 +602,6 @@ public: hsa_op_base *arg0 = NULL, hsa_op_base *arg1 = NULL, hsa_op_base *arg2 = NULL); - void *operator new (size_t); - /* Source type should be derived from operand types. */ /* The comparison operation. */ @@ -634,9 +612,6 @@ public: private: /* Make the default constructor inaccessible. */ hsa_insn_cmp () : hsa_insn_basic (1, BRIG_OPCODE_CMP) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a comparison instruction. */ @@ -656,8 +631,6 @@ class hsa_insn_mem : public hsa_insn_basic public: hsa_insn_mem (int opc, BrigType16_t t, hsa_op_base *arg0, hsa_op_base *arg1); - void *operator new (size_t); - /* Set alignment to VALUE. */ void set_align (BrigAlignment8_t value); @@ -680,9 +653,6 @@ protected: private: /* Make the default constructor inaccessible. */ hsa_insn_mem () : hsa_insn_basic (1, BRIG_OPCODE_LD) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a memory instruction. */ @@ -705,7 +675,6 @@ public: BrigType16_t t, BrigMemoryOrder memorder, hsa_op_base *arg0 = NULL, hsa_op_base *arg1 = NULL, hsa_op_base *arg2 = NULL, hsa_op_base *arg3 = NULL); - void *operator new (size_t); /* The operation itself. */ enum BrigAtomicOperation m_atomicop; @@ -719,9 +688,6 @@ public: private: /* Make the default constructor inaccessible. */ hsa_insn_atomic () : hsa_insn_mem (1, BRIG_KIND_NONE, BRIG_TYPE_NONE) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is an atomic instruction. */ @@ -745,17 +711,11 @@ public: hsa_op_base *arg0 = NULL, hsa_op_base *arg1 = NULL, hsa_op_base *arg2 = NULL, hsa_op_base *arg3 = NULL); - void *operator new (size_t); - /* Things like acquire/release/aligned. */ enum BrigMemoryOrder m_memory_order; /* The operation itself. */ enum BrigAtomicOperation m_signalop; -private: - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a signal instruction. */ @@ -777,8 +737,6 @@ public: hsa_insn_seg (int opc, BrigType16_t destt, BrigType16_t srct, BrigSegment8_t seg, hsa_op_base *arg0, hsa_op_base *arg1); - void *operator new (size_t); - /* Source type. Depends on the source addressing/segment. */ BrigType16_t m_src_type; /* The segment we are converting from or to. */ @@ -786,9 +744,6 @@ public: private: /* Make the default constructor inaccessible. */ hsa_insn_seg () : hsa_insn_basic (1, BRIG_OPCODE_STOF) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a segment conversion instruction. */ @@ -845,8 +800,6 @@ public: /* Default destructor. */ ~hsa_insn_call (); - void *operator new (size_t); - /* Called function. */ tree m_called_function; @@ -873,9 +826,6 @@ public: private: /* Make the default constructor inaccessible. */ hsa_insn_call () : hsa_insn_basic (0, BRIG_OPCODE_CALL) {} - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a call instruction. */ @@ -899,17 +849,11 @@ class hsa_insn_arg_block : public hsa_insn_basic public: hsa_insn_arg_block (BrigKind brig_kind, hsa_insn_call * call); - void *operator new (size_t); - /* Kind of argument block. */ BrigKind m_kind; /* Call instruction. */ hsa_insn_call *m_call_insn; -private: - /* All objects are deallocated by destroying their pool, so make delete - inaccessible too. */ - void operator delete (void *) {} }; /* Report whether or not P is a call block instruction. */ @@ -933,8 +877,6 @@ public: /* Default destructor. */ ~hsa_insn_comment (); - void *operator new (size_t); - char *m_comment; }; @@ -991,9 +933,6 @@ public: BrigType16_t srct, hsa_op_base *arg0, hsa_op_base *arg1, hsa_op_base *arg2); - /* Pool allocator. */ - void *operator new (size_t); - /* Source type. */ BrigType16_t m_source_type; @@ -1022,9 +961,6 @@ public: BrigType16_t srct, hsa_op_base *arg0, hsa_op_base *arg1, hsa_op_base *arg2); - /* Pool allocator. */ - void *operator new (size_t); - /* Operand list for an operand of the instruction. */ hsa_op_operand_list *m_operand_list; @@ -1049,9 +985,6 @@ class hsa_insn_cvt: public hsa_insn_basic { public: hsa_insn_cvt (hsa_op_with_type *dest, hsa_op_with_type *src); - - /* Pool allocator. */ - void *operator new (size_t); }; /* Report whether or not P is a convert instruction. */ @@ -1074,9 +1007,6 @@ public: /* Required alignment of the allocation. */ BrigAlignment8_t m_align; - - /* Pool allocator. */ - void *operator new (size_t); }; /* Report whether or not P is an alloca instruction. */