From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21834 invoked by alias); 16 Feb 2005 15:49:33 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 21769 invoked from network); 16 Feb 2005 15:49:25 -0000 Received: from unknown (HELO iris1.csv.ica.uni-stuttgart.de) (129.69.118.2) by sourceware.org with SMTP; 16 Feb 2005 15:49:25 -0000 Received: from rembrandt.csv.ica.uni-stuttgart.de ([129.69.118.42]) by iris1.csv.ica.uni-stuttgart.de with esmtp id 1D1RQa-0002k7-00 for ; Wed, 16 Feb 2005 16:49:24 +0100 Received: from ica2_ts by rembrandt.csv.ica.uni-stuttgart.de with local (Exim 3.35 #1 (Debian)) id 1D1RQa-0006db-00 for ; Wed, 16 Feb 2005 16:49:24 +0100 Date: Wed, 16 Feb 2005 23:51:00 -0000 To: binutils@sources.redhat.com Subject: [PATCH] MIPS gas: Fix macro expansions for .set noat Message-ID: <20050216154924.GG1757@rembrandt.csv.ica.uni-stuttgart.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i From: Thiemo Seufer X-SW-Source: 2005-02/txt/msg00374.txt.bz2 Hello All, In some cases, MIPS gas uses the $at register even if .set noat is in effect. The appended patch fixes this. Tested on mips-linux and committed. Thiemo 2005-02-16 Thiemo Seufer /gas/ChangeLog * config/tc-mips.c (load_address): Fix formatting. (macro): Don't use AT if .set noat is in effect. Fix formatting. Catch macros which are unexpandable without AT. Remove duplicate zeroing of used_at. (macro2): Remove duplicate zeroing of used_at. Index: gas/config/tc-mips.c =================================================================== RCS file: /cvs/src/src/gas/config/tc-mips.c,v retrieving revision 1.281 diff -u -p -r1.281 tc-mips.c --- gas/config/tc-mips.c 15 Feb 2005 19:57:52 -0000 1.281 +++ gas/config/tc-mips.c 16 Feb 2005 15:32:45 -0000 @@ -3877,7 +3877,7 @@ load_address (int reg, expressionS *ep, It used not to be possible with the original relaxation code, but it could be done now. */ - if (*used_at == 0 && ! mips_opts.noat) + if (*used_at == 0 && !mips_opts.noat) { macro_build (ep, "lui", "t,u", reg, BFD_RELOC_MIPS_HIGHEST); macro_build (ep, "lui", "t,u", AT, BFD_RELOC_HI16_S); @@ -4907,7 +4907,7 @@ macro (struct mips_cl_insn *ip) return; } - if (treg == breg) + if (!mips_opts.noat && (treg == breg)) { tempreg = AT; used_at = 1; @@ -4915,7 +4915,6 @@ macro (struct mips_cl_insn *ip) else { tempreg = treg; - used_at = 0; } if (offset_expr.X_op != O_symbol @@ -4963,7 +4962,7 @@ macro (struct mips_cl_insn *ip) these macros. It used not to be possible with the original relaxation code, but it could be done now. */ - if (used_at == 0 && ! mips_opts.noat) + if (used_at == 0 && !mips_opts.noat) { macro_build (&offset_expr, "lui", "t,u", tempreg, BFD_RELOC_MIPS_HIGHEST); @@ -5484,7 +5483,7 @@ macro (struct mips_cl_insn *ip) macro_build (NULL, s, "d,v,t", treg, tempreg, breg); } - if (! used_at) + if (!used_at) return; break; @@ -5762,11 +5761,19 @@ macro (struct mips_cl_insn *ip) case M_LWU_AB: s = "lwu"; ld: - if (breg == treg || coproc || lr) + /* XXX Why don't we try to use AT for all expansions? */ + if (!mips_opts.noat && (breg == treg || coproc || lr)) { tempreg = AT; used_at = 1; } + else if (breg == treg + && (offset_expr.X_op != O_constant + || (offset_expr.X_add_number > 0x7fff + || offset_expr.X_add_number < -0x8000))) + { + as_bad(_("load expansion needs $at register")); + } else { tempreg = treg; @@ -5840,8 +5847,23 @@ macro (struct mips_cl_insn *ip) case M_SDR_AB: s = "sdr"; st: - tempreg = AT; - used_at = 1; + if (!mips_opts.noat) + { + tempreg = AT; + used_at = 1; + } + else if (breg == treg + && (offset_expr.X_op != O_constant + || (offset_expr.X_add_number > 0x7fff + || offset_expr.X_add_number < -0x8000))) + { + as_bad(_("store expansion needs $at register")); + } + else + { + tempreg = treg; + used_at = 0; + } ld_st: /* Itbl support may require additional care here. */ if (mask == M_LWC1_AB @@ -5973,7 +5995,7 @@ macro (struct mips_cl_insn *ip) these macros. It used not to be possible with the original relaxation code, but it could be done now. */ - if (used_at == 0 && ! mips_opts.noat) + if (used_at == 0 && !mips_opts.noat) { macro_build (&offset_expr, "lui", "t,u", tempreg, BFD_RELOC_MIPS_HIGHEST); @@ -6006,6 +6028,9 @@ macro (struct mips_cl_insn *ip) BFD_RELOC_LO16, tempreg); } + if (used_at) + break; + return; } @@ -6022,7 +6047,6 @@ macro (struct mips_cl_insn *ip) macro_build (&offset_expr, s, fmt, treg, BFD_RELOC_GPREL16, mips_gp_register); relax_switch (); - used_at = 0; } macro_build_lui (&offset_expr, tempreg); macro_build (&offset_expr, s, fmt, treg, @@ -6086,7 +6110,7 @@ macro (struct mips_cl_insn *ip) macro_build (&offset_expr, s, fmt, treg, BFD_RELOC_MIPS_GOT_OFST, tempreg); - if (! used_at) + if (!used_at) return; break; @@ -6200,7 +6224,7 @@ macro (struct mips_cl_insn *ip) else abort (); - if (! used_at) + if (!used_at) return; break; @@ -6504,7 +6528,6 @@ macro (struct mips_cl_insn *ip) if (breg == 0) { tempreg = mips_gp_register; - used_at = 0; } else { @@ -6690,7 +6713,7 @@ macro (struct mips_cl_insn *ip) else abort (); - if (! used_at) + if (!used_at) return; break; @@ -6897,7 +6920,6 @@ macro2 (struct mips_cl_insn *ip) else { tempreg = dreg; - used_at = 0; } macro_build (NULL, "dnegu", "d,w", tempreg, treg); macro_build (NULL, "drorv", "d,t,s", dreg, sreg, tempreg); @@ -6922,7 +6944,6 @@ macro2 (struct mips_cl_insn *ip) else { tempreg = dreg; - used_at = 0; } macro_build (NULL, "negu", "d,w", tempreg, treg); macro_build (NULL, "rorv", "d,t,s", dreg, sreg, tempreg); @@ -7113,7 +7134,6 @@ macro2 (struct mips_cl_insn *ip) && imm_expr.X_add_number < 0x10000) { macro_build (&imm_expr, "xori", "t,r,i", dreg, sreg, BFD_RELOC_LO16); - used_at = 0; } else if (imm_expr.X_op == O_constant && imm_expr.X_add_number > -0x8000 @@ -7122,7 +7142,6 @@ macro2 (struct mips_cl_insn *ip) imm_expr.X_add_number = -imm_expr.X_add_number; macro_build (&imm_expr, HAVE_32BIT_GPRS ? "addiu" : "daddiu", "t,r,j", dreg, sreg, BFD_RELOC_LO16); - used_at = 0; } else { @@ -7153,7 +7172,6 @@ macro2 (struct mips_cl_insn *ip) { macro_build (&imm_expr, mask == M_SGE_I ? "slti" : "sltiu", "t,r,j", dreg, sreg, BFD_RELOC_LO16); - used_at = 0; } else { @@ -7263,7 +7281,6 @@ macro2 (struct mips_cl_insn *ip) && imm_expr.X_add_number < 0x10000) { macro_build (&imm_expr, "xori", "t,r,i", dreg, sreg, BFD_RELOC_LO16); - used_at = 0; } else if (imm_expr.X_op == O_constant && imm_expr.X_add_number > -0x8000 @@ -7272,7 +7289,6 @@ macro2 (struct mips_cl_insn *ip) imm_expr.X_add_number = -imm_expr.X_add_number; macro_build (&imm_expr, HAVE_32BIT_GPRS ? "addiu" : "daddiu", "t,r,j", dreg, sreg, BFD_RELOC_LO16); - used_at = 0; } else {