From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26473 invoked by alias); 30 Jul 2007 04:37:31 -0000 Received: (qmail 26462 invoked by uid 22791); 30 Jul 2007 04:37:31 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 30 Jul 2007 04:37:28 +0000 Received: from zps75.corp.google.com (zps75.corp.google.com [172.25.146.75]) by smtp-out.google.com with ESMTP id l6U4bMSH032701; Sun, 29 Jul 2007 21:37:23 -0700 Received: from smtp.corp.google.com (spacemonkey2.corp.google.com [192.168.120.114]) by zps75.corp.google.com with ESMTP id l6U4b6xl015487 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 29 Jul 2007 21:37:07 -0700 Received: from localhost.localdomain.google.com (adsl-71-133-8-30.dsl.pltn13.pacbell.net [71.133.8.30]) (authenticated bits=0) by smtp.corp.google.com (8.13.8/8.13.8) with ESMTP id l6U4b6Hs022206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 29 Jul 2007 21:37:06 -0700 To: petruk_gile Cc: gcc@gcc.gnu.org Subject: Re: How to activate instruction scheduling in GCC? References: <11857079.post@talk.nabble.com> From: Ian Lance Taylor Date: Mon, 30 Jul 2007 04:37:00 -0000 In-Reply-To: <11857079.post@talk.nabble.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg00916.txt.bz2 petruk_gile writes: > I'm a pure beginner in GCC, and currently working on a project to implement > instruction scheduling for a new DSP processor. This processor doesn't have > pipeline interlock, so the compiler HAVE to schedule the instruction without > relying on hardware help anymore .... > > The problem is, I'm a very beginner in GCC. I think the scheduling in GCC is > activated by INSN_SCHEDULING variable (in automatically generated file: > insn-attr.h), but I don't even know how to activate this variable. INSN_SCHEDULING will automatically be turned on if you have any define_insn_reservation clauses in your CPU.md file. See the "Processor pipeline description" documentation in the gcc internals manual. That said, the gcc scheduler unfortunately does not work very well for processors which do not have hardware interlocks. The scheduler will lay out the instructions more or less optimally. But the scheduler has no ability to insert nops when they are required to satisfy interlock constraints. I know of two workable approachs. You can either insert the required nops in the TARGET_MACHINE_DEPENDENT_REORG pass or in the TARGET_ASM_FUNCTION_PROLOGUE hook. I personally prefer the latter approach, as it takes effect after all other instruction rearrangement is complete, but there are existing backends which use the former. For an example of inserting nops in TARGET_MACHINE_DEPENDENT_REORG, see the MIPS backend, specifically mips_avoid_hazards. For an example of inserting nops in TARGET_ASM_FUNCTION_PROLOGUE, see the FRV backend, specifically frv_pack_insns. Ian