[M3devel] m3cc/configure -enable-checks=all non-trivial conversion at assignment

Jay K jay.krell at cornell.edu
Mon May 31 12:57:24 CEST 2010


configure -enable-checks=all

../src/M3FP.m3:48: error: non-trivial conversion at assignment
word_64
int_64

      error ("non-trivial conversion at assignment");
      debug_generic_expr (TREE_TYPE (lhs));
      debug_generic_expr (TREE_TYPE (rhs));
      return true;


gcc doesn't like conversion from word64 to int64.

PROCEDURE ExtendByInt (READONLY a: T;  i: Int): T = (* line 48 *)
  VAR buf: NChars;
  BEGIN
    FOR x := FIRST (buf) TO LAST (buf) DO
      buf [x] := VAL (Word.And (i, 16_ff), CHAR);
      i := Word.Shift (i, -8);  (* line 53 *)
    END;
    RETURN Fingerprint.FromChars (buf, a);
  END ExtendByInt;


The line is probably the one with the shift.
Int here is      Int = BITS 32 FOR [-16_7fffffff - 1 .. 16_7fffffff];

Presumably we should just build a cast?

I'm guessing the problem is:

(180) set_source_line
  source line   53
(181) load
  type:int32
  type:int64   
  m3cg_load (M3_ENQ7Kn_i): offset 0x0, convert int32 -> int64
(182) load_integer
  type:int64
  integer i:0xfe n_bytes:0x1 0x00000000000000008 sign -1
(183) shift
  type:word64  <== 
(184) import_procedure
  type:void
  procedure:RTHooks__ReportFault nparams:0x2 rettype:void
(185) declare_param
  type:addr
  param M3_AJWxb1_module type 0xb typeid 0x8402063 bytesize 0x40 alignment 0x40 in_memory 0x0 up_level 0x0
  mode 0x11 (DImode)
(186) declare_param
  type:int64
  param M3_AcxOUs_info type 0x7 typeid 0x195c2a74 bytesize 0x40 alignment 0x40 in_memory 0x0 up_level 0x0
  mode 0x11 (DImode)
(187) set_runtime_proc
(188) check_range
  type:int64
  integer i:0xfa n_bytes:0x4 0x00000000080000000 sign -1
  integer i:0xfb n_bytes:0x4 0x0000000007fffffff sign 1
  check range type 0x7 code 0x1
  declare_fault_proc: type is 0x11 (DImode)
(189) store
  type:int64  <==
  type:int32
  store (M3_ENQ7Kn_i) offset 0x0 src_t int64 dst_t int32
(190) set_source_line
 

The line numbers don't seem to be reported correctly -- we just get the first line of the function.

I don't think this is a serious problem, but probably here:

static void
m3cg_shift (void)
{
  MTYPE (t);

  tree n = declare_temp (t_int);
  tree x = declare_temp (t);

  gcc_assert (INTEGRAL_TYPE_P (t));

  add_stmt (m3_build2 (MODIFY_EXPR, t_int, n, EXPR_REF(-1)));
  add_stmt (m3_build2 (MODIFY_EXPR, t, x, EXPR_REF(-2)));


We should cast 1) assert t is unsigned and 2 ) cast x to it.

I will look into why we don't accidentally ever do arithmetic shift, as gcc does overload the same operand based on type:

/* Shift operations for shift and rotate.
   Shift means logical shift if done on an
   unsigned type, arithmetic shift if done on a signed type.
   The second operand is the number of bits to
   shift by; it need not be the same type as the first operand and result.
   Note that the result is undefined if the second operand is larger
   than or equal to the first operand's type size.  */
DEFTREECODE (LSHIFT_EXPR, "lshift_expr", tcc_binary, 2)
DEFTREECODE (RSHIFT_EXPR, "rshift_expr", tcc_binary, 2)
DEFTREECODE (LROTATE_EXPR, "lrotate_expr", tcc_binary, 2)
DEFTREECODE (RROTATE_EXPR, "rrotate_expr", tcc_binary, 2)


er. actually the problem is on output not input?
shift => word64
but then we do int64 => int32 conversion of the result.


 - Jay
 		 	   		  


More information about the M3devel mailing list