diff mbox

pdp11: fix assembler warning

Message ID 1A550A31-E248-4230-943B-7B3F7622013C@dell.com
State New
Headers show

Commit Message

Paul Koning Nov. 9, 2010, 1:08 a.m. UTC
This patch cures a number of "value truncated" assembler warnings that show up in the testsuite.

Tested by build and make check.  Committed.

	paul

ChangeLog:

2010-11-08  Paul Koning  <ni1d@arrl.net>

	* config/pdp11/pdp11.c (pdp11_assemble_integer): Mask byte values
	to 8 bits.

Comments

Richard Henderson Nov. 9, 2010, 1:42 a.m. UTC | #1
On 11/08/2010 05:08 PM, Paul Koning wrote:
> +				 GEN_INT (trunc_int_for_mode (INTVAL (x),
> +							      QImode) & 0xff));

This is gen_int_mode.

> +      fprintf (file, "%#o", (int) trunc_int_for_mode (INTVAL (x), HImode) & 0xffff);

Surely the & 0xffff isn't needed, since the value has already
been truncated.  Alternately, if you want an HImode value as
an unsigned number, then the trunc_int_for_mode isn't needed.


r~
Paul Koning Nov. 9, 2010, 11:47 a.m. UTC | #2
On Nov 8, 2010, at 8:42 PM, Richard Henderson wrote:

> On 11/08/2010 05:08 PM, Paul Koning wrote:
>> +				 GEN_INT (trunc_int_for_mode (INTVAL (x),
>> +							      QImode) & 0xff));
> 
> This is gen_int_mode.
> 
>> +      fprintf (file, "%#o", (int) trunc_int_for_mode (INTVAL (x), HImode) & 0xffff);
> 
> Surely the & 0xffff isn't needed, since the value has already
> been truncated.  Alternately, if you want an HImode value as
> an unsigned number, then the trunc_int_for_mode isn't needed.

True.  I remembered some consistency checks in trunc_int_for_mode, but now that I look more closely those aren't interesting.  So just a mask (for both cases) is what I need -- yes I need the unsigned value.

	paul
diff mbox

Patch

Index: config/pdp11/pdp11.c
===================================================================
--- config/pdp11/pdp11.c	(revision 166433)
+++ config/pdp11/pdp11.c	(working copy)
@@ -1002,7 +1002,10 @@ 
       {
       case 1:
 	fprintf (asm_out_file, "\t.byte\t");
-	output_addr_const_pdp11 (asm_out_file, x);
+	output_addr_const_pdp11 (asm_out_file, 
+				 GEN_INT (trunc_int_for_mode (INTVAL (x),
+							      QImode) & 0xff));
+;
 	fprintf (asm_out_file, " /* char */\n");
 	return true;
 
@@ -1739,9 +1742,7 @@ 
       break;
 
     case CONST_INT:
-      /* Should we check for constants which are too big?  Maybe cutting
-	 them off to 16 bits is OK?  */
-      fprintf (file, "%#ho", (unsigned short) INTVAL (x));
+      fprintf (file, "%#o", (int) trunc_int_for_mode (INTVAL (x), HImode) & 0xffff);
       break;
 
     case CONST: