From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31107 invoked by alias); 10 Jan 2008 16:22:27 -0000 Received: (qmail 31096 invoked by uid 22791); 10 Jan 2008 16:22:27 -0000 X-Spam-Check-By: sourceware.org Received: from mail.gmx.net (HELO mail.gmx.net) (213.165.64.20) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 10 Jan 2008 16:22:07 +0000 Received: (qmail invoked by alias); 10 Jan 2008 16:22:04 -0000 Received: from pool-128-146-197-89.dbd-ipconnect.net (EHLO [192.168.178.22]) [89.197.146.128] by mail.gmx.net (mp042) with SMTP; 10 Jan 2008 17:22:04 +0100 X-Authenticated: #4022294 In-Reply-To: References: <35528597-A9DA-4D81-8EE4-4192FE591628@gmx.de> Mime-Version: 1.0 (Apple Message framework v753) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <97A81DD8-6B29-4F32-89D6-08B185E9E888@gmx.de> Cc: Ian Lance Taylor Content-Transfer-Encoding: 7bit From: Boris Boesler Subject: Re: Allocating scratch register Date: Thu, 10 Jan 2008 16:22:00 -0000 To: GCC X-Mailer: Apple Mail (2.753) X-Y-GMX-Trusted: 0 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/msg00117.txt.bz2 Hi! Am 09.01.2008 um 23:54 schrieb Ian Lance Taylor: > Boris Boesler writes: > >> I'm trying to allocate a scratch register: write immediate constant >> into scratch register r, write register r into memory ... >> 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. Yes, I can remember that constraints in a mov-insn can not be resolved by other/additional mov-insns. Ok, I rewrote my insns; there was a "mov"-insn with mode \in {QI, HI, SI}: (define_insn_and_split "movqi" [(set (match_operand:QI 0 "reg_mem_operand" "=mr") (match_operand:QI 1 "rim_operand" " mir")) (clobber (match_scratch:QI 2 "=r")) ] "" "#" "&& reload_completed" [(set (match_dup 2) (match_dup 1)) (set (match_dup 0) (match_dup 2))] "") ;; help insns (define_insn "mov_reg_by_store" [(set (match_operand:I8I16 0 "memory_operand" "= m") (match_operand:I8I16 1 "register_operand" " rAx"))] "" "bla bla bla") (define_insn "mov_reg_imm" [(set (match_operand:I8I16 0 "register_operand" "=rAx, rAx, rAx") (match_operand:I8I16 1 "immediate_operand" " I, i, rAx"))] "" "some other bla bla bla") These insns handle byte-accesses as expected. But now a previous tests fail for something like ashift:SI(reg:SI, const_int:QI 5): p.c:36: error: unrecognizable insn: (insn 114 18 115 (set (scratch:QI) (const_int 5 [0x5])) -1 (nil) (nil)) I do not understand why this happens does not happen in my byte- access example. So I added the two insns (I8I16 = {QI, HI}): (define_insn "mov_to_scratch" [(set (match_scratch:I8I16 0 "=r,r") (match_operand:I8I16 1 "reg_imm_operand" " r,i"))] "" "again bla bla bla") (define_insn "mov_from_scratch" [(set (match_operand:I8I16 0 "register_operand" "=r") (match_scratch:I8I16 1 " r"))] "" "even more bla bla bla") But now the compiler says: p.c:36: error: insn does not satisfy its constraints: (insn 114 18 115 (set (scratch:QI) (const_int 5 [0x5])) 79 {movqi_to_scratch} (nil) (nil)) p.c:36: internal compiler error: in final_scan_insn, at final.c:2382 The two insns in the dump file .shorten are: (insn 114 18 115 (set (scratch:QI) (const_int 5 [0x5])) 79 {movqi_to_scratch} (nil) (nil)) (insn 115 114 19 (set (reg:QI 31 R31) (scratch:QI)) 81 {movqi_from_scratch} (nil) (nil)) I can't see what's wrong. I guess I don't understand that scratch- stuff in gcc? Thanks, Boris