FreeBSD/contrib/binutils/gas/config/tc-i386.c
/* Try to use the smallest displacement type too.  */
Try to use the smallest displacement type too.
Try to use the smallest displacement type too .
static void
optimize_disp (void)
{
  int op;
  for (op = i.operands; --op >= 0;)
    if (i.types[op] & Disp)
      {
	if (i.op[op].disps->X_op == O_constant)
	  {
	    offsetT disp = i.op[op].disps->X_add_number;
	    if ((i.types[op] & Disp16)
		&& (disp & ~(offsetT) 0xffff) == 0)
	      {
		disp = (((disp & 0xffff) ^ 0x8000) - 0x8000);
		i.types[op] &= ~Disp64;
	      }
	    if ((i.types[op] & Disp32)
		&& (disp & ~(((offsetT) 2 << 31) - 1)) == 0)
	      {
		disp &= (((offsetT) 2 << 31) - 1);
		disp = (disp ^ ((offsetT) 1 << 31)) - ((addressT) 1 << 31);
		i.types[op] &= ~Disp64;
	      }
	    if (!disp && (i.types[op] & BaseIndex))
	      {
		i.types[op] &= ~Disp;
		i.op[op].disps = 0;
		i.disp_operands--;
	      }
	    else if (flag_code == CODE_64BIT)
	      {
		if (fits_in_signed_long (disp))
		  {
		    i.types[op] &= ~Disp64;
		    i.types[op] |= Disp32S;
		  }
		if (fits_in_unsigned_long (disp))
		  i.types[op] |= Disp32;
	      }
	    if ((i.types[op] & (Disp32 | Disp32S | Disp16))
		&& fits_in_signed_byte (disp))
	      i.types[op] |= Disp8;
	  }
	else if (i.reloc[op] == BFD_RELOC_386_TLS_DESC_CALL
		 || i.reloc[op] == BFD_RELOC_X86_64_TLSDESC_CALL)
	  {
	    fix_new_exp (frag_now, frag_more (0) - frag_now->fr_literal, 0,
			 i.op[op].disps, 0, i.reloc[op]);
	    i.types[op] &= ~Disp;
	  }
 	else
	  i.types[op] &= ~Disp64;
      }
}
static void optimize_disp ( void ) { int op ; for ( op = i . operands ; -- op >= 0 ; ) if ( i . types [ op ] & Disp ) { if ( i . op [ op ] . disps -> X_op == O_constant ) { offsetT disp = i . op [ op ] . disps -> X_add_number ; if ( ( i . types [ op ] & Disp16 ) && ( disp & ~ ( offsetT ) 0xffff ) == 0 ) { disp = ( ( ( disp & 0xffff ) ^ 0x8000 ) - 0x8000 ) ; i . types [ op ] &= ~ Disp64 ; } if ( ( i . types [ op ] & Disp32 ) && ( disp & ~ ( ( ( offsetT ) 2 << 31 ) - 1 ) ) == 0 ) { disp &= ( ( ( offsetT ) 2 << 31 ) - 1 ) ; disp = ( disp ^ ( ( offsetT ) 1 << 31 ) ) - ( ( addressT ) 1 << 31 ) ; i . types [ op ] &= ~ Disp64 ; } if ( ! disp && ( i . types [ op ] & BaseIndex ) ) { i . types [ op ] &= ~ Disp ; i . op [ op ] . disps = 0 ; i . disp_operands -- ; } else if ( flag_code == CODE_64BIT ) { if ( fits_in_signed_long ( disp ) ) { i . types [ op ] &= ~ Disp64 ; i . types [ op ] |= Disp32S ; } if ( fits_in_unsigned_long ( disp ) ) i . types [ op ] |= Disp32 ; } if ( ( i . types [ op ] & ( Disp32 | Disp32S | Disp16 ) ) && fits_in_signed_byte ( disp ) ) i . types [ op ] |= Disp8 ; } else if ( i . reloc [ op ] == BFD_RELOC_386_TLS_DESC_CALL || i . reloc [ op ] == BFD_RELOC_X86_64_TLSDESC_CALL ) { fix_new_exp ( frag_now , frag_more ( 0 ) - frag_now -> fr_literal , 0 , i . op [ op ] . disps , 0 , i . reloc [ op ] ) ; i . types [ op ] &= ~ Disp ; } else i . types [ op ] &= ~ Disp64 ; } }
Try to use the smallest displacement type too.
Try to use the smallest displacement type too .
/* If this operand is at most 16 bits, convert
		   to a signed 16 bit number and don't use 64bit
		   displacement.  */ /* If this operand is at most 32 bits, convert
		   to a signed 32 bit number and don't use 64bit
		   displacement.  */ /* We only support 64bit displacement on constants.  */