From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8010 invoked by alias); 9 Jan 2008 22:55:03 -0000 Received: (qmail 8001 invoked by uid 22791); 9 Jan 2008 22:55:03 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Jan 2008 22:54:45 +0000 Received: from zps75.corp.google.com (zps75.corp.google.com [172.25.146.75]) by smtp-out.google.com with ESMTP id m09MsWm2010529; Wed, 9 Jan 2008 22:54:33 GMT Received: from localhost.localdomain.google.com (dhcp-172-18-119-235.corp.google.com [172.18.119.235]) (authenticated bits=0) by zps75.corp.google.com with ESMTP id m09MsPYT029784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 9 Jan 2008 14:54:32 -0800 To: Boris Boesler Cc: GCC Subject: Re: Allocating scratch register References: <35528597-A9DA-4D81-8EE4-4192FE591628@gmx.de> From: Ian Lance Taylor Date: Wed, 09 Jan 2008 22:55:00 -0000 In-Reply-To: <35528597-A9DA-4D81-8EE4-4192FE591628@gmx.de> 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: 2008-01/txt/msg00104.txt.bz2 Boris Boesler writes: > I'm trying to allocate a scratch register: write immediate constant > into scratch register r, write register r into memory > > ;; write imm into memory > (define_insn_and_split "mov_imm_by_store" > [(set (match_operand:I8I16 0 "memory_operand" "=m") > (match_operand:I8I16 1 "immediate_operand" " i")) > (clobber (match_scratch:I8I16 2 "=r"))] > "" > "#" > "" > [(parallel > [(set (match_dup 2) (match_dup 1)) > (set (match_dup 0) (match_dup 2))])] > "" > ) > > I found that in a mips back-end. But this pattern is not recognized > during code-generation [char c1; c1 = 1;]: > simple-memory.c:19: error: unrecognizable insn: > (insn 12 11 14 3 (set (mem/c/i:QI (reg/f:SI 105) [0 c1+0 S8]) > (const_int 1 [0x1])) -1 (nil) > (nil)) > > If I remove the clobber command and replace (match_dup 2) by > (reg:I8I16 A15_REGNUM) code will be generated (but not as wanted). > > What is wrong with the code above? There is nothing wrong with that code, but nothing is going to make the compiler use it. Moves are special. If you need a scratch register to do a move, then you need to look at the TARGET_SECONDARY_RELOAD hook. But if the problem is only that you need a register to store a constant into memory, then you should be able to do that using register constraints on your mov insn. Ian