From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3319 invoked by alias); 17 Oct 2010 16:22:41 -0000 Received: (qmail 3308 invoked by uid 22791); 17 Oct 2010 16:22:39 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from eddie.linux-mips.org (HELO cvs.linux-mips.org) (78.24.191.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Oct 2010 16:22:35 +0000 Received: from localhost.localdomain ([127.0.0.1]:41938 "EHLO localhost.localdomain" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S1491127Ab0JQQWb (ORCPT ); Sun, 17 Oct 2010 18:22:31 +0200 Date: Sun, 17 Oct 2010 16:22:00 -0000 From: "Maciej W. Rozycki" To: Richard Sandiford cc: binutils@sourceware.org Subject: [PATCH 1/2] MIPS/GAS: Fix o32 LD to the base register Message-ID: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00258.txt.bz2 Hi, Here's another one: $ cat ld-base.s ld $4, ($4) $ mips-linux-as -o ld-base.o ld-base.s $ mips-linux-objdump -d ld-base.o ld-base.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <.text>: 0: 8c840000 lw a0,0(a0) 4: 00000000 nop 8: 8c850004 lw a1,4(a0) Ouch! Fixed thus and regression tested for mips-linux, mips64-linux, mipstx39-elf, mipsisa64-elf and mips-ecoff targets and their little-endian counterparts. The new code produced looks like this: $ mips-linux-objdump -d ld-base.o ld-base.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <.text>: 0: 00800821 move at,a0 4: 8c240000 lw a0,0(at) 8: 8c250004 lw a1,4(at) 2010-10-17 Maciej W. Rozycki gas/ * config/tc-mips.c (macro)[M_LD_OB]: Use a temporary register when the first load of the pair would overwrite the base register needed for the other one. OK? And thanks for your reviews so far -- I'll try to proceed with commits ASAP. Maciej binutils-2.20.51-20100925-mips-gas-ld-tmp.patch Index: binutils-2.20.51/gas/config/tc-mips.c =================================================================== --- binutils-2.20.51.orig/gas/config/tc-mips.c +++ binutils-2.20.51/gas/config/tc-mips.c @@ -7346,9 +7346,19 @@ macro (struct mips_cl_insn *ip) case M_LD_OB: s = HAVE_64BIT_GPRS ? "ld" : "lw"; + if (!HAVE_64BIT_GPRS && treg == breg && breg != ZERO) + { + /* First load would overwrite the base register, use a + temporary register. */ + used_at = 1; + macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", AT, breg, ZERO); + breg = AT; + } goto sd_ob; + case M_SD_OB: s = HAVE_64BIT_GPRS ? "sd" : "sw"; + sd_ob: macro_build (&offset_expr, s, "t,o(b)", treg, BFD_RELOC_LO16, breg); if (!HAVE_64BIT_GPRS)