This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] S/390: Don't ICE in print_operand and print_operand_address
- From: "Andreas Krebbel" <krebbel at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Nov 2010 15:08:59 +0100
- Subject: [Committed] S/390: Don't ICE in print_operand and print_operand_address
Hi,
the attached patch replaces several assertions and fatal_insn calls
with error printing statements when printing operands. This avoids
ICEs to be issued when inline asm hackers use wrong operands or output
modifiers.
Committed to mainline.
Bye,
-Andreas-
2010-11-26 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/s390.c (print_operand_address): Replace assert with
error message.
(print_operand): Replace assertions, gcc_unreachable and
fatal_insn with error messages.
Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c.orig
--- gcc/config/s390/s390.c
*************** print_operand_address (FILE *file, rtx a
*** 5130,5136 ****
if (s390_symref_operand_p (addr, NULL, NULL))
{
! gcc_assert (TARGET_Z10);
output_addr_const (file, addr);
return;
}
--- 5130,5140 ----
if (s390_symref_operand_p (addr, NULL, NULL))
{
! if (!TARGET_Z10)
! {
! error ("symbolic memory references are only supported on z10 or later");
! return;
! }
output_addr_const (file, addr);
return;
}
*************** print_operand (FILE *file, rtx x, int co
*** 5197,5203 ****
else if (GET_CODE (x) == GT)
fprintf (file, "h");
else
! gcc_unreachable ();
return;
case 'J':
--- 5201,5207 ----
else if (GET_CODE (x) == GT)
fprintf (file, "h");
else
! error ("invalid comparison operator for 'E' output modifier");
return;
case 'J':
*************** print_operand (FILE *file, rtx x, int co
*** 5217,5223 ****
assemble_name (file, get_some_local_dynamic_name ());
}
else
! gcc_unreachable ();
return;
case 'G':
--- 5221,5227 ----
assemble_name (file, get_some_local_dynamic_name ());
}
else
! error ("invalid reference for 'J' output modifier");
return;
case 'G':
*************** print_operand (FILE *file, rtx x, int co
*** 5229,5239 ****
struct s390_address ad;
int ret;
! gcc_assert (GET_CODE (x) == MEM);
ret = s390_decompose_address (XEXP (x, 0), &ad);
! gcc_assert (ret);
! gcc_assert (!ad.base || REGNO_OK_FOR_BASE_P (REGNO (ad.base)));
! gcc_assert (!ad.indx);
if (ad.disp)
output_addr_const (file, ad.disp);
--- 5233,5253 ----
struct s390_address ad;
int ret;
! if (!MEM_P (x))
! {
! error ("memory reference expected for 'O' output modifier");
! return;
! }
!
ret = s390_decompose_address (XEXP (x, 0), &ad);
!
! if (!ret
! || (ad.base && !REGNO_OK_FOR_BASE_P (REGNO (ad.base)))
! || ad.indx)
! {
! error ("invalid address for 'O' output modifier");
! return;
! }
if (ad.disp)
output_addr_const (file, ad.disp);
*************** print_operand (FILE *file, rtx x, int co
*** 5247,5257 ****
struct s390_address ad;
int ret;
! gcc_assert (GET_CODE (x) == MEM);
ret = s390_decompose_address (XEXP (x, 0), &ad);
! gcc_assert (ret);
! gcc_assert (!ad.base || REGNO_OK_FOR_BASE_P (REGNO (ad.base)));
! gcc_assert (!ad.indx);
if (ad.base)
fprintf (file, "%s", reg_names[REGNO (ad.base)]);
--- 5261,5281 ----
struct s390_address ad;
int ret;
! if (!MEM_P (x))
! {
! error ("memory reference expected for 'R' output modifier");
! return;
! }
!
ret = s390_decompose_address (XEXP (x, 0), &ad);
!
! if (!ret
! || (ad.base && !REGNO_OK_FOR_BASE_P (REGNO (ad.base)))
! || ad.indx)
! {
! error ("invalid address for 'R' output modifier");
! return;
! }
if (ad.base)
fprintf (file, "%s", reg_names[REGNO (ad.base)]);
*************** print_operand (FILE *file, rtx x, int co
*** 5265,5275 ****
struct s390_address ad;
int ret;
! gcc_assert (GET_CODE (x) == MEM);
ret = s390_decompose_address (XEXP (x, 0), &ad);
! gcc_assert (ret);
! gcc_assert (!ad.base || REGNO_OK_FOR_BASE_P (REGNO (ad.base)));
! gcc_assert (!ad.indx);
if (ad.disp)
output_addr_const (file, ad.disp);
--- 5289,5308 ----
struct s390_address ad;
int ret;
! if (!MEM_P (x))
! {
! error ("memory reference expected for 'S' output modifier");
! return;
! }
ret = s390_decompose_address (XEXP (x, 0), &ad);
!
! if (!ret
! || (ad.base && !REGNO_OK_FOR_BASE_P (REGNO (ad.base)))
! || ad.indx)
! {
! error ("invalid address for 'S' output modifier");
! return;
! }
if (ad.disp)
output_addr_const (file, ad.disp);
*************** print_operand (FILE *file, rtx x, int co
*** 5287,5293 ****
else if (GET_CODE (x) == MEM)
x = change_address (x, VOIDmode, plus_constant (XEXP (x, 0), 4));
else
! gcc_unreachable ();
break;
case 'M':
--- 5320,5326 ----
else if (GET_CODE (x) == MEM)
x = change_address (x, VOIDmode, plus_constant (XEXP (x, 0), 4));
else
! error ("register or memory expression expected for 'N' output modifier");
break;
case 'M':
*************** print_operand (FILE *file, rtx x, int co
*** 5296,5302 ****
else if (GET_CODE (x) == MEM)
x = change_address (x, VOIDmode, plus_constant (XEXP (x, 0), 8));
else
! gcc_unreachable ();
break;
case 'Y':
--- 5329,5335 ----
else if (GET_CODE (x) == MEM)
x = change_address (x, VOIDmode, plus_constant (XEXP (x, 0), 8));
else
! error ("register or memory expression expected for 'M' output modifier");
break;
case 'Y':
*************** print_operand (FILE *file, rtx x, int co
*** 5357,5367 ****
else if (code == 'h')
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ((CONST_DOUBLE_LOW (x) & 0xffff) ^ 0x8000) - 0x8000);
else
! gcc_unreachable ();
break;
default:
! fatal_insn ("UNKNOWN in print_operand !?", x);
break;
}
}
--- 5390,5408 ----
else if (code == 'h')
fprintf (file, HOST_WIDE_INT_PRINT_DEC, ((CONST_DOUBLE_LOW (x) & 0xffff) ^ 0x8000) - 0x8000);
else
! {
! if (code == 0)
! error ("invalid constant - try using an output modifier");
! else
! error ("invalid constant for output modifier '%c'", code);
! }
break;
default:
! if (code == 0)
! error ("invalid expression - try using an output modifier");
! else
! error ("invalid expression for output modifier '%c'", code);
break;
}
}