[M3devel] extra temporaries?

Jay K jay.krell at cornell.edu
Sun Jun 27 13:07:06 CEST 2010


Why all these extra temporaries?

static voidm3cg_max (void){  MTYPE (t);
  tree t1 = declare_temp (t);  tree t2 = declare_temp (t);
  add_stmt (m3_build2 (MODIFY_EXPR, t, t1, EXPR_REF (-1)));  add_stmt (m3_build2 (MODIFY_EXPR, t, t2, EXPR_REF (-2)));
  EXPR_REF (-2) = m3_build3 (COND_EXPR, t,                             m3_build2 (LE_EXPR, boolean_type_node, t2, t1),                             t1, t2);  EXPR_POP ();}

static voidm3cg_min (void){  MTYPE (t);
  tree t1 = declare_temp (t);  tree t2 = declare_temp (t);
  add_stmt (m3_build2 (MODIFY_EXPR, t, t1, EXPR_REF (-1)));  add_stmt (m3_build2 (MODIFY_EXPR, t, t2, EXPR_REF (-2)));
  EXPR_REF (-2) = m3_build3 (COND_EXPR, t,                             m3_build2 (LE_EXPR, boolean_type_node, t1, t2),                             t1, t2);  EXPR_POP ();}


static voidm3cg_check_nil (void){  INTEGER (code);
  tree temp1 = declare_temp (t_addr);
  m3_store (temp1, 0, t_addr, T_addr, t_addr, T_addr);  EXPR_PUSH (temp1);  add_stmt (build3 (COND_EXPR, t_void,                    m3_build2 (EQ_EXPR, boolean_type_node, temp1, v_null),                    generate_fault (code),                    NULL_TREE));}


static voidm3cg_check_lo (void){  MTYPE2         (t, T);  TARGET_INTEGER (a);  INTEGER        (code);
  tree temp1 = declare_temp (t);
  a = convert (t, a);
  if (option_exprs_trace)    fprintf (stderr, "  check low type:%s code:0x%lx\n", m3cg_typename(T), code);
  if (TREE_TYPE (EXPR_REF (-1)) != t)    EXPR_REF (-1) = m3_build1 (CONVERT_EXPR, t, EXPR_REF (-1));
  m3_store (temp1, 0, t, T, t, T);  EXPR_PUSH (temp1);  add_stmt (build3 (COND_EXPR, t_void,                    m3_build2 (LT_EXPR, boolean_type_node, temp1, a),                    generate_fault (code),                    NULL_TREE));}

static voidm3cg_check_hi (void){  MTYPE2         (t, T);  TARGET_INTEGER (a);  INTEGER        (code);
  tree temp1 = declare_temp (t);
  a = convert (t, a);
  if (option_exprs_trace)    fprintf (stderr, "  check high type:%s code:0x%lx\n", m3cg_typename(T), code);
  if (TREE_TYPE (EXPR_REF (-1)) != t)    EXPR_REF (-1) = m3_build1 (CONVERT_EXPR, t, EXPR_REF (-1));
  m3_store (temp1, 0, t, T, t, T);  EXPR_PUSH (temp1);  add_stmt (build3 (COND_EXPR, t_void,                    m3_build2 (GT_EXPR, boolean_type_node, temp1, a),                    generate_fault (code),                    NULL_TREE));}

static voidm3cg_check_range (void){  MTYPE2         (t, T);  TARGET_INTEGER (a);  TARGET_INTEGER (b);  INTEGER        (code);
  tree temp1 = declare_temp (t);
  a = convert (t, a);  b = convert (t, b);
  if (option_exprs_trace)    fprintf (stderr, "  check range type:%s code:0x%lx\n", m3cg_typename(T), code);
  if (TREE_TYPE (EXPR_REF (-1)) != t)    EXPR_REF (-1) = m3_build1 (CONVERT_EXPR, t, EXPR_REF (-1));
  m3_store (temp1, 0, t, T, t, T);  EXPR_PUSH (temp1);  add_stmt (build3 (COND_EXPR, t_void,                    m3_build2 (TRUTH_ORIF_EXPR, boolean_type_node,                               m3_build2 (LT_EXPR,                                          boolean_type_node, temp1, a),                               m3_build2 (GT_EXPR,                                          boolean_type_node, temp1, b)),                    generate_fault (code),                    NULL_TREE));}

static voidm3cg_check_eq (void){  MTYPE2  (t, T);  INTEGER (code);
  tree temp1 = declare_temp (t);  tree temp2 = declare_temp (t);
  m3_store (temp1, 0, t, T, t, T);  m3_store (temp2, 0, t, T, t, T);  add_stmt (build3 (COND_EXPR, t_void,                    m3_build2 (NE_EXPR, boolean_type_node, temp1, temp2),                    generate_fault (code),                    NULL_TREE));}

seem kind of wasteful.

 - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100627/1b034a0f/attachment-0001.html>


More information about the M3devel mailing list