Exemplo n.º 1
0
int
vax_float_literal(rtx c)
{
  enum machine_mode mode;
  REAL_VALUE_TYPE r, s;
  int i;

  if (GET_CODE (c) != CONST_DOUBLE)
    return 0;

  mode = GET_MODE (c);

  if (c == const_tiny_rtx[(int) mode][0]
      || c == const_tiny_rtx[(int) mode][1]
      || c == const_tiny_rtx[(int) mode][2])
    return 1;

  REAL_VALUE_FROM_CONST_DOUBLE (r, c);

  for (i = 0; i < 7; i++)
    {
      int x = 1 << i;
      bool ok;
      REAL_VALUE_FROM_INT (s, x, 0, mode);

      if (REAL_VALUES_EQUAL (r, s))
	return 1;
      ok = exact_real_inverse (mode, &s);
      gcc_assert (ok);
      if (REAL_VALUES_EQUAL (r, s))
	return 1;
    }
  return 0;
}
Exemplo n.º 2
0
/*
 *	Return a new REAL_CST node whose type is TYPE
 *	and whose value is the integer value of the
 *	INTEGER_CST node I.
 */
REAL_VALUE_TYPE
real_value_from_int_cst (tree i)
{
	REAL_VALUE_TYPE		d;

#ifdef REAL_ARITHMETIC

	REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i));

#else /* not REAL_ARITHMETIC */
#define MASK ((unsigned)1 << (HOST_BITS_PER_INT - 1))

	if (TREE_INT_CST_HIGH (i) < 0)
	{
		d = (double) (~ TREE_INT_CST_HIGH (i));
		d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) *
			(double) (1 << (HOST_BITS_PER_INT / 2)));
		/*
		 *	The following four lines are equivalent
		 *	to converting ~ TREE_INT_CST_LOW (i) from
		 *	unsigned to double, but that is broken in
		 *	some compilers.
		 */
		if (((~ TREE_INT_CST_LOW (i)) & MASK) != 0)
			d += ((double) MASK +
				(double) ((~ MASK) & ~ TREE_INT_CST_LOW (i)));
		else
			d += (double) (unsigned) (~ TREE_INT_CST_LOW (i));

		d = (- d - 1.0);
	}
	else
	{
		d = (double) TREE_INT_CST_HIGH (i);
		d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) *
			(double) (1 << (HOST_BITS_PER_INT / 2)));

		if ((TREE_INT_CST_LOW (i) & MASK) != 0)
			d += ((double) MASK +
				(double) ((~ MASK) & TREE_INT_CST_LOW (i)));
		else
			d += (double) (unsigned) TREE_INT_CST_LOW (i);
	}

#undef MASK
#endif /* not REAL_ARITHMETIC */

	return (d);

}	/* end real_value_from_int_cst */
Exemplo n.º 3
0
static bool
ortho_init (void)
{
  tree n;

  input_location = BUILTINS_LOCATION;

  /* Create a global binding.  */
  push_binding ();

  build_common_tree_nodes (0);
  size_type_node = type_for_size (GET_MODE_BITSIZE (Pmode), 1);
  set_sizetype (size_type_node);
  build_common_tree_nodes_2 (0);

  n = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("int"), integer_type_node);
  push_decl (n);
  n = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("char"), char_type_node);
  push_decl (n);

  /* Create alloca builtin.  */
  {
    tree args_type = tree_cons (NULL_TREE, size_type_node, void_list_node);
    tree func_type = build_function_type (ptr_type_node, args_type);
       
    implicit_built_in_decls[BUILT_IN_ALLOCA] = builtin_function
      ("__builtin_alloca", func_type,
       BUILT_IN_ALLOCA, BUILT_IN_NORMAL, NULL, NULL_TREE);
    
    stack_alloc_function_ptr = build1
      (ADDR_EXPR, 
       build_pointer_type (func_type),
       implicit_built_in_decls[BUILT_IN_ALLOCA]);
  }

  {
    tree ptr_ftype = build_function_type (ptr_type_node, NULL_TREE);

    implicit_built_in_decls[BUILT_IN_STACK_SAVE] = builtin_function
      ("__builtin_stack_save", ptr_ftype,
       BUILT_IN_STACK_SAVE, BUILT_IN_NORMAL, NULL, NULL_TREE);
  }

  {
    tree ftype_ptr;

    ftype_ptr = build_function_type
      (void_type_node,
       tree_cons (NULL_TREE, ptr_type_node, NULL_TREE));

    implicit_built_in_decls[BUILT_IN_STACK_RESTORE] = builtin_function
      ("__builtin_stack_restore", ftype_ptr,
       BUILT_IN_STACK_RESTORE, BUILT_IN_NORMAL, NULL, NULL_TREE);
  }

  {
    REAL_VALUE_TYPE v;
    
    REAL_VALUE_FROM_INT (v, 1, 0, DFmode);
    real_ldexp (&fp_const_p5, &v, -1);
    
    REAL_VALUE_FROM_INT (v, -1, -1, DFmode);
    real_ldexp (&fp_const_m_p5, &v, -1);
    
    REAL_VALUE_FROM_INT (fp_const_zero, 0, 0, DFmode);
  }

  ortho_fe_init ();

  return true;
}
Exemplo n.º 4
0
static bool
ortho_init (void)
{
  tree n;

  input_location = BUILTINS_LOCATION;

  /* Create a global binding.  Don't use push_binding, as neither a BLOCK nor
     a BIND_EXPR are needed.  */
  push_binding (GLOBAL_BINDING);

  build_common_tree_nodes (0, 0);

  n = build_decl (input_location,
                  TYPE_DECL, get_identifier ("int"), integer_type_node);
  pushdecl (n);
  n = build_decl (input_location,
                  TYPE_DECL, get_identifier ("char"), char_type_node);
  pushdecl (n);

  /* Create alloca builtin.  */
  {
    tree args_type = tree_cons (NULL_TREE, size_type_node, void_list_node);
    tree func_type = build_function_type (ptr_type_node, args_type);

    define_builtin ("__builtin_alloca", func_type,
		    BUILT_IN_ALLOCA, NULL, 0);

    stack_alloc_function_ptr = build1
      (ADDR_EXPR,
       build_pointer_type (func_type),
       builtin_decl_implicit (BUILT_IN_ALLOCA));
  }

  {
    tree ptr_ftype = build_function_type (ptr_type_node, NULL_TREE);

    define_builtin ("__builtin_stack_save", ptr_ftype,
		    BUILT_IN_STACK_SAVE, NULL, 0);
  }

  {
    tree ftype_ptr = build_function_type_list (void_type_node,
					       ptr_type_node, NULL_TREE);

    define_builtin ("__builtin_stack_restore", ftype_ptr,
		    BUILT_IN_STACK_RESTORE, NULL, 0);
  }

  {
    tree ftype_ptr = build_function_type_list (void_type_node, NULL_TREE);

    define_builtin ("__builtin_trap", ftype_ptr,
		    BUILT_IN_TRAP, NULL, ECF_NOTHROW | ECF_LEAF);
    TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1;
  }

  {
    REAL_VALUE_TYPE v;

    REAL_VALUE_FROM_INT (v, 1, 0, DFmode);
    real_ldexp (&fp_const_p5, &v, -1);

    REAL_VALUE_FROM_INT (v, -1, -1, DFmode);
    real_ldexp (&fp_const_m_p5, &v, -1);

    REAL_VALUE_FROM_INT (fp_const_zero, 0, 0, DFmode);
  }

  build_common_builtin_nodes ();
  // FIXME: this MAY remove the need for creating the builtins above...
  // Evaluate tree.c / build_common_builtin_nodes (); for each in turn.

  return true;
}